-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
635 lines (582 loc) · 20.4 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Yearofmoo AngularJS Animation Slides</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<link rel="stylesheet" href="css/overrides.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="clouds"></div>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>AngularJS Animations</h1>
<h3>By Matias Niemelä</h3>
<p>
<a href="http://bitly.com/yom-slides" class="em">bitly.com/yom-slides</a>
</p>
</section>
<section>
<h2 class="em">@yearofmoo</h2>
<div id="logo"></div>
<p>
<a class="em2" target="_blank" href="http://www.yearofmoo.com">http://www.yearofmoo.com</a>
</p>
<p>
Six major AngularJS articles.
</p>
<p>
Great resource to learn about <span class="em3">AngularJS</span> and <span class="em3">ngAnimate</span>.
</p>
<aside class="notes">
Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
</aside>
</section>
<section>
<section>
<h2 class="em">Animation & Webapps</h2>
<p class="fragment fade-in">
Animation code tends almost always gets mixed in together with application code and website logic.
</p>
<p class="fragment fade-in">
Not so simple way of disabling and changing animation properties during runtime
</p>
<p class="fragment fade-in">
Difficult to test & reuse animations
</p>
</section>
<section>
<h2 class="em">What about AngularJS?</h2>
<p class="fragment fade-in">
You'll fall into these same challenges when doing it yourself
</p>
<p class="fragment fade-in">
No way to hook into core operations inside your application.
</p>
<p class="fragment fade-in">
No way to isolate your code properly.
</p>
<p class="fragment fade-in">
No fair!
</p>
<p class="fragment fade-in em3">
ngAnimate solves this!
</p>
</section>
<section>
<h2 class="em">Non-Animated Demo</h2>
<div>
Here is an existing application that uses AngularJS, but without ngAnimate.
<a href="http://bitly.com/yom-w1" target="_blank" class="em">http://bitly.com/yom-w1</a>
</div>
<div>
<a href="http://bitly.com/yom-w1" target="_blank">
<div class="existing-example"></div>
</a>
</div>
</section>
</section>
<section>
<h2 class="em">ngAnimate</h2>
<p class="fragment fade-in">
The magical directive that signals other directives to perform animations.
</p>
<p class="fragment fade-in">
Supported in version <span class="em">1.1.5</span> of <span class="em">AngularJS</span>.
</p>
<p class="fragment fade-in">
Full support for <span class="em2">CSS3 Animations</span> & <span class="em2">Transitions</span>
</p>
<p class="fragment fade-in">
Also supports <span class="em3">JavaScript animations</span>
</p>
<p class="fragment fade-in">
Lets get started!
</p>
</section>
<section>
<section>
<h2 class="em">How to define animations</h2>
<p class="fragment fade-in">
Animations can be defined in CSS or in JavaScript (inside of your module code).
</p>
<p class="fragment fade-in">
<span class="em3">CSS-enabled</span> animations use two classes to signal the <span class="em">setup</span>
and the <span class="em">active</span> animation states.
</p>
<p class="fragment fade-in">
<span class="em3">JavaScript-enabled</span> animations use a <span class="em">setup</span> and a <span class="em">start</span>
callback.
</p>
</section>
<section>
<h2 class="em">CSS3 Transitions</h2>
<p class="fragment fade-in">
Two CSS classes required.
</p>
<div class="fragment fade-in">
<pre class="big-code"><code data-trim>
/* preparation CSS (from) */
.some-animation {
transition:0.5s linear all;
background:red;
}
/* animation CSS (to) */
.some-animation-active {
background:blue;
}
</code></pre>
</div>
</section>
<section>
<h2 class="em">CSS3 Animations</h2>
<p class="fragment fade-in">
Only CSS class required.
</p>
<div class="fragment fade-in">
<pre class="big-code"><code data-trim>
/* preparation CSS */
.some-animation {
animation:0.5s my_animation;
}
/* animation CSS (from & to) */
@keyframes my_animation {
from { background:blue; }
to { background:red; }
}
</code></pre>
</div>
</section>
<section>
<h2 class="em">JavaScript Animations</h2>
<p class="fragment fade-in">
Define it like a service
</p>
<div class="fragment fade-in">
<pre class="big-code"><code data-trim>
ngModule.animation('some-animation', function(inject) {
return {
setup : function(element) { //preparation (from)
element.css('background','blue');
},
start : function(element, done) { //animation (to)
element.animate({
'background':'#F00'
}, done);
},
cancel : function(element, done) {
cancelAnimation(element);
done();
}
};
});
</code></pre>
</div>
</section>
</section>
<section>
<section>
<h2 class="em">How to use animations</h2>
<pre class="big-code fragment fade-in" style="text-align:center"><code style="padding:1em;" data-trim>
<div ng-directive ng-animate="..."><div>
</code></pre>
<table class="yom-table fragment fade-in" id="animation-inputs">
<thead>
<tr>
<th class="first">Type</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="first">String</td>
<td class="em">' "some-animation' '</td>
</tr>
<tr>
<td class="first">Object</td>
<td class="em">' {event:"some-animation-enter"} '</td>
</tr>
<tr>
<td class="first">Function</td>
<td class="em">computeAnimation()</td>
</tr>
</tbody>
</table>
</section>
<section>
<h2 class="em">Shortform Syntax</h2>
<p class="fragment fade-in">
When a <span class="em">string</span> then it will expand to <span class="em">value-event</em>
</p>
<table class="yom-table fragment fade-in" id="animation-inputs">
<thead>
<th>Event</th>
<th class="em">ng-animate="'something'"</th>
</thead>
<tbody>
<tr>
<td>enter</td>
<td>something-enter</td>
</tr>
<tr>
<td>leave</td>
<td>something-leave</td>
</tr>
<tr>
<td>move</td>
<td>something-move</td>
</tr>
<tr>
<td>show</td>
<td>something-show</td>
</tr>
<tr>
<td>hide</td>
<td>something-hide</td>
</tr>
<tr>
<td>custom</td>
<td>something-EVENT</td>
</tr>
</tbody>
</table>
</section>
</section>
<section>
<section>
<h2 class="em">Animation-aware Directives</h2>
<p class="fragment fade-in">
The following directives support ngAnimate
</p>
<table class="yom-table fragment fade-in" id="animation-inputs">
<thead>
<tr>
<th>Directive</th>
<th>Events</th>
</tr>
</thead>
<tbody>
<tr>
<td>ngRepeat</td>
<td>enter, move, leave</td>
</tr>
<tr>
<td>ngSwitch, ngView, ngInclude</td>
<td>enter, leave</td>
</tr>
<tr>
<td>ngIf</td>
<td>enter, leave</td>
</tr>
<tr>
<td>ngShow, ngHide</td>
<td>show, hide</td>
</tr>
</tbody>
</table>
</section>
<section>
<h2 class="em">ngShow / ngHide Example</h2>
<p class="fragment fade-in">
Here is an example using ngShow to fading animation
</p>
<pre class="big-code fragment fade-in"><code data-trim>
<div ng-show="showMe"
ng-animate="{show:'show',hide:'hide'}">
</div>
</code></pre>
<pre class="big-code fragment fade-in"><code data-trim>
.show, .hide {
transition:0.5s linear all;
}
.show { opacity:0; }
.show-active { opacity:1; }
.hide { opacity:1; }
.hide-active { opacity:0; }
</code></pre>
</section>
<section>
<h2 class="em">ngView Example</h2>
<p class="fragment fade-in">
Here is an example using ngView to perform a sliding animation
</p>
<pre class="big-code fragment fade-in" style="text-align:center"><code data-trim>
<div ng-view ng-animate="'view'"></div>
</code></pre>
<pre class="big-code fragment fade-in"><code data-trim>
.view-enter, .view-leave {
transition:0.5s linear all;
position:relative;
}
.view-enter { opacity:0; left:20px; }
.view-enter-active { opacity:1; left:0; }
.view-leave { opacity:1; left:0; }
.view-leave-active { opacity:0; left:-20px; }
</code></pre>
</section>
<section>
<h2 class="em">ngRepeat Example</h2>
<p class="fragment fade-in">
Here is an example using ngRepeat to perform an expanding animation
</p>
<pre class="big-code fragment fade-in" style="text-align:center"><code data-trim>
<div ng-repeat="item in items" ng-animate="'scale'"></div>
</code></pre>
<pre class="big-code fragment fade-in"><code data-trim>
ngModule.animate('scale-enter', function() {
return {
setup : function(element) {
var to = {
'line-height' : element.css('line-height'),
'height' : element.css('height')
};
element.css({
'height':0,
'line-height':0,
});
return to;
},
start : function(element, done, to) {
element.animate(to, done);
}
};
});
ngModule.animate('scale-leave', function() {
return {
start : function(element, done) {
element.animate({
'line-height':0,
'height':0
},done);
}
};
});
</code></pre>
</section>
</section>
<section>
<h2 class="em">animate.css</h2>
<p>
Quick and dirty method of putting animations into your AngularJS code.
</p>
<pre class="big-code fragment fade-in"><code data-trim>
<link rel="stylesheet" href="animate.css" />
<div ng-show="showMe" ng-animate="{
enter:'animated fadeIn',
leave:'animated fadeOut'
}"></div>
</code></pre>
<p class="fragment fade-in">
<a class="em" href="http://bitly.com/yom-w3" target="_blank">bitly.com/yom-w3</a> |
<a class="em" href="http://daneden.me/animate/" target="_blank">animate.css homepage</a>
</p>
</section>
<section>
<h2 class="em">Animated Demo</h2>
<div>
Here is an AngularJS application built using ngAnimate:
<a href="http://bitly.com/yom-w2" target="_blank" class="em">http://bitly.com/yom-w2</a>
</div>
<div>
<a href="http://bitly.com/yom-w2" target="_blank">
<div class="animated-example"></div>
</a>
</div>
</section>
<section>
<section>
<h2 class="em">Using $animator in your own directives</h2>
<p class="fragment fade-in">
$animator is a core service for running animations.
</p>
<pre class="big-code fragment fade-in"><code data-trim>
ngModule.directive('my-directive', function($animator) {
return function($scope, element, attrs) {
var animator = $animator($scope, attrs);
//...
};
});
</code></pre>
<p class="fragment fade-in">
Now the created animator object can be used trigger animations
</p>
</section>
<section>
<h2 class="em">How to run animations</h2>
<p class="fragment fade-in">
the animator object can trigger common events such as:
</p>
<table class="yom-table fragment fade-in" id="animation-members">
<thead>
<th class="first">Event</th>
<th class="em">ng-animate="'something'"</th>
</thead>
<tbody>
<tr>
<td class="first">enter</td>
<td>animator.enter(<span class="em2">element, parent, after</span>)</td>
</tr>
<tr>
<td class="first">leave</td>
<td>animator.leave(<span class="em2">element, parent</span>)</td>
</tr>
<tr>
<td class="first">move</td>
<td>animator.move(<span class="em2">element, parent, after</span>)</td>
</tr>
<tr>
<td class="first">show</td>
<td>animator.show(<span class="em2">element</span>)</td>
</tr>
<tr>
<td class="first">hide</td>
<td>animator.hide(<span class="em2">element</span>)</td>
</tr>
<tr>
<td class="first">custom</td>
<td>animator.animate(<span class="em2">event, element</span>)</td>
</tr>
</tbody>
</table>
</section>
<section>
<h2 class="em">$animator example</h2>
<p class="fragment fade-in">
This will show and hide the element when clicked
</p>
<pre class="big-code fragment fade-in"><code data-trim>
ngModule.directive('my-directive', function($animator) {
return function($scope, element, attrs) {
var animator = $animator($scope, attrs);
var toggle = element.children()[0];
var container = element.children()[1];
toggle.bind('click', function() {
container.css('display') == 'none' ?
animator.show(container) :
animator.hide(container);
});
};
});
</code></pre>
<pre class="big-code fragment fade-in"><code data-trim>
<div my-directive
ng-animate="{show:'show',hide:'hide'}">
<button>toggle</button>
<div>...</div>
</div>
</code></pre>
</section>
</section>
<section>
<h2 class="em">Disabling Animations</h2>
<p class="fragment fade-in">
Remove the scope member or return null to ngAnimate.
</p>
<p class="fragment fade-in">
Run <span class="em">$animator.enabled(false)</span> in your controller.
</p>
</section>
<section>
<h2 class="em">Use ngAnimate & $animator</h2>
<p class="fragment fade-in">
Try to always use ngAnimate with your code
</p>
<p class="fragment fade-in">
Automatically cancels and starts animations without collision
</p>
<p class="fragment fade-in">
Easy to disable and enable animations
</p>
<p class="fragment fade-in em">
Common, organized method of creating animation code
</p>
</section>
<section>
<h2 class="em">Soon to come...</h2>
<p class="fragment fade-in">
<span class="em2">animator.addClass</span>,
<span class="em2">animator.removeClass</span>
support
</p>
<p class="fragment fade-in">
<span class="em3">ngClass animation</span> hooks
</p>
<p class="fragment fade-in">
"Spaced" animation support.
</p>
</section>
<section>
<h2 class="em">Thank you!</h2>
<p class="fragment fade-in">
Thank you for making this possible
</p>
<div id="slogo"></div>
<p class="fragment fade-in">
Please use and experiment with animations so that we can make this tool better
</p>
<p class="fragment fade-in">
<a href="https://twitter.com/yearofmoo" class="em" target="_blank">@yearofmoo</a>
</p>
<p class="fragment fade-in">
Feel free to contact me via <span class="em">[email protected]</span>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
Reveal.configure({
keyboard: {
'27': function() {
var on = document.body.className.indexOf('no-clouds') >= 0;
if(on) {
document.body.className = document.body.className.replace(' no-clouds','');
}
else {
document.body.className += ' no-clouds';
}
}
}
});
</script>
</body>
</html>