-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollMagicDemo2.html
More file actions
334 lines (300 loc) · 10.3 KB
/
ScrollMagicDemo2.html
File metadata and controls
334 lines (300 loc) · 10.3 KB
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
324
325
326
327
328
329
330
331
332
333
334
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ScrollMagic Showcase!</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TimelineMax.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/animation.gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/jquery.ScrollMagic.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css?family=Montserrat|Raleway:500');
HTML, BODY {
height: 100%;
margin: 0;
font-family: 'Montserrat', Arial, sans-serif;
color: #1A1313;
vertical-align:middle;
}
H1 {
display: block;
color: #ffffff;
font-size: 50px;
font-weight: normal;
text-align: center;
padding: 20px;
margin: 0 auto;
}
.debugBox {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 1px dashed rgba(255,255,255,0.75);
}
.fullSize {
height: 100%;
width: 100%;
}
.tealBkgd {
background-color: teal;
}
.redBkgd {
background-color: red;
}
.blueBkgd1 {
background-color: aliceblue;
}
.blueBkgd2 {
background-color: skyblue;
}
.blueBkgd3 {
background-color: deepskyblue;
}
.blueBkgd4 {
background-color: dodgerblue;
}
.whiteText {
color: white;
}
.blackText {
color: black;
}
.spacer150 {
height: 150px;
}
.triggerDiv {
height: 1px;
}
.introHeader {
text-align:center;
color: #FFFFFF;
}
.introTextContainer {
display: table;
height: 200px;
width: 400px;
margin: auto;
text-align: center;
vertical-align: middle;
}
.introText {
display: inline-table;
background-color: white;
padding: 15px;
font-family: 'Raleway', sans-serif;
font-size: 32px;
letter-spacing:5px;
margin: 20px;
}
.introText.box1 {
opacity: 1;
transform: rotateZ(-20deg);
-webkit-transform: rotateZ(-20deg);
-ms-transform: rotateZ(-20deg);
margin-right: 20px;
}
.introText.box2 {
opacity: 1;
transform: rotateZ(10deg);
-webkit-transform: rotateZ(10deg);
-ms-transform: rotateZ(10deg);
}
.introText.box3 {
opacity: 1;
transform: rotateZ(5deg);
-webkit-transform: rotateZ(5deg);
-ms-transform: rotateZ(5deg);
margin-top:10px;
}
.demo01TextA {
display: block;
position: relative;
left: 0px;
width: 350px;
margin: 0 0 10px;
padding:10px;
background-color: #ff8888;
font-size:30px;
}
.demo01TextB {
display: block;
position: relative;
right: -100%;
width: 350px;
margin: 0 0 10px;
padding:10px;
background-color: #BB0000;
font-size:30px;
color: #ffffff;
text-align: right;
}
.demo01TextC {
display: block;
opacity: 1;
margin: 0 auto;
padding: 10px;
width: 550px;
height: 200px;
background: #ffd828;
color: #ff0000;
font-size: 60px;
text-transform: uppercase;
text-align: center;
vertical-align: middle;
line-height: 200px;
}
.demo02Size {
height: 500px;
text-align: center;
}
.demo02Text span {
font-size: 50px;
width: 100%;
height: 100%;
line-height: 500px;
}
</style>
</head>
<body>
<!-- ================================================================
= The introduction to the demo animates "Let's get started!" with the
= mouse scroll before the screen moves onto the first demo
================================================================= -->
<section id="demoIntro" class="fullSize">
<div class="fullSize tealBkgd">
<div class="spacer150"> </div>
<div class="introHeader">
<p>This is a ScrollMagic demo, created by Marc Concepcion.</p>
<p>Scroll down with the mouse to begin.</p>
</div>
<div class="introTextContainer">
<div class="introText box1">Let's</div>
<div class="introText box2">get</div>
<div class="introText box3">started!</div>
</div>
<div id="textATrigger" class="triggerDiv"></div>
</div>
</section>
<!-- ================================================================
= The first demo shows a simple "trigger" behavior, where a preset
= animation runs when the target div passes the trigger.
================================================================= -->
<section id="demo01">
<div id="demo01Content" class="redBkgd" style="overflow-x: hidden;">
<div id="textBTrigger" class="triggerDiv"></div>
<h1>Demo #01:</h1>
<div style="height:200px;"></div>
<div id="slidingLeft1" class="demo01TextA">Let's just start</div>
<div id="slidingLeft2" class="demo01TextA">with something</div>
<div id="slidingLeft3" class="demo01TextA">simple.</div>
<div id="textCTrigger" class="triggerDiv"></div>
<div style="height:100px;"></div>
<div id="slidingRght1" class="demo01TextB">Text slides in</div>
<div id="slidingRght2" class="demo01TextB">from both sides</div>
<div id="slidingRght3" class="demo01TextB">of the screen</div>
<div style="height:100px;"></div>
<div id="growing" class="demo01TextC">With triggers.</div>
<div style="height:500px;"></div>
</div>
</section>
<!-- ================================================================
= The second animation shows a simple div pinning sequence of four
= divs.
= TO DO: Set the duration of the setPin animation to the height of
= the div.
================================================================= -->
<section id="demo02">
<div id="demo02Content" class="fullSize">
<div id="pinTrigger1" class="triggerDiv"></div>
<div id="demo02Pin1" class="demo02Size blueBkgd1 demo02Text blackText">
<span>Demo #02:</span>
</div>
<div id="pinTrigger2" class="triggerDiv"></div>
<div id="demo02Pin2" class="demo02Size blueBkgd2 demo02Text blackText">
<span>Fun</span>
</div>
<div id="pinTrigger3" class="triggerDiv"></div>
<div id="demo02Pin3" class="demo02Size blueBkgd3 demo02Text whiteText">
<span>With</span>
</div>
<div id="pinTrigger4" class="triggerDiv"></div>
<div id="demo02Pin4" class="demo02Size blueBkgd4 demo02Text whiteText">
<span>DIV PINS!</span>
</div>
</div>
</section>
<section id="demo03" class="fullSize">
<div id="demo03Content" class="tealBkgd" style="height: 3000px;">Bump!</div>
</section>
<script>
$(function() {
var currWinSize = $( window ).height();
var demo01ContentHeight = $( "#demo01Content" ).height();
var demoController = new ScrollMagic.Controller({
globalSceneOptions: {
triggerHook: 'onLeave' // I know it can be '0', but I like the semantics :)
}
});
/* The first div needs to stay put while the intro animates. */
new ScrollMagic.Scene({
duration: currWinSize + 100
})
.setPin("section#demoIntro")
.addTo(demoController);
/* "Let's Get Started" intro animation */
new ScrollMagic.Scene({ duration: $(window).height() })
.setTween( TweenMax.staggerFrom( [$( ".box1" ), $( ".box2" ), $( ".box3" )], 1, {y:"+=150", rotation:"+=360", opacity:0}, 0.5 ) )
.addIndicators({name: "introText Anim"})
.addTo(demoController);
/* Demo #1 - Text Group A animation (left side) */
new ScrollMagic.Scene({ triggerElement: "#textATrigger" })
.setTween( TweenMax.staggerFrom( [ $( "#slidingLeft1" ), $( "#slidingLeft2" ), $( "#slidingLeft3" ) ], 0.5, {x:"-=370"}, 0.2 ) )
.addIndicators({name: "Text Group A"})
.addTo(demoController);
/* Demo #1 - Text Group B animation (right side) */
new ScrollMagic.Scene({ triggerElement: "#textBTrigger" })
.setTween( TweenMax.staggerTo( [ $( "#slidingRght1" ), $( "#slidingRght2" ), $( "#slidingRght3" ) ], 0.5, {x:"-=370"}, 0.2 ) )
.addIndicators({name: "Text Group B"})
.addTo(demoController);
/* Demo #1 - Bottom text box animation */
new ScrollMagic.Scene({ triggerElement: "#textCTrigger" })
.setTween( TweenMax.from( $( "#growing" ), 0.5, {scaleX:0.5, scaleY:0.5, opacity:0} ) )
.addIndicators({name: "Text Group C"})
.addTo(demoController);
/* Demo #2 - Pinned Div 1 */
new ScrollMagic.Scene({
triggerElement: "#pinTrigger1"
})
.setPin( "#demo02Pin1" )
.addIndicators({name: "Demo #2 Pin 1"})
.addTo(demoController);
/* Demo #2 - Pinned Div 2 */
new ScrollMagic.Scene({
triggerElement: "#pinTrigger2"
})
.setPin( "#demo02Pin2" )
.addIndicators({name: "Demo #2 Pin 2"})
.addTo(demoController);
/* Demo #2 - Pinned Div 3 */
new ScrollMagic.Scene({
triggerElement: "#pinTrigger3"
})
.setPin( "#demo02Pin3" )
.addIndicators({name: "Demo #2 Pin 3"})
.addTo(demoController);
/* Demo #2 - Pinned Div 4 */
new ScrollMagic.Scene({
triggerElement: "#pinTrigger4"
})
.setPin( "#demo02Pin4" )
.addIndicators({name: "Demo #2 Pin 4"})
.addTo(demoController);
});
</script>
</body>
</html>