-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
160 lines (127 loc) · 2.52 KB
/
script.js
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
const tl = gsap.timeline({scrollTrigger:{
trigger:"#section2",
start: "0% 95%",
end: "60% 50%",
scrub:true,
markers:false
}});
tl.to("#fanta",{
top:"120%",
left:"5%",
duration:2,
}, 'heroAnimation')
tl.to("#orange2",{
top:"160%",
left:"25%",
zIndex:"9",
duration: 2,
}, 'heroAnimation')
tl.to("#orange1", {
top:"160%",
left:"70%",
duration: 2,
}, 'heroAnimation')
tl.to("#leaf1", {
top:"105%",
left:"70%",
zIndex:"3",
rotation: 75,
duration: 2,
}, 'heroAnimation')
tl.to("#leaf2", {
top:"115%",
left:"8%",
zIndex:"3",
rotation: 180,
duration: 2,
}, 'heroAnimation')
const tl2 = gsap.timeline({scrollTrigger:{
trigger:"#section3",
start: "0% 95%",
end: "50% 55%",
scrub:true,
markers:false
}});
tl2.from("#cocacola",{
rotation: "-90deg",
top:"10%",
right:"30%",
duration:3,
}, "can")
tl2.from("#lemonC",{
rotation: "-90deg",
top:"10%",
right:"30%",
duration:3,
}, "can")
tl2.from("#pepsi",{
rotation: "90deg",
top:"10%",
left:"30%",
duration:3,
// left:"50%",
}, "can")
tl2.from("#lemonP",{
rotation: "90deg",
top:"10%",
left:"30%",
duration:3,
// left:"50%",
}, "can")
const tl3 = gsap.timeline({scrollTrigger:{
trigger:"#section3",
start: "0% 95%",
end: "35% 35%",
scrub:true,
markers:false
}});
tl3.to("#fanta", {
top:"218%",
left:"30%",
width:"40%",
// rotation: 360,
ease: "linear",
duration: 2,
}, 'secondSection')
tl3.to("#orange2", {
top:"207%",
left:"40%",
width:"20%",
zIndex:"3",
// rotation: 180,
duration: 2,
}, 'secondSection')
// splitType with lenis
gsap.registerPlugin(ScrollTrigger)
const splitTypes = document.querySelectorAll('.reveal-type')
splitTypes.forEach((char,i) => {
const bg = char.dataset.bgColor
const fg = char.dataset.fgColor
const text = new SplitType(char, { types: 'chars'})
gsap.fromTo(text.chars,
{
color: bg,
},
{
color: fg,
duration: 0.6,
stagger: 0.9,
scrollTrigger: {
trigger: char,
start: '5% 80%',
end: '85% 20%',
scrub: true,
markers: false,
toggleActions: 'play play reverse reverse'
}
})
})
const lenis = new Lenis()
lenis.on('scroll', (e) => {
console.log(e)
})
function raf(time) {
lenis.raf(time)
requestAnimationFrame(raf)
}
requestAnimationFrame(raf)