-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-boxes.html
85 lines (81 loc) · 2.72 KB
/
simple-boxes.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="overflow: hidden;">
<div id="container"
style="width: 100vw; flex-wrap: nowrap; height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 4rem 0rem; box-sizing: border-box; overflow:auto;">
<div class="box"
style="width: 50vw; border: 1px solid #333; flex-shrink: 0; margin: 4rem 0rem; height: 20rem; display: flex; justify-content: center; align-items: center;">
Box 1
</div>
<div class="box"
style="width: 50vw; border: 1px solid #333; flex-shrink: 0; margin: 4rem 0rem; height: 20rem; display: flex; justify-content: center; align-items: center;">
Box 2
</div>
<div class="box"
style="width: 50vw; border: 1px solid #333; flex-shrink: 0; margin: 4rem 0rem; height: 20rem; display: flex; justify-content: center; align-items: center;">
Box 3
</div>
<div class="box"
style="width: 50vw; border: 1px solid #333; flex-shrink: 0; margin: 4rem 0rem; height: 20rem; display: flex; justify-content: center; align-items: center;">
Box 4
</div>
</div>
<script type="module">
import AnimeScrollTrigger
from "https://cdn.jsdelivr.net/npm/[email protected]/dist/anime-scrolltrigger.es.js";
let container = document.getElementById('container');
let boxes = container.querySelectorAll('.box');
let animations = [
{
targets: boxes[0],
translateX: 100,
easing: 'linear',
scrollTrigger: {
trigger: boxes[0],
start: 'top 3%',
end: 'bottom 30%',
}
},
{
targets: boxes[1],
backgroundColor: '#a993ff',
easing: 'linear',
scrollTrigger: {
trigger: boxes[1],
start: 'top 40%',
end: 'bottom center',
lerp: true,
}
},
{
targets: boxes[2],
backgroundColor: '#02cdf1',
easing: 'linear',
scrollTrigger: {
trigger: boxes[2],
start: 'top 60%',
end: 'bottom 80%',
lerp: true,
}
},
{
targets: boxes[3],
translateY: -100,
easing: 'linear',
scrollTrigger: {
trigger: boxes[3],
lerp: true,
start: 'top 60%',
end: 'bottom 80%',
}
}
]
new AnimeScrollTrigger(container, animations);
</script>
</body>
</html>