-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
265 lines (223 loc) · 4.3 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
ScrollTrigger.normalizeScroll(true);
ScrollTrigger.defaults({ ignoreMobileResize: true });
gsap.registerPlugin(ScrollTrigger);
const locoScroll = new LocomotiveScroll({
el: document.querySelector("#main"),
smooth: true,
smoothMobile: 0.1,
});
locoScroll.on("scroll", ScrollTrigger.update);
ScrollTrigger.scrollerProxy("#main", {
scrollTop(value) {
return arguments.length ? locoScroll.scrollTo(value, 0, 0) : locoScroll.scroll.instance.scroll.y;
},
getBoundingClientRect() {
return { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight };
},
pinType: document.querySelector("#main").style.transform ? "transform" : "fixed",
});
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
ScrollTrigger.refresh();
function page1(){
const t1=gsap.timeline();
t1.from('#txt1 h1',{
y:100,
opacity:0,
duration:0.5,
})
t1.from('#txt2 h1',{
y:100,
opacity:0,
duration:0.5,
})
t1.from('#txt3 h1',{
y:100,
opacity:0,
duration:0.5,
})
t1.from('#txt3',{
width:'0%',
})
t1.from('#img1',{
x:-500,
})
t1.from('#img2',{
y:-500,
})
t1.from('#img3',{
x:500,
})
t1.from('#img4',{
y:500,
})
}
page1();
function page2(){
const t1=gsap.timeline();
const media = window.matchMedia('(max-width: 600px)');
gsap.to('#page2',{
scrollTrigger:{
trigger:'#page2',
scroller:'#main',
pin:true,
}
})
t1.to('#page2 #text',{
x:-200,
duration:3,
scrollTrigger:{
trigger:'#text h1',
scroller:'#main',
scrub:2,
}
})
if(media.matches){
gsap.to('#card1',{
height:'35%',
duration:2,
scrollTrigger:{
trigger:'#card1',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
gsap.to('#card2',{
height:'30%',
duration:2,
scrollTrigger:{
trigger:'#card2',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
gsap.to('#card3',{
height:'35%',
duration:2,
scrollTrigger:{
trigger:'#card3',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
}
else{
gsap.to('#card1',{
height:'70%',
duration:2,
scrollTrigger:{
trigger:'#card1',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
gsap.to('#card2',{
height:'70%',
duration:2,
scrollTrigger:{
trigger:'#card2',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
gsap.to('#card3',{
height:'70%',
duration:2,
scrollTrigger:{
trigger:'#card3',
scroller:'#main',
start:'top 60%',
scrub:2,
}
})
}
}
page2();
function page3() {
}
function page3(){
const t1=gsap.timeline();
t1.to('#page3',{
scrollTrigger:{
trigger:'#page3',
scroller:'#main',
pin:true,
scrub:2,
}
})
t1.to('.item',{
duration:10,
transform:'translate(-300%)',
scrollTrigger:{
trigger:'.item',
scroller:'#main',
scrub:5,
start:'top 0%',
end:'top -100%'
}
})
}
page3();
function page4(){
const t1=gsap.timeline();
const media = window.matchMedia('(max-width: 600px)');
if(media.matches){
t1.to('#page4',{
scrollTrigger:{
trigger:'#page4',
scroller:'#main',
pin:true,
}
})
t1.to('#page4 h1',{
duration:3,
scale:2,
opacity:0,
scrollTrigger:{
trigger:'#page4 h1',
scroller:'#main',
start:'top 0',
scrub:2,
}
})
}
else{
t1.to('#page4',{
scrollTrigger:{
trigger:'#page4',
scroller:'#main',
pin:true,
}
})
t1.to('#page4 h1',{
duration:3,
scale:2,
opacity:0,
width:0,
scrollTrigger:{
trigger:'#page4 h1',
scroller:'#main',
start:'top 0',
scrub:2,
}
})
}
}
page4();
function page5(){
const t1=gsap.timeline();
t1.to('#page5 #text',{
x:-200,
duration:3,
scrollTrigger:{
trigger:'#page5 h1',
scroller:'#main',
scrub:2,
}
})
}
page5();