forked from maxwellito/vivus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
510 lines (447 loc) · 27.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>vivus.js - svg animation</title>
<meta name="description" content="SVG Drawing Animation" />
<style type="text/css">
/* Base style */
body {
margin: 0 0 40px;
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
font-weight: 100;
font-size: 24px;
color: #666666;
background-color: #F9F9F9;
}
a, a:visited, a:hover, a:link {
color: #666666;
outline: 0;
}
small {
font-weight: 100;
}
p {
font-size: 1em;
}
dl dt {
font-weight: bold;
}
dl dd {
margin-bottom: 14px;
}
button, .button {
margin: 0; padding: 8px;
border-radius: 10px;
border: 1px solid #666666;
color: #666666;
background-color: rgba(0,0,0,0);
font-size: 16px;
font-weight: 100;
text-decoration: none;
cursor: pointer;
outline: 0;
}
i {
background-color: rgba(0,0,0,0.1);
border-radius: 4px;
}
/* Common components */
.content {
margin: auto;
max-width: 960px;
padding: 0 20px;
}
.smaller {
margin: 4px 0;
font-size: 0.75em;
}
.bigger {
font-size: 1em;
}
.clearer {
clear: both;
}
.striked {
text-decoration: line-through;
}
.italic {
font-style: italic;
}
.col3 {
width: 33.33%;
float: left;
text-align: center;
border-bottom-color: #666;
border-bottom-style: solid;
}
.col-container {
padding: 0 12px;
}
.col3 p {
font-size: 0.75em;
}
.code {
overflow: scroll;
margin: 0; padding: 10px;
border: none;
background-color: rgba(0,0,0,0.1);
font-size: 0.6125em;
font-family: monospace;
}
.bloc {
color: #f9f9f9;
padding: 1px 0 30px;
border-color: #f9f9f9;
}
.bloc button {
border: 1px solid #f9f9f9;
color: #f9f9f9;
}
/* Colors */
.bloc-head { background: #5aa8c5; padding: 30px; }
.bloc-anim { background: #2e2e2e; }
.bloc-documentation { background: #d36281; }
.bloc-example { background: #4fe084; }
/* Custom */
#tape {
width: 100%;
}
.intro-links {
text-align: right;
}
.example-description {
margin-left: 440px;
}
.example-svg {
float: left;
}
#polaroid {
width: 400px; height: 320px;
}
.goodbye-head {
font-size: 1.5em;
text-align: center;
margin-bottom: 0;
}
.goodbye-sub {
font-size: 0.875em;
text-align: center;
margin: 0 0 20px;
}
/* Media queries */
@media (min-width: 768px) {
.col3 { border-bottom: none; }
}
@media (max-width: 767px) {
#polaroid { width: 100%; max-height: 300px; }
.example-description { margin-left: 0; }
.col3 { width: 100%; float: none; margin-bottom: 25px; padding-bottom: 25px; border-bottom-width: 1px; min-height: 200px; }
.col3:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom-width: 0px; }
}
@media (min-width: 481px) and (max-width: 767px) {
#polaroid { width: 100%; max-height: 300px; }
.example-description { margin-left: 0; }
.col3:nth-child(2n) svg {
width: 200px;
float: right;
}
.col3:nth-child(2n) .col-container {
text-align: right;
margin-right: 200px;
}
.col3:nth-child(2n+1) svg {
width: 200px;
float: left;
}
.col3:nth-child(2n+1) .col-container {
text-align: left;
margin-left: 200px;
}
}
@media (max-width: 480px) {
.col-container { padding: 0px; }
#polaroid { width: 100%; max-height: 260px; }
}
</style>
</head>
<body>
<!-- Head: HI THERE -->
<div class="bloc bloc-head">
<svg height="300" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 404.7 354" enable-background="new 0 0 404.7 354" id="tape" onclick="hi.reset(); hi.play();">
<!-- HI -->
<path fill="none" data-duration="10" stroke="#FFFFFF" stroke-width="4" d="M324.6,61.2c16.6,0,29.5-12.9,29.5-29.5c0-16.6-12.9-29.5-29.5-29.5c-16.6,0-29.5,12.9-29.5,29.5C295.1,48.4,308,61.2,324.6,61.2z"/>
<path fill="none" data-duration="130" stroke="#FFFFFF" stroke-width="4" d="M366.2,204.2c-9.8,0-15-5.6-15-15.1V77.2h-85v28h19.5c9.8,0,8.5,2.1,8.5,11.6v72.4c0,9.5,0.5,15.1-9.3,15.1H277h-20.7c-8.5,0-14.2-4.1-14.2-12.9V52.4c0-8.5,5.7-12.3,14.2-12.3h18.8v-28h-127v28h18.1c8.5,0,9.9,2.1,9.9,8.9v56.1h-75V53.4c0-11.5,8.6-13.3,17-13.3h11v-28H2.2v28h26c8.5,0,12,2.1,12,7.9v142.2c0,8.5-3.6,13.9-12,13.9h-21v33h122v-33h-11c-8.5,0-17-4.1-17-12.2v-57.8h75v58.4c0,9.1-1.4,11.6-9.9,11.6h-18.1v33h122.9h5.9h102.2v-33H366.2z"/>
<path fill="none" data-async data-delay="20" stroke="#FFFFFF" stroke-width="4" d="M358.8,82.8c11.1-4.2,18.8-14.7,18.8-27.5c0-8.5-3.4-16-8.9-21.3"/>
<path fill="none" data-async stroke="#FFFFFF" stroke-width="4" d="M124.2,105.7V77c0-11.5,9.1-13.8,17.5-13.8h10.5V44.7"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="147.9,40.2 171.2,63.2 175.7,63.2"/>
<line fill="none" data-async stroke="#FFFFFF" stroke-width="4" x1="295.1" y1="32.1" x2="275.2" y2="12.2"/>
<path fill="none" data-async stroke="#FFFFFF" stroke-width="4" d="M266.2,204.7V75.9c0-8.5,5.2-12.8,13.7-12.8h18.3V44.7"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="265.9,105.2 289.2,129.2 293.7,129.2"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="374.2,204.7 374.2,94.2 358.8,82.8 351.2,77.2"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="148.2,237.2 171.2,261.2 294.6,261.2 300.5,261.2 402.2,261.2 402.2,228.2 379.2,204.2"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="124.2,204.7 124.2,157.2 175.7,157.2"/>
<line fill="none" data-async stroke="#FFFFFF" stroke-width="4" x1="147.7" y1="228.2" x2="129.2" y2="204.2"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="7.2,237.3 30.2,261.2 152.2,261.2 152.2,241.7"/>
<polyline fill="none" data-async stroke="#FFFFFF" stroke-width="4" points="1.9,40.2 26,63.2 39.7,63.2"/>
<line fill="none" data-async stroke="#FFFFFF" stroke-width="4" x1="129.2" y1="12.2" x2="148.2" y2="33.2"/>
<line fill="none" data-async stroke="#FFFFFF" stroke-width="4" x1="303.9" y1="53" x2="328.1" y2="77.2"/>
<line fill="none" stroke="#FFFFFF" stroke-width="4" x1="345.1" y1="10.5" x2="368.7" y2="34"/>
<!-- there -->
<path fill="none" data-delay="30" data-duration="60" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M76.8,337.3c0,0,1.9,12.2,13.1,12.2c22.1,0,23.8-1.8,59-66.4c-19.7,35.7-36.4,66.2-19.3,66.2c15.2,0,22.9-14.2,28.3-23.7c3.3-0.5,24-3.2,35-25.5c4-8.1,4.1-17.8-8.1-15.2c-5.6,1.2-13.1,14.8-15.7,19.2c-7.6,12.7-22.4,45.2-22.4,45.2s10.3-22.4,21.5-22.4c15.5,0-9.4,22.4,4.7,22.4c4.9,0,11.7-11.4,16.6-20.9c7.5,4.7,19.7,1.7,24.5-8.1c10.1-20.4-14.4-12.8-24.5,8.1c-5.5,11.3-2.2,21.1,11.2,21.1c16.4,0,26.1-28.3,30.5-37.5c9.9,2.5,14,2.5,22.7-1.1c-3.5,5.1-24,38.1-8.3,38.1c6.7,0,11.7-11.4,16.6-20.9c7.5,4.7,19.7,1.7,24.5-8.1c10.1-20.4-14.4-12.8-24.5,8.1c-5.5,11.3-2.2,21.1,11.2,21.1c16.4,0,20.6-4,24.7-10.5"/>
<path fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="M157.3,300.8c3.8-2.3-29,0.8-35.6,3.2"/>
</svg>
</div>
<!-- Intro -->
<div class="content">
<h1>vivus<small>, bringing your SVGs to life</small></h1>
<p>Vivus is a little JavaScript class (little because it's lightweight and has no dependencies) to make animating SVGs easy. Different animations are available, and you can even script the entire SVG to do whatever you want.</p>
<p class="intro-links">
<a href="//github.com/maxwellito/vivus" class="button bigger">View on GitHub</a>
</p>
</div>
<!-- Animation examples/demo -->
<div class="bloc bloc-anim">
<div class="content">
<h2>How it looks</h2>
<div>
<div class="col3">
<svg id="opturateur1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="100%" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" onclick="obt1.reset(); obt1.play();">
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="90"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="85.74"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="72.947"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="39.74"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="34.042" y1="131.189" x2="67.047" y2="77.781"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="31.306" y1="75.416" x2="92.41" y2="60.987"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="68.81" y1="34.042" x2="122.219" y2="67.046"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="124.584" y1="31.305" x2="139.013" y2="92.409"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="165.957" y1="68.809" x2="132.953" y2="122.219"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="168.693" y1="124.584" x2="107.59" y2="139.012"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="131.19" y1="165.957" x2="77.781" y2="132.953"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="75.417" y1="168.693" x2="60.987" y2="107.59"/>
</svg>
<div class="col-container">
<h3>Delayed</h3>
<p>Every path element is drawn at the same time with a little delay at the start. This is default animation.</p>
<button onclick="obt1.reset(); obt1.play();">replay</button>
</div>
</div>
<div class="col3">
<svg id="opturateur2" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="100%" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" onclick="obt2.reset(); obt2.play();">
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="90"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="85.74"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="72.947"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="39.74"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="34.042" y1="131.189" x2="67.047" y2="77.781"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="31.306" y1="75.416" x2="92.41" y2="60.987"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="68.81" y1="34.042" x2="122.219" y2="67.046"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="124.584" y1="31.305" x2="139.013" y2="92.409"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="165.957" y1="68.809" x2="132.953" y2="122.219"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="168.693" y1="124.584" x2="107.59" y2="139.012"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="131.19" y1="165.957" x2="77.781" y2="132.953"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="75.417" y1="168.693" x2="60.987" y2="107.59"/>
</svg>
<div class="col-container">
<h3>Async</h3>
<p>Each line is drawn asynchronously. They all start and finishe at the same time, hence `async`.</p>
<button onclick="obt2.reset(); obt2.play();">replay</button>
</div>
</div>
<div class="col3">
<svg id="opturateur3" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="100%" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" onclick="obt3.reset(); obt3.play();">
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="90"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="85.74"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="72.947"/>
<circle fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" cx="100" cy="100" r="39.74"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="34.042" y1="131.189" x2="67.047" y2="77.781"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="31.306" y1="75.416" x2="92.41" y2="60.987"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="68.81" y1="34.042" x2="122.219" y2="67.046"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="124.584" y1="31.305" x2="139.013" y2="92.409"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="165.957" y1="68.809" x2="132.953" y2="122.219"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="168.693" y1="124.584" x2="107.59" y2="139.012"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="131.19" y1="165.957" x2="77.781" y2="132.953"/>
<line fill="none" stroke="#f9f9f9" stroke-width="3" stroke-miterlimit="10" x1="75.417" y1="168.693" x2="60.987" y2="107.59"/>
</svg>
<div class="col-container">
<h3>OneByOne</h3>
<p>Each path element is drawn one after each other. This animation gives the impression of live drawing.</p>
<button onclick="obt3.reset(); obt3.play();">replay</button>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<!-- How it works? -->
<div class="content">
<h2>How it works</h2>
<p>To make this effect, the script use the CSS property <i>strokeDashoffset</i>. This property manages the stroke offset on every line of the SVG. Add some JavaScript to update this value progressively, and the magic begins.<br>Unfortunately, there's a problem, this property is only available on <i>path</i> elements. So if you use <i>circle</i>, <i>rect</i>, <i>line</i>, or <i>polyline</i>, they will break the animation. Because of this, another class is available in the repo, called <i>pathformer</i>. It's made to transform all the objects in your SVG into path elements, so you can use this property and then animate your SVG.<br>The animation always draws elements in the same order as they are set in the SVG tag.</p>
<p>The code is inspired from other repo. The drawer is inspired from the excellent <a href="http://tympanus.net/codrops/">Codrops</a> post about <a href="http://tympanus.net/codrops/2013/12/30/svg-drawing-animation/">SVG Drawing Animation</a> (if you didn't know about this website, get ready for mind-blowing). The <i>pathformer</i> is inspired quite a bit from <a href="https://github.com/Waest/SVGPathConverter">SVGPathConverter</a> by <a href="https://github.com/Waest">Waest</a>.</p>
</div>
<!-- How to use it? -->
<div class="bloc bloc-documentation">
<div class="content">
<h2>How to use it</h2>
<p>As I said, no dependencies here. You just need to include the scripts.</p>
<p class="code">
new Vivus('my-svg-id', {type: 'delayed', duration: 200}, myCallback);
</p>
<p>The Vivus constructor asks for 3 parameters :</p>
<ul>
<li>ID of the SVG to animate (or the DOM element)</li>
<li>Options object (described in the following)</li>
<li>Callback to call at the end of the animation (optional)</li>
</ul>
<p>The options object must respect this structure :</p>
<dl>
<dt>type <small>string</small></dt>
<dd>define what kind of animation will be used: <i>delayed</i>, <i>async</i>, <i>oneByOne</i>, <i>scenario</i> or <i>scenario-sync</i></dd>
<dt>duration <small>integer</small></dt>
<dd>animation duration, in frames</dd>
<dt>start <small>string</small></dt>
<dd>define how to trigger the animation
<p class="smaller">
<strong>inViewport</strong> once the SVG is in the viewport<br>
<strong>manual</strong> give you the freedom to call <i>play</i> method to start<br>
<strong>autostart</strong> make it start right now<br>
</p>
</dd>
<dt>delay <small>integer</small></dt>
<dd>time between the drawing of first and last path, in frames (only for <i>delayed</i> animations)</dd>
<dt>selfDestroy <small>boolean</small></dt>
<dd>remove all extra styling on the SVG, and leave it as original</dd>
</dl>
<p>To control the animation, three methods are available : play, stop and reset. The method play takes one parameter which is the speed. This value can be positive, negative (to go backwards), or under 1 to play slowly. By default the value is 1.</p>
</div>
</div>
<!-- Scripting -->
<div class="content">
<h2>Scenarize</h2>
<p>This feature allows you to script the animation of your SVG. To do this, the custom values will be set directly in the DOM of the SVG.</p>
<hr>
<h3>{type: '<i>scenario</i>'}</h3>
<p>This type is easier to understand, but takes longer to implement. You just have to define the start and duration of each element with <i>data-start</i> and <i>data-duration</i> attributes. If missing, it will use the default value given to the constructor.</p>
<p>The good point about this type is the flexibility. You don't have to respect the order/stack of the SVG. You can start with the last element, then continue with the first, to finish with all the rest at the same time.</p>
<p>Then define custom rules for each element in your SVG via extra attributes in your SVG DOM :</p>
<dl>
<dt>data-start <small>integer</small></dt>
<dd>time when the animation must start, in frames</dd>
<dt>data-duration <small>integer</small></dt>
<dd>animation duration of this path, in frames</dd>
</dl>
<pre class="code">
<svg>
<circle <i>data-start="0"</i> <i>data-duration="10"</i> ... />
<circle <i>data-start="20"</i> <i>data-duration="10"</i> ... />
<circle <i>data-start="20"</i> <i>data-duration="20"</i> ... />
<circle <i>data-start="0"</i> <i>data-duration="30"</i> ... />
</svg></pre>
<hr>
<h3>{type: '<i>scenario-sync</i>'}</h3>
<p>It's not the sexiest code ever, but quite flexible. The behaviour is quite different, let's see.</p>
<p>By using this animation type, the default behaviour is the same as `oneByOne`. But here, you can define some properties on a specific path item. Like the duration, the delay to start (from the end of the previous path) and if it should be played asyncronously.</p>
<dl>
<dt>data-delay <small>integer</small></dt>
<dd>time between the end of the animation of the previous path and the start of the current path, in frames</dd>
<dt>data-duration <small>integer</small></dt>
<dd>animation duration of this path, in frames</dd>
<dt>data-async <small>(no value required)</small></dt>
<dd>make the drawing of this path asynchronous. It means the next path will start at the same time.</dd>
</dl>
<p>If a path does not have an attribute for duration or delay. The default one, set in options, will be used.</p>
<p>For an easier debug, have a look to the attribute <i>map</i> of your Vivus object. This one contain the mapping of your animation. If you're using Google Chrome, I recommand you to use `console.table` to get a nice output of the array, which will make your debug easier.</p>
</div>
<!-- Scripting example -->
<div class="bloc bloc-example">
<div class="content">
<div class="script-example">
<svg id="polaroid" class="example-svg" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 200 160" enable-background="new 0 0 200 160" onclick="pola.reset(); pola.play();">
<!-- Case -->
<!-- The case items will be drawn at the same time (attribute `data-async` on each tag) with a custom duration of 40 frames (attribute `data-duration`). WARNING: When you want to draw a bloc asynchronously (like here), the last item need to be `data-async` free. Otherwise the following tags will also start at the same time. I know it's a bit confusing, play a bit with it and you'll see. -->
<path data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M106.725,104.742c-0.773,2.498-3.586,4.229-6.285,3.867L12.473,96.802c-2.699-0.363-4.262-2.682-3.49-5.18l25.164-81.436
c0.771-2.496,3.584-4.229,6.283-3.866l87.966,11.808c2.699,0.362,4.264,2.68,3.49,5.179L106.725,104.742z"/>
<path data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M101.02,123.207c-0.773,2.5-3.587,4.23-6.286,3.867L6.766,115.27c-2.699-0.363-4.26-2.682-3.488-5.182l2.91-9.417
c0.771-2.499,3.585-4.23,6.285-3.87l87.967,11.809c2.699,0.361,4.261,2.682,3.49,5.18L101.02,123.207z"/>
<line data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="103.377" y1="128.225" x2="154.768" y2="155.32"/>
<line data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="109.852" y1="112.684" x2="155.035" y2="136.906"/>
<path data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M9.096,120.207l47.932,21.994c0,0,98.06,12.414,97.74,13.119c-0.318,0.709,5.426-16.205,5.426-16.205l-2.646-96.842
c-1.098-7.587-2.467-11.8-8.559-15.024l-12.635-6.604"/>
<path data-async data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M161.586,38.135l30.717,16.085c0,0,5.295,2.323,4.543,6.504l-3.215,10.527c-0.648,2.621-2.939,4.988-8.229,2.798l-9.154-4.701
l-11.834,56.441"/>
<path data-duration="40" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M183.148,49.518c0,0,5.295,2.324,4.543,6.506l-3.215,10.526c-0.648,2.622-2.938,4.988-8.229,2.798"/>
<!-- Lens -->
<!-- All item will be drawn line by line, with an exception for the first one, a little delay (attribute `data-delay) to make a break between the drawing of the case and the start of the lens part -->
<path data-delay="20" fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M87.176,56.143C83.274,68.78,69.043,77.538,55.395,75.706S33.846,62.146,37.75,49.511c3.903-12.637,18.135-21.392,31.783-19.562
C83.181,31.782,91.081,43.51,87.176,56.143z"/>
<path fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M92.745,56.891c-4.785,15.48-22.219,26.213-38.942,23.969C37.079,78.615,27.4,64.245,32.184,48.763
c4.783-15.48,22.218-26.211,38.94-23.968C87.848,27.041,97.528,41.411,92.745,56.891z"/>
<path fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M78.99,26.933c16.169,7.426,19.398,10.989,22.026,20.105c1.283,4.449,1.271,9.411-0.3,14.489
c-4.783,15.479-22.217,26.213-38.941,23.969c-8.68-1.165-21.171-7.963-25.613-14.055"/>
<path fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M42.602,50.162c3.137-10.157,14.573-17.193,25.543-15.722"/>
<!-- Flash -->
<!-- This tag does not have any extra attribute. So it will start when the previous tag is finished. His duration and delay will be the one given in the options. -->
<path fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M103.789,29.275c-0.568,1.841,0.582,3.549,2.57,3.818l12.807,1.72c1.988,0.266,4.062-1.012,4.633-2.851l1.66-5.38
c0.568-1.843-0.582-3.551-2.57-3.816l-12.807-1.72c-1.988-0.268-4.062,1.01-4.633,2.85L103.789,29.275z"/>
<!-- Output -->
<!-- Same case as Flash -->
<path fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M11.129,105.791c-0.297,0.965,0.305,1.855,1.346,1.994l81.446,10.932c1.038,0.141,2.123-0.527,2.42-1.49l0,0
c0.298-0.961-0.304-1.855-1.343-1.996l-81.447-10.93C12.51,104.16,11.426,104.828,11.129,105.791L11.129,105.791z"/>
<!-- Design (color lines on the front) -->
<!-- All the lines will start at the same time, because they all have the attribute `data-async` -->
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="47.583" y1="101.505" x2="51.561" y2="88.267"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="53.391" y1="102.326" x2="57.047" y2="90.125"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="59.224" y1="103.068" x2="62.749" y2="91.295"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="65.057" y1="103.814" x2="69.015" y2="90.637"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="72.87" y1="19.969" x2="75.497" y2="11.082"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="78.512" y1="21.325" x2="81.317" y2="11.868"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="83.833" y1="23.718" x2="87.16" y2="12.582"/>
<line data-async fill="none" stroke="#f9f9f9" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="89.145" y1="26.141" x2="92.939" y2="13.498"/>
</svg>
<div class="example-description">
<p>Here is an example using <i>scenario-sync</i>.<br>I recommend you to look at the source code, it's well commented.</p>
<p>The idea is to first, draw the case asynchronously, then after a little pause start to draw the lens, following by the flash and the picture output. To finish with the stripes on the front.</p>
<button onclick="pola.reset(); pola.play();">replay</button>
<button onclick="pola.play(-3);">rewind</button>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<!-- Goodbye -->
<div class="content">
<p class="goodbye-head">Thanks for watching.</p>
<p class="goodbye-sub">Made with <span class="striked">love</span> <span class="italic">a keyboard</span></p>
</div>
<!-- Le scripts -->
<script src="dist/vivus.js"></script>
<script>
var hi = new Vivus('tape', {type: 'scenario-sync', duration: 20, start: 'autostart'}, function () {
if (console) {
console.log('Animation finished. [log triggered from callback]');
}
}),
obt1 = new Vivus('opturateur1', {type: 'delayed', duration: 150}),
obt2 = new Vivus('opturateur2', {type: 'async', duration: 150}),
obt3 = new Vivus('opturateur3', {type: 'oneByOne', duration: 150}),
pola = new Vivus('polaroid', {type: 'scenario-sync', duration: 20});
</script>
</body>
</html>