-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
677 lines (591 loc) · 28.7 KB
/
index.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
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
<!DOCTYPE html>
<html>
<head>
<title>Taking Off with CSS and SVG Animation!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/white-customized.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- - - - - - - - - - - MAJOR SECTION SEPARATOR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!--
<section>
<ul>
<li>Intro – why we did this??</li>
<li>HTML / CSS and the SVG icon (straightforward)</li>
<li>SVG – why it's cool, what it is?</li>
<li>Bezier curve – control points on our line</li>
<li>Penner's equations and easing functions – what's this about?</li>
<li>JavaScript - requestAnimationFrame maybe?</li>
<li>Events for user interaction – scroll (this updates our SVG)</li>
<li>Motion blur with SVG</li>
<li>Final code / working versions in CodePen?</li>
</ul>
</section>
-->
<section>
<h1 style="font-size:1.6em">Taking off with CSS and SVG animation!</h1>
<p><a href="https://dribbble.com/shots/2101933-GIF-for-Pull-Down-Space-Ship">
<img class="noborder nomargin" width="60%" src="images/orig-spaceship.gif">
</a></p>
<h2 class="subhead">
How to create this awesome <a href="https://dribbble.com/shots/2101933-GIF-for-Pull-Down-Space-Ship">space ship animation</a> by Toma Reznichenko
</h2>
<!--
<h3 class="subhead" style="font-size:0.76em;">By Liz Krane and Jim Thoburn</h3>
-->
</section>
<section>
<a href="https://dribbble.com/shots/2101933-GIF-for-Pull-Down-Space-Ship">
<img class="noborder" width="600" src="images/slowmo-spaceship.gif">
</a>
<p>The original animation was created in After Effects.</p>
</section>
<section>
<h2>Steps</h2>
<ol>
<li>Create the page elements with HTML and CSS.</li>
<li>Draw the graphics with SVG.</li>
<li>Make life-like animation with Penner’s easing equations.</li>
<li>Add a motion blur.</li>
<li>Let the user control the animation by scrolling.</li>
</ol>
</section>
<section>
<h2>Create the page elements</h2>
<div class="halves">
<pre style="margin:0; width:96%;"><code style="height: 500px; box-sizing: border-box;" class="smaller" data-trim contenteditable="">
<header>…</header>
<div class="refresh">
<svg viewbox="0 0 180 160">
<!-- Path data for the launch pad -->
</svg>
<svg viewBox="0 0 17.3 26.6">
<!-- Path data for the space ship -->
</svg>
</div>
<ul>
<li>…</li>
<li>…</li>
<li>…</li>
<li>…</li>
<li>…</li>
<li>…</li>
</ul>
</code></pre>
</div>
<div class="halves">
<iframe class="halves" style="height: 500px;" src="spaceship/step1.html"></iframe>
</div>
</section>
<section>
<h2 style="font-size:4em;">SVG</h2>
<h3>Scalable Vector Graphics for the web!</h3>
<ul>
<li>SVG images look beautiful at any size or pixel density.</li>
<li>An SVG image is just a text file.</li>
<li>The language looks a lot like HTML.</li>
<li>You can create an SVG by hand or with a tool like <a href="https://www.sketchapp.com">Sketch</a> or <a href="http://www.adobe.com/products/illustrator.html">Illustrator</a>.</li>
<li>They can be loaded from a separate file or embedded in an HTML document.</li>
<li>You can style them with CSS and script them with JavaScript.</li>
</ul>
</section>
<section>
<h2>Draw your space ship</h2>
<p style="margin-bottom:0;">Here’s one by <a href="https://thenounproject.com/search/?q=space+ship&i=243332">Guilherme Simoes from the Noun Project</a></p>
<div class="halves">
<pre><code class="smaller" data-trim contenteditable="">
<svg viewBox="0 0 17.3 26.6">
<style>
.ship-outline {
fill: rgba(0, 0, 0, 0.25);
}
.ship-panels {
fill: rgb(169, 206, 203);
}
.ship-fins {
fill: rgb(224, 71, 71);
}
.ship-window {
fill: rgb(220, 235, 234);
}
</style>
<path class="ship-outline" fill="black" d="M17.3,24.6c0,0.2-0.1,0.5-0.2,0.6c-0.1,0.1-0.2,0.1-0.3,0.2c-0.3,0.1-0.7,0.1-1-0.2
c-0.9-0.9-2.3-2.1-3.2-2.5c-0.7,0.4-1.5,0.7-2.5,0.9l0,1.8c0,0.3-0.1,0.6-0.4,0.9c-0.2,0.2-0.6,0.4-0.9,0.4H8.5
c-0.3,0-0.7-0.1-0.9-0.4c-0.2-0.2-0.4-0.6-0.4-0.9v-1.8c-1-0.1-1.9-0.5-2.5-0.9c-0.9,0.4-2.3,1.6-3.3,2.5c-0.3,0.2-0.6,0.3-1,0.2
C0.2,25.2,0,24.9,0,24.5c0.3-4.5,2.3-7,3-7.7c-0.2-1-0.3-2.2-0.3-3.3C2.4,7.2,4.4,2.6,8.5,0.1L8.7,0L9,0.2c4,2.4,6,7.1,5.7,13.4
c-0.1,1.2-0.2,2.3-0.4,3.3C15,17.6,17,20.1,17.3,24.6z M16.3,24.3c-0.2-3.1-1.4-5.1-2.2-6.1c-0.3,1.7-0.7,3.1-1,3.7
C14.2,22.4,15.4,23.5,16.3,24.3z M12.7,19.7c0.9-3.5,2-10.3-0.8-15.2C10.9,4.8,9.8,5,8.7,5C7.6,5,6.5,4.8,5.5,4.5
C2.7,9.3,3.7,16,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.1c-0.5,0.4-1.2,0.6-2.1,0.7v-1.3C10.9,21.2,11.7,21,12.4,20.8z"/>
<path class="ship-panels" fill="#ccc" d="M7.3,21.2l0,1.3c-0.8-0.1-1.5-0.4-2-0.8c-0.1-0.2-0.2-0.6-0.3-1.1C5.6,20.9,6.4,21.1,7.3,21.2z"/>
<path class="ship-panels" fill="#ccc" d="M11.9,4.5c2.8,4.8,1.7,11.7,0.8,15.2l0-0.1c-0.8,0.3-1.7,0.5-2.6,0.6l0-2.5c0-0.3-0.1-0.6-0.4-0.9
c-0.2-0.2-0.5-0.4-0.9-0.4H8.5c-0.7,0-1.2,0.6-1.3,1.2l0,2.5c-1-0.1-2-0.4-2.7-0.7C3.7,16,2.7,9.3,5.5,4.5C6.5,4.8,7.6,5,8.7,5
C9.8,5,10.9,4.8,11.9,4.5z M12.3,9.8c0-0.9-0.4-1.9-1-2.5S9.7,6.2,8.7,6.2c-1.9,0-3.6,1.7-3.6,3.6c0,1,0.4,1.9,1,2.5
s1.6,1.1,2.5,1.1c1,0,1.9-0.4,2.5-1C11.9,11.7,12.3,10.8,12.3,9.8z"/>
<path class="ship-panels" fill="#ccc" d="M11.4,3.7C10.5,3.9,9.6,4,8.7,4C7.8,4,6.9,3.9,6.1,3.6c0.7-0.9,1.6-1.8,2.6-2.5C9.8,1.9,10.7,2.7,11.4,3.7z"
/>
<path class="ship-fins" fill="#333" d="M9.1,17.7l0,7.6c0,0.1-0.1,0.2-0.2,0.2H8.5c-0.1,0-0.2-0.1-0.2-0.2l0-7.6c0-0.1,0-0.1,0.1-0.2
c0,0,0.1-0.1,0.2-0.1h0.3C9,17.5,9.1,17.6,9.1,17.7z"/>
<path class="ship-fins" fill="#333" d="M3.2,18.1c0.3,1.7,0.7,3.1,0.9,3.7c-1,0.5-2.3,1.6-3.2,2.4C1.3,21.1,2.5,19.1,3.2,18.1z"/>
<path class="ship-fins" fill="#333" d="M14.1,18.2c0.8,1,1.9,3,2.2,6.1c-0.8-0.8-2.1-1.8-3.1-2.4C13.4,21.2,13.8,19.9,14.1,18.2z"/>
<path class="ship-window" fill="white" d="M10.5,8c0.5,0.5,0.8,1.1,0.8,1.8c0,1.4-1.2,2.6-2.6,2.6c-0.7,0-1.3-0.3-1.8-0.8s-0.8-1.1-0.8-1.8
c0-0.7,0.3-1.3,0.8-1.8S8,7.2,8.7,7.2C9.4,7.2,10.1,7.5,10.5,8z"/>
</svg>
</code></pre>
</div>
<div class="halves" style="margin-top:60px;">
<svg class="shapeship prelaunch-animation" id="spaceship" xmlns="http://www.w3.org/2000/svg" width="260" height="400" viewBox="0 0 17.3 26.6">
<!--
Created by Guilherme Simoes
from the Noun Project
https://thenounproject.com/search/?q=space+ship&i=243332
-->
<style>
.ship-outline {
fill: rgb(71, 79, 105);
}
.ship-panels {
fill: rgb(169, 206, 203);
}
.ship-fins {
fill: rgb(224, 71, 71);
}
.ship-window {
fill: rgb(220, 235, 234);
}
</style>
<g id="spaceship-group">
<path class="ship-outline" fill="black" d="M17.3,24.6c0,0.2-0.1,0.5-0.2,0.6c-0.1,0.1-0.2,0.1-0.3,0.2c-0.3,0.1-0.7,0.1-1-0.2
c-0.9-0.9-2.3-2.1-3.2-2.5c-0.7,0.4-1.5,0.7-2.5,0.9l0,1.8c0,0.3-0.1,0.6-0.4,0.9c-0.2,0.2-0.6,0.4-0.9,0.4H8.5
c-0.3,0-0.7-0.1-0.9-0.4c-0.2-0.2-0.4-0.6-0.4-0.9v-1.8c-1-0.1-1.9-0.5-2.5-0.9c-0.9,0.4-2.3,1.6-3.3,2.5c-0.3,0.2-0.6,0.3-1,0.2
C0.2,25.2,0,24.9,0,24.5c0.3-4.5,2.3-7,3-7.7c-0.2-1-0.3-2.2-0.3-3.3C2.4,7.2,4.4,2.6,8.5,0.1L8.7,0L9,0.2c4,2.4,6,7.1,5.7,13.4
c-0.1,1.2-0.2,2.3-0.4,3.3C15,17.6,17,20.1,17.3,24.6z M16.3,24.3c-0.2-3.1-1.4-5.1-2.2-6.1c-0.3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.1,9.1,6.1,9.8c0,0.7,0.3,1.4,0.8,1.8s1.1,0.8,1.8,0.8C10.1,12.4,11.3,11.2,11.3,9.8z"/>
<path class="ship-panels" fill="#ccc" d="M12.4,20.8c-0.1,0.5-0.3,0.9-0.3,1.1c-0.5,0.4-1.2,0.6-2.1,0.7v-1.3C10.9,21.2,11.7,21,12.4,20.8z"/>
<path class="ship-panels" fill="#ccc" d="M7.3,21.2l0,1.3c-0.8-0.1-1.5-0.4-2-0.8c-0.1-0.2-0.2-0.6-0.3-1.1C5.6,20.9,6.4,21.1,7.3,21.2z"/>
<path class="ship-panels" fill="#ccc" d="M11.9,4.5c2.8,4.8,1.7,11.7,0.8,15.2l0-0.1c-0.8,0.3-1.7,0.5-2.6,0.6l0-2.5c0-0.3-0.1-0.6-0.4-0.9
c-0.2-0.2-0.5-0.4-0.9-0.4H8.5c-0.7,0-1.2,0.6-1.3,1.2l0,2.5c-1-0.1-2-0.4-2.7-0.7C3.7,16,2.7,9.3,5.5,4.5C6.5,4.8,7.6,5,8.7,5
C9.8,5,10.9,4.8,11.9,4.5z M12.3,9.8c0-0.9-0.4-1.9-1-2.5S9.7,6.2,8.7,6.2c-1.9,0-3.6,1.7-3.6,3.6c0,1,0.4,1.9,1,2.5
s1.6,1.1,2.5,1.1c1,0,1.9-0.4,2.5-1C11.9,11.7,12.3,10.8,12.3,9.8z"/>
<path class="ship-panels" fill="#ccc" d="M11.4,3.7C10.5,3.9,9.6,4,8.7,4C7.8,4,6.9,3.9,6.1,3.6c0.7-0.9,1.6-1.8,2.6-2.5C9.8,1.9,10.7,2.7,11.4,3.7z"
/>
<path class="ship-fins" fill="#333" d="M9.1,17.7l0,7.6c0,0.1-0.1,0.2-0.2,0.2H8.5c-0.1,0-0.2-0.1-0.2-0.2l0-7.6c0-0.1,0-0.1,0.1-0.2
c0,0,0.1-0.1,0.2-0.1h0.3C9,17.5,9.1,17.6,9.1,17.7z"/>
<path class="ship-fins" fill="#333" d="M3.2,18.1c0.3,1.7,0.7,3.1,0.9,3.7c-1,0.5-2.3,1.6-3.2,2.4C1.3,21.1,2.5,19.1,3.2,18.1z"/>
<path class="ship-fins" fill="#333" d="M14.1,18.2c0.8,1,1.9,3,2.2,6.1c-0.8-0.8-2.1-1.8-3.1-2.4C13.4,21.2,13.8,19.9,14.1,18.2z"/>
<path class="ship-window" fill="white" d="M10.5,8c0.5,0.5,0.8,1.1,0.8,1.8c0,1.4-1.2,2.6-2.6,2.6c-0.7,0-1.3-0.3-1.8-0.8s-0.8-1.1-0.8-1.8
c0-0.7,0.3-1.3,0.8-1.8S8,7.2,8.7,7.2C9.4,7.2,10.1,7.5,10.5,8z"/>
</g>
</svg>
</div>
</section>
<section>
<h2>Draw your launch pad</h2>
<svg style="width: 100%" width="360" height="240" viewbox="0 0 120 80">
<path d="M 10 60 Q 60 80, 110 60" stroke="black" stroke-width="4" fill="transparent"></path>
</svg>
</section>
<section>
<h2>SVG <path> elements can be used to draw lines</h2>
<svg style="width: 100%" width="360" height="240" viewbox="0 0 120 80">
<path d="M 10 60, L 60 10, L 110 60" stroke="black" stroke-width="4" fill="transparent"></path>
</svg>
<pre><code data-trim contenteditable="">
<svg viewbox="0 0 120 120">
<path d="M 10 60, L 60 10, L 110 60"></path>
</svg>
</code></pre>
</section>
<section>
<h2>…and curves</h2>
<svg style="width: 100%" width="360" height="240" viewbox="0 0 120 80">
<path d="M 10 60, Q 60 10, 110 60" stroke="black" stroke-width="4" fill="transparent"></path>
</svg>
<pre><code data-trim contenteditable="">
<svg viewbox="0 0 120 120">
<path d="M 10 60, Q 60 10, 110 60"></path>
</svg>
</code></pre>
</section>
<section>
<h2 style="margin-top:2em; margin-bottom: 1.1em;">Curves are drawn between two points,<br />with a control point in between.</h2>
<svg width="400" height="400" viewbox="0 0 120 120" xmlns="http://www.w3.org/2000/svg">
<path d="M 10 60 Q 60 10, 110 60" stroke="black" fill="transparent"></path>
<path d="M 10 60 L 60 10 L 110 60" stroke="blue" fill="transparent"></path>
<circle fill="blue" cx="10" cy="60" r="5"></circle>
<circle fill="red" cx="60" cy="10" r="5"></circle>
<circle fill="blue" cx="110" cy="60" r="5"></circle>
</svg>
</section>
<section>
<h2 style="margin-top:1em; margin-bottom: 1.1em;width:98%;">As the control point moves, the curve moves with it.</h2>
<svg style="margin-top:-5em;" width="400" height="400" viewbox="0 0 120 120" xmlns="http://www.w3.org/2000/svg">
<path d="M 10 60 Q 60 110, 110 60" stroke="black" fill="transparent"></path>
<path d="M 10 60 L 60 110 L 110 60" stroke="blue" fill="transparent"></path>
<circle fill="blue" cx="10" cy="60" r="5"></circle>
<circle fill="red" cx="60" cy="110" r="5"></circle>
<circle fill="blue" cx="110" cy="60" r="5"></circle>
</svg>
</section>
<!--
<section>
<h2>Cubic bezier curves!! yayyy</h2>
</section>
<section>
<h2>Animating the line – linear</h2>
</section>
-->
<section>
<h2>Animating with easing functions</h2>
<!--
<p>Robert Pennner wrote these for ActionScript in Flash, but they work just as well in JavaScript.</p>
-->
<p><a href="http://robertpenner.com/easing/">http://robertpenner.com/easing/</a></p>
</section>
<section>
<h2>Objects in real life … almost never move at a constant speed.</h2>
<p>Easing functions specify the rate of change of a parameter over time.</p>
<p><a href="http://easings.net">http://easings.net</a></p>
</section>
<section>
<h2>Linear</h2>
<img src="images/easings/linear.png" width="500" alt="Linear" />
<pre><code class="js" data-trim contenteditable="">
function linear (t, b, c, d) {
return c * (t / d) + b;
}
</code></pre>
</section>
<section>
<h2>Ease In</h2>
<img src="images/easings/ease-in-quint.png" width="500" alt="Ease in Quint" />
<pre><code class="js" data-trim contenteditable="">
function easeInQuint (t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
}
</code></pre>
</section>
<section>
<h2>Ease Out Elastic</h2>
<img src="images/easings/ease-in-out-elastic.png" width="500" alt="Ease In Out Elastic" />
<pre style="margin-top:0;"><code class="smaller" data-trim contenteditable="">
function easeOutElastic (t, b, c, d) {
var s=1.70158;var p=0;var a=c;
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
if (a < Math.abs(c)) { a=c; var s=p/4; }
else var s = p/(2*Math.PI) * Math.asin (c/a);
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
}
</code></pre>
</section>
<section>
<h2>Easing functions visualized</h2>
<img src="images/easings.png" width="500" alt="Easings" />
<p><a href="http://easings.net">http://easings.net</a></p>
</section>
<!--
<p><a href="http://gsgd.co.uk/sandbox/jquery/easing/">http://gsgd.co.uk/sandbox/jquery/easing/</a></p>
-->
<!--
<p>@t is the current time (or position) of the tween. This can be seconds or frames, steps, seconds, ms, whatever – as long as the unit is the same as is used for the total time</p>
<p>@b is the beginning value of the property.</p>
<p>@c is the change between the beginning and destination value of the property.</p>
<p>@d is the total time of the tween.</p>
-->
<!--
<section>
<h3>jQuery easing functions (bounce)</h3>
<pre><code class="smaller" data-trim contenteditable="">
function easeInOutBounce (t, b, c, d) {
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
}
</code></pre>
<p><a href="http://gsgd.co.uk/sandbox/jquery/easing/">http://gsgd.co.uk/sandbox/jquery/easing/</a></p>
</section>
-->
<!--
<section>
<h3>maybe compare: linear vs ease </h3>
</section>
<section>
<h3>Animating the spaceship to move with the line</h3>
</section>
-->
<!--
<section>
<h3>Particles!! Yay Bubbles</h3>
<div class="halves">
<iframe class="halves" style="height: 500px;" src="spaceship/bubbles.html"></iframe>
</div>
<div class="halves">
<pre><code class="smaller" data-trim contenteditable="">
.bubble {
background: rgba(69, 111, 168, 0.9);
border-radius: 50%;
width: 1.5em;
height: 1.5em;
display: inline-block;
animation: float 1s both linear;
}
</code></pre>
</div>
</section>
-->
<section>
<h2>Make the animation interactive with browser events</h2>
</section>
<section>
<h2>Scroll-based animation</h2>
<img src="images/scroll.png" height="500" />
</section>
<section>
<h2 style="margin-bottom:1em;">Listening to scroll position</h2>
<pre><code data-trim contenteditable="">
window.addEventListener('scroll', function(e) {
var scrollY = getScrollY();
if (scrollY < refreshHeight) {
animateByScroll(scrollY);
}
});
</code></pre>
</section>
<section>
<h2 style="margin-bottom:1em;">Animating by scroll position</h2>
<pre><code style="font-size:0.8em;" data-trim contenteditable="">
function animateByScroll(scrollY) {
var progress = refreshHeight - scrollY;
var duration = refreshHeight;
var propertyStart = 80;
var propertyDestination = 130;
nextValue = Math.floor(easeInQuint(
progress,
propertyStart,
propertyDestination - propertyStart,
duration));
svg.setAttribute('d',
'M 0 80 V 0 H 180 V 80 M180 80 Q 95 ' + nextValue + ' 0 80');
}
</code></pre>
</section>
<section>
<h2>Add a motion blur</h2>
<div class="halves" style="width:60%;margin-top:10px;">
<pre style="width:100%;"><code style="font-size:0.8em;" data-trim contenteditable="">
<svg xmlns="http://www.w3.org/2000/svg"
version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur in="SourceGraphic"
stdDeviation="0,12" />
</filter>
</defs>
</svg>
<g filter="url(#blur)">
<!-- path data is in here -->
</g>
</code></pre>
</div>
<div class="halves" style="width:40%;margin-top:10px;">
<svg class="shapeship prelaunch-animation" id="spaceship" xmlns="http://www.w3.org/2000/svg" style="padding:20px;" width="260" height="400" viewBox="0 0 17.3 26.6">
<!--
Created by Guilherme Simoes
from the Noun Project
https://thenounproject.com/search/?q=space+ship&i=243332
-->
<defs>
<filter id="blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="0,1" />
</filter>
</defs>
<style>
.ship-outline {
fill: rgb(71, 79, 105);
}
.ship-panels {
fill: rgb(169, 206, 203);
}
.ship-fins {
fill: rgb(224, 71, 71);
}
.ship-window {
fill: rgb(220, 235, 234);
}
</style>
<g filter="url(#blur)" id="spaceship-group">
<path class="ship-outline" fill="black" d="M17.3,24.6c0,0.2-0.1,0.5-0.2,0.6c-0.1,0.1-0.2,0.1-0.3,0.2c-0.3,0.1-0.7,0.1-1-0.2
c-0.9-0.9-2.3-2.1-3.2-2.5c-0.7,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.8-0.1-1.7-0.3-2.4-0.5
c0.1,0.5,0.3,0.9,0.3,1.1C5.7,22.2,6.4,22.4,7.3,22.6z M4.2,21.9c-0.2-0.7-0.6-2-0.9-3.7c-0.8,1-1.9,3-2.2,6.1
C1.9,23.4,3.1,22.4,4.2,21.9z"/>
<path class="ship-outline" fill="black" d="M11.3,7.3c0.7,0.7,1.1,1.6,1,2.5c0,1-0.4,1.9-1.1,2.5c-0.7,0.7-1.6,1.1-2.5,1c-1,0-1.9-0.4-2.5-1.1
s-1.1-1.6-1-2.5c0-1.9,1.7-3.6,3.6-3.6C9.7,6.2,10.6,6.6,11.3,7.3z M11.3,9.8c0-0.7-0.3-1.3-0.8-1.8c-0.5-0.5-1.1-0.8-1.8-0.8
C8,7.2,7.4,7.5,6.9,8S6.1,9.1,6.1,9.8c0,0.7,0.3,1.4,0.8,1.8s1.1,0.8,1.8,0.8C10.1,12.4,11.3,11.2,11.3,9.8z"/>
<path class="ship-panels" fill="#ccc" d="M12.4,20.8c-0.1,0.5-0.3,0.9-0.3,1.1c-0.5,0.4-1.2,0.6-2.1,0.7v-1.3C10.9,21.2,11.7,21,12.4,20.8z"/>
<path class="ship-panels" fill="#ccc" d="M7.3,21.2l0,1.3c-0.8-0.1-1.5-0.4-2-0.8c-0.1-0.2-0.2-0.6-0.3-1.1C5.6,20.9,6.4,21.1,7.3,21.2z"/>
<path class="ship-panels" fill="#ccc" d="M11.9,4.5c2.8,4.8,1.7,11.7,0.8,15.2l0-0.1c-0.8,0.3-1.7,0.5-2.6,0.6l0-2.5c0-0.3-0.1-0.6-0.4-0.9
c-0.2-0.2-0.5-0.4-0.9-0.4H8.5c-0.7,0-1.2,0.6-1.3,1.2l0,2.5c-1-0.1-2-0.4-2.7-0.7C3.7,16,2.7,9.3,5.5,4.5C6.5,4.8,7.6,5,8.7,5
C9.8,5,10.9,4.8,11.9,4.5z M12.3,9.8c0-0.9-0.4-1.9-1-2.5S9.7,6.2,8.7,6.2c-1.9,0-3.6,1.7-3.6,3.6c0,1,0.4,1.9,1,2.5
s1.6,1.1,2.5,1.1c1,0,1.9-0.4,2.5-1C11.9,11.7,12.3,10.8,12.3,9.8z"/>
<path class="ship-panels" fill="#ccc" d="M11.4,3.7C10.5,3.9,9.6,4,8.7,4C7.8,4,6.9,3.9,6.1,3.6c0.7-0.9,1.6-1.8,2.6-2.5C9.8,1.9,10.7,2.7,11.4,3.7z"
/>
<path class="ship-fins" fill="#333" d="M9.1,17.7l0,7.6c0,0.1-0.1,0.2-0.2,0.2H8.5c-0.1,0-0.2-0.1-0.2-0.2l0-7.6c0-0.1,0-0.1,0.1-0.2
c0,0,0.1-0.1,0.2-0.1h0.3C9,17.5,9.1,17.6,9.1,17.7z"/>
<path class="ship-fins" fill="#333" d="M3.2,18.1c0.3,1.7,0.7,3.1,0.9,3.7c-1,0.5-2.3,1.6-3.2,2.4C1.3,21.1,2.5,19.1,3.2,18.1z"/>
<path class="ship-fins" fill="#333" d="M14.1,18.2c0.8,1,1.9,3,2.2,6.1c-0.8-0.8-2.1-1.8-3.1-2.4C13.4,21.2,13.8,19.9,14.1,18.2z"/>
<path class="ship-window" fill="white" d="M10.5,8c0.5,0.5,0.8,1.1,0.8,1.8c0,1.4-1.2,2.6-2.6,2.6c-0.7,0-1.3-0.3-1.8-0.8s-0.8-1.1-0.8-1.8
c0-0.7,0.3-1.3,0.8-1.8S8,7.2,8.7,7.2C9.4,7.2,10.1,7.5,10.5,8z"/>
</g>
</svg>
</div>
<!--
<pre><code class="smaller" data-trim contenteditable="">
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="blur">
<feGaussianBlur in="SourceGraphic" stdDeviation="0,12" />
</filter>
</defs>
<g filter="url(#blur)">
<!-- path data is in here -->
</g>
</svg>
</code></pre>
-->
</section>
<section>
<h2>Putting it all together</h2>
<ul>
<li>Create your page with HTML, CSS and JavaScript.</li>
<li>
Use SVG to draw more complicated elements like curves,<br />
and to add effects like motion blur.
</li>
<li>Make life-like animation with Penner’s easing equations.</li>
<li>Listen for scroll events and use them as triggers for the animation.</li>
</ul>
</section>
<section>
<h2>Our Finished Code!</h2>
<p><a href="http://codepen.io/LearnToCodeLA/pen/WGAGbW">http://codepen.io/LearnToCodeLA/pen/WGAGbW</a></p>
<iframe class="noshadow noborder" height='600' scrolling='no' src='http://codepen.io/LearnToCodeLA/embed/WGAGbW/?height=500&theme-id=dark&default-tab=result&embed-version=2' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='http://codepen.io/LearnToCodeLA/pen/WGAGbW/'>WGAGbW</a> by Learn to Code LA (<a href='http://codepen.io/LearnToCodeLA'>@LearnToCodeLA</a>) on <a href='http://codepen.io'>CodePen</a>.</iframe>
</section>
<section>
<h2>Get these slides on GitHub</h2>
<p><a href="https://github.com/learntocodela/math-animation">https://github.com/learntocodela/math-animation</a></p>
</section>
<section>
<h1 style="margin-bottom: 60px;">Futher Reading</h1>
<h3>Understanding Easing</h3>
<p><a href="http://upshots.org/actionscript/jsas-understanding-easing">http://upshots.org/actionscript/jsas-understanding-easing</a></p>
<h3>SVG Paths</h3>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path">https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path</a></p>
</section>
<!-- COMMON ELEMENTS:
<h2 class="subhead"></h2>
<h2 class="big"></h2>
<p class="small">
SMALL font if lots of text
</p>
<p class="fragment highlight-current-blue">
FRAGMENTS - highlight one at a time, best to keep them all visible I think though!
</p>
<p>
INLINE CODE BELOW:
</p>
<pre><code contenteditable="">some inline code here</code></pre>
<pre><code class="smaller js" data-trim contenteditable="">
{big block of inline code here, and
REMEMBER TO KEEP IT ALL THE WAY TO THE LEFT!
*** AND REMEMBER TO INCLUDE A CLASS NAME TO SPECIFY WHICH LANGUAGE (how to highlight it)
</code></pre>
<img width="60%" src="">
<img class="noborder noshadow" src="">
<iframe style="margin-top: 50px; height: 300px;" src""></iframe>
<blockquote style="text-align:left; padding:20px;">
<p>
QUOTES ARE GREAT!
</p>
<p style="text-align:right;">
-- ATTRIBUTION!
</p>
</blockquote>
<p class="nomargin"><cite>
Small CITE text for image credits or footnotes
</cite></p>
<div class="fourths">
</div>
<div class="halves" style="width:35%">
</div>
<img class="halves noshadow noborder nomargin" style="width:65%" src="">
<ol start="5" class="listspaces">
<li>Numbered lists across multiple slides!</li>
<li>LISTSPACES class to add margin below list items</li>
</ol>
-->
</div><!-- END .slides -->
</div><!-- END .reveal -->
<footer class="branding">
<!--
<a class="button" href="#">Sample Code</a>
-->
<cite style="margin-left:0.5em;">By <a href="https://twitter.com/LearningNerd">Liz Krane</a> and <a href="https://twitter.com/jimthoburn">Jim Thoburn</a> for <a href="http://www.meetup.com/LearnToCodeLA/">Learn to Code LA</a></cite>
</footer>
<script src="lib/js/head.min.js"></script>
<script src="reveal.js"></script>
<script>
Reveal.initialize({
history: true,
transition: 'none',
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>