-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
323 lines (260 loc) · 6.49 KB
/
app.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/////////////////////// ME FALLING ~~ animated /////////////////////
//bezier object
const fallPath = {
//amount of curviness
curviness: 0.255,
// autoRotate: true,
//array of the points (objects) we want to animate to (x left,y)
//create a tween and animate along this path
//negative y is top, positive is down
values: [
{x:0, y: 0},
{x:-10, y: 100},
{x:-20, y: 150},
{x:-10, y: 200},
{x:0, y: 250},
// {x:10, y: 350},
// {x:20, y: 400},
// {x:10, y: 450},
// {x:0, y: 450},
]
};
//create a tween and animate along this path
const tween = new TimelineLite();
tween.add(
TweenLite.to(".me", 1 , {
//animate with bezier plugin
bezier: fallPath,
ease: Power1.easeInOut
})
);
//here is a trigger ScrollMagic scene for multiple elements..
// how to make this ^ affected by scrolling (ScrollMagic gsap plugin)
const controller = new ScrollMagic.Controller();
const scene = new ScrollMagic.Scene({
triggerElement: '.animation',
duration: 5000,
offset: 200,
//when it reaches the end of the animation section, triggers
triggerHook: 0
} )
.setTween(tween)
// .addIndicators()
//stuck here
.setPin('.animation',400)
.addTo(controller);
// IN THE FUTURE, should maybe use .each function to
// loop thruogh each scene and create a new ScrollMagic scene for each one
/////////////////////// Trees /////////////////////
const tree1Path = {
curviness: 0.255,
values: [
{x:0, y: 0},
{x:100, y: 0},
]
};
const tween1 = new TimelineLite();
tween1.add(
TweenLite.to(".trees1", 1 , {
bezier: tree1Path,
ease: Power1.easeInOut
})
);
const controller1 = new ScrollMagic.Controller();
const scene1 = new ScrollMagic.Scene({
triggerElement: '.animation',
duration: 5000,
offset: 200,
triggerHook: 0
} )
.setTween(tween1)
.addTo(controller1);
/////////////////////// Trees 2 /////////////////////
const tree2Path = {
curviness: 0.255,
values: [
{x:0, y: 0},
{x:-100, y: 0},
]
};
const tween2 = new TimelineLite();
tween2.add(
TweenLite.to(".trees2", 1 , {
bezier: tree2Path,
ease: Power1.easeInOut
})
);
const controller2 = new ScrollMagic.Controller();
const scene2 = new ScrollMagic.Scene({
triggerElement: '.animation',
duration: 5000,
offset: 200,
triggerHook: 0
} )
.setTween(tween2)
.addTo(controller2);
/////////////////////// Trees 3 /////////////////////
const tree3Path = {
curviness: 0.255,
values: [
{x:800, y: 50},
{x:850, y: 100},
]
};
const tween3 = new TimelineLite();
tween3.add(
TweenLite.to(".trees3", 1 , {
bezier: tree3Path,
ease: Power1.easeInOut
})
);
const controller3 = new ScrollMagic.Controller();
const scene3 = new ScrollMagic.Scene({
triggerElement: '.animation',
duration: 5000,
offset: 200,
triggerHook: 0
} )
.setTween(tween3)
.addTo(controller3);
/////////////////////// Trees 4 /////////////////////
const tree4Path = {
curviness: 0.255,
values: [
{x:-800, y: 50},
{x:-700, y: 100},
]
};
const tween4 = new TimelineLite();
tween4.add(
TweenLite.to(".trees4", 1 , {
bezier: tree4Path,
ease: Power1.easeInOut
})
);
const controller4 = new ScrollMagic.Controller();
const scene4 = new ScrollMagic.Scene({
triggerElement: '.animation',
duration: 5000,
offset: 200,
triggerHook: 0
} )
.setTween(tween4)
.addTo(controller4);
////////////////// me again ////////////////////////
const fallPath2 = {
curviness: 0.255,
values: [
{x:0, y: 0},
{x:-10, y: 100},
{x:-20, y: 150},
{x:-10, y: 200},
{x:0, y: 250},
{x:-10, y: 200},
{x:-20, y: 150},
]
};
const tweenfallPath2 = new TimelineLite();
tweenfallPath2.add(
TweenLite.to(".me2", 1 , {
//animate with bezier plugin
bezier: fallPath2,
ease: Power1.easeInOut
})
);
const controllerfallPath2 = new ScrollMagic.Controller();
const scenefallPath2 = new ScrollMagic.Scene({
triggerElement: '.animation1',
duration: 5000,
offset: 200,
//when it reaches the end of the animation section, triggers
triggerHook: 0
} )
.setTween(tweenfallPath2)
// .addIndicators()
//stuck here
.setPin('.animation1',400)
.addTo(controllerfallPath2);
/////////////////////// fish /////////////////////
const fishPath = {
autoRotate: true,
curviness: 0.5,
values: [
{x:0, y: 0},
{x:500, y: 200},
{x:1000, y: 150},
]
};
const tweenfishPath = new TimelineLite();
tweenfishPath.add(
TweenLite.to(".fish", 3 , {
bezier: fishPath,
ease: Power1.easeInOut
})
);
const controllerfishPath = new ScrollMagic.Controller();
const scenefishPath = new ScrollMagic.Scene({
triggerElement: '.animation1',
duration: -5000,
offset: 300,
triggerHook: 0
} )
.setTween(tweenfishPath)
.addTo(controllerfishPath);
/////////////////////// fish2 /////////////////////
const fish2Path = {
autoRotate: true,
curviness: 0.55,
values: [
{x:0, y: 0},
{x:500, y: 200},
{x:3000, y: 250},
]
};
const tweenfish2Path = new TimelineLite();
tweenfish2Path.add(
TweenLite.to(".fish2", 3 , {
bezier: fish2Path,
ease: Power1.easeInOut
})
);
const controllerfish2Path = new ScrollMagic.Controller();
const scenefish2Path = new ScrollMagic.Scene({
triggerElement: '.animation1',
duration: -5000,
offset: 200,
triggerHook: 0
} )
.setTween(tweenfish2Path)
.addTo(controllerfish2Path);
////////////////// me again third section ////////////////////////
const sleepPath = {
curviness: 0.255,
values: [
{x:0, y: 0},
{x:-10, y: 100},
{x:-20, y: 150},
{x:-10, y: 200},
]
};
const tweensleepPath = new TimelineLite();
tweensleepPath.add(
TweenLite.to(".me3", 1 , {
//animate with bezier plugin
bezier: sleepPath,
ease: Power1.easeInOut
})
);
const controllersleepPath = new ScrollMagic.Controller();
const scenesleepPath = new ScrollMagic.Scene({
triggerElement: '.animation2',
duration: 5000,
offset: 200,
//when it reaches the end of the animation section, triggers
triggerHook: 0
} )
.setTween(tweensleepPath)
// .addIndicators()
//stuck here
.setPin('.animation2',400)
.addTo(controllersleepPath);