-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother-people-libraries.html
54 lines (47 loc) · 1.42 KB
/
other-people-libraries.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<title>Animation</title>
<link href="./animation.css" rel="stylesheet" type="text/css" />
<style>
.box {
width: 100px;
height: 100px;
background-color: #0074d9;
border-radius: 50%;
}
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 400px;
}
</style>
</head>
<body>
<h1>Animation</h1>
<div class="box"></div>
<script src="https://unpkg.com/popmotion@8.1.24/dist/popmotion.global.min.js"></script>
<script>
// code taken from one of the examples on popmotion.io
const ball = document.querySelector(".box");
const divStyler = popmotion.styler(ball);
const ballXY = popmotion.value({ x: 0, y: 0 }, divStyler.set);
popmotion.listen(ball, "mousedown touchstart").start(e => {
e.preventDefault();
popmotion.pointer(ballXY.get()).start(ballXY);
});
popmotion.listen(document, "mouseup").start(() => {
popmotion
.spring({
from: ballXY.get(),
velocity: ballXY.getVelocity(),
to: { x: 0, y: 0 },
stiffness: 200
})
.start(ballXY);
});
</script>
</body>
</html>