9
9
padding: 0.2em 1em;
10
10
border: 1px solid black;
11
11
}
12
+ table.play-state-transitions th {
13
+ text-align: center;
14
+ }
12
15
table.play-state-transitions th.rowgroup {
13
16
transform: rotate(-180deg);
14
17
writing-mode: vertical-lr;
15
18
padding-left: 5px;
16
19
}
20
+
21
+ table.event-state-transitions {
22
+ width: 100%;
23
+ border-spacing: 0px;
24
+ border-collapse: collapse;
25
+ }
26
+ table.event-state-transitions th:first-child {
27
+ width: 30%;
28
+ }
29
+ table.event-state-transitions th {
30
+ text-align: center;
31
+ }
32
+ table.event-state-transitions td {
33
+ padding: 0.2em 1em;
34
+ border: 1px solid black;
35
+ }
17
36
</style>
18
37
19
38
<pre class='metadata'>
@@ -39,14 +58,22 @@ urlPrefix: https://w3c.github.io/web-animations/; type: method; for: Animation;
39
58
urlPrefix: https://w3c.github.io/web-animations/; type: method; for: KeyframeEffectReadOnly; spec: web-animations
40
59
text: getFrames()
41
60
urlPrefix: https://w3c.github.io/web-animations/; type: dfn; spec: web-animations
61
+ text: active duration
62
+ text: active phase
63
+ text: after phase
42
64
text: animation
43
- text: animation playback rate
44
65
text: animation class
66
+ text: animation effect
67
+ text: animation playback rate
68
+ text: before phase
45
69
text: composite operation
46
70
text: current iteration
47
71
text: current time
48
72
text: global animation list
49
73
text: idle play state
74
+ text: idle phase
75
+ text: iteration duration
76
+ text: iteration start
50
77
text: pause an animation
51
78
text: play an animation
52
79
text: sampling
@@ -379,47 +406,142 @@ The <em>additional</em> types of animation events that can occur are:
379
406
380
407
Note, this is a more general description of event dispatch than that of CSS
381
408
Animations Level 1 [[CSS3-ANIMATIONS]] since it must account for the
382
- possibility of animations being seeked using the Web Animations API
409
+ possibility of animations being seeked or reversed using the Web Animations API
383
410
[[WEB-ANIMATIONS]].
384
411
385
- For the purpose of determining which events to dispatch, an animation can
386
- be considered to be in one of four mutually-exclusive <dfn
387
- lt="event state">event states</dfn> determined using the following procedure:
388
-
389
- 1. If the animation is <a lt="idle play state">idle</a> or has no <a>target
390
- effect</a> it is <dfn>idle</dfn>.
391
- 1. Otherwise, if the animation has a <a>current time</a> less than the
392
- <a>start delay</a> of its <a>target effect</a>, or, if the animation's
393
- <a lt="animation playback rate">playback rate</a> is less than zero and
394
- it has a <a>current time</a> less than <em>or equal</em> to the
395
- <a>start delay</a> of its <a>target effect</a>, it is
396
- <dfn>left-active</dfn>.
397
- 1. Otherwise, if the animation has a <a>current time</a> greater than its
398
- <a>target effect end</a>, or, if the animation's
399
- <a lt="animation playback rate">playback rate</a> is greater than or equal
400
- to zero and it has a <a>current time</a> greater than <em>or equal</em> to
401
- its <a>target effect end</a>, it is <dfn>right-active</dfn>.
402
- 1. Otherwise, it is <dfn>active</dfn>.
403
-
404
- Each time the animation is <a lt="sampling">sampled</a>, the events to
405
- dispatch are determined by comparing the <a>event state</a> before and
412
+ For the purpose of determining which events to dispatch, the
413
+ [[web-animations#animation-effect-phases-and-states|phases]] defined in
414
+ the Web Animations model are used. These definitions apply to an <a>animation
415
+ effect</a>, however, for the purpose of dispatching events, we consider a
416
+ CSS Animation to have the same phase as its <a>target effect</a>. For example,
417
+ a CSS Animation is in the <a>before phase</a> if its <a>target effect</a>
418
+ is in the <a>before phase</a>. A CSS Animation that does not have a <a>target
419
+ effect</a> is considered to be in the <a>idle phase</a>.
420
+
421
+ Similarly, subsequent references to the <a>start delay</a>, <a>active
422
+ duration</a>, <a>current iteration</a>, <a>iteration start</a>, and
423
+ <a>iteration duration</a> of a CSS animation should be understood to refer
424
+ to the corresponding properties of the animation's <a>target effect</a>.
425
+
426
+ For calculating the {{AnimationEvent/elapsedTime}} of each event, the following
427
+ definitions are used:
428
+
429
+ * <dfn>interval start</dfn> =
430
+ <code>max(min(-<a>start delay</a>, <a>active duration</a>), 0)</code>
431
+ * <dfn>interval end</dfn> =
432
+ <code>max(min(<a>target effect end</a> - <a>start delay</a>,
433
+ <a>active duration</a>), 0)</code>
434
+
435
+ Each time an animation is <a lt="sampling">sampled</a>, the events to
436
+ dispatch are determined by comparing the animation's phase before and
406
437
after the sample as follows:
407
438
408
- : not <a>active</a> → <a>active</a>
409
- :: <a idl>animationstart</a>
410
- : <a>left-active</a> → <a>right-active</a>
411
- : <a>right-active</a> → <a>left-active</a>
412
- :: <a idl>animationstart</a>, <a idl>animationend</a>
413
- : <a>active</a> → <a>left-active</a>
414
- : <a>active</a> → <a>right-active</a>
415
- :: <a idl>animationend</a>
416
- : <a>active</a> → <a>active</a>
417
- :: <a idl>animationiteration</a> <em>if</em> there has been a change to the
418
- <a>current iteration</a> of the animation's <a>target effect</a>.
419
- : not <a>idle</a> → <a>idle</a>
420
- :: <a idl>animationcancel</a>
421
-
422
- Issue: Define the value of <code>elapsedTime</code> for each case.
439
+ <table class="event-state-transitions">
440
+ <thead>
441
+ <tr>
442
+ <th>Change</th>
443
+ <th>Events dispatched</th>
444
+ <th><dfn>Elapsed time</dfn> (ms)</th>
445
+ </tr>
446
+ </thead>
447
+ <tbody>
448
+ <tr>
449
+ <td><a lt="idle phase">idle</a> →
450
+ <a lt="active phase">active</a></td>
451
+ <td><a idl>animationstart</a></td>
452
+ <td>If the <a>animation playback rate</a> is ≥ 0,
453
+ use the <a>interval start</a>, otherwise use the
454
+ <a>interval end</a>.
455
+ </td>
456
+ </tr>
457
+ <tr>
458
+ <td><a lt="before phase">before</a> →
459
+ <a lt="active phase">active</a></td>
460
+ <td><a idl>animationstart</a></td>
461
+ <td><a>interval start</a></td>
462
+ </tr>
463
+ <tr>
464
+ <td><a lt="after phase">after</a> →
465
+ <a lt="active phase">active</a></td>
466
+ <td><a idl>animationstart</a></td>
467
+ <td><a>interval end</a></td>
468
+ </tr>
469
+ <tr>
470
+ <td rowspan="2"><a lt="before phase">before</a> →
471
+ <a lt="after phase">after</a> <a
472
+ href="#multiple-events-note">٭</a></td>
473
+ <td><a idl>animationstart</a></td>
474
+ <td><a>interval start</a></td>
475
+ </tr>
476
+ <tr>
477
+ <td><a idl>animationend</a></td>
478
+ <td><a>interval end</a></td>
479
+ </tr>
480
+ <tr>
481
+ <td rowspan="2"><a lt="after phase">after</a> →
482
+ <a lt="before phase">before</a> <a
483
+ href="#multiple-events-note">٭</a></td>
484
+ <td><a idl>animationstart</a></td>
485
+ <td><a>interval end</a></td>
486
+ </tr>
487
+ <tr>
488
+ <td><a idl>animationend</a></td>
489
+ <td><a>interval start</a></td>
490
+ </tr>
491
+ <tr>
492
+ <td><a lt="active phase">active</a> →
493
+ <a lt="before phase">before</a></td>
494
+ <td><a idl>animationend</a></td>
495
+ <td><a>interval start</a></td>
496
+ </tr>
497
+ <tr>
498
+ <td><a lt="active phase">active</a> →
499
+ <a lt="after phase">after</a></td>
500
+ <td><a idl>animationend</a></td>
501
+ <td><a>interval end</a></td>
502
+ </tr>
503
+ <tr>
504
+ <td><a lt="active phase">active</a> →
505
+ <a lt="active phase">active</a>
506
+ <em>and</em>
507
+ the <a>current iteration</a> of the animation's <a>target effect</a>
508
+ has changed since the previous sample
509
+ </td>
510
+ <td><a idl>animationiteration</a></td>
511
+ <td>(See below)
512
+ <a href="#animation-iteration-elapsed-time">†</a></td>
513
+ </tr>
514
+ <tr>
515
+ <td>Not <a lt="idle phase">idle</a> →
516
+ <a lt="idle phase">idle</a></td>
517
+ <td><a idl>animationcancel</a></td>
518
+ <td>0</td>
519
+ </tr>
520
+ </tbody>
521
+ </table>
522
+
523
+ <p id="multiple-events-note">٭ Where multiple events are listed for
524
+ a state change, all events are dispatched in the order listed and in immediate
525
+ succession.</p>
526
+
527
+ <p id="animation-iteration-elapsed-time">† The <a>elapsed time</a> for
528
+ an <a idl>animationiteration</a> event is defined as follows:</p>
529
+
530
+ 1. Let <var>previous current iteration</var> be the <a>current iteration</a>
531
+ from the previous sample.
532
+
533
+ 1. If <var>previous current iteration</var> is greater than <a>current
534
+ iteration</a>, let <var>iteration boundary</var> be <code><a>current
535
+ iteration</a> + 1</code>, otherwise let it be <a>current iteration</a>.
536
+
537
+ 1. The <a>elapsed time</a> is the result of evaluating
538
+ <code>(<var>iteration boundary</var> - <a>iteration start</a>) ×
539
+ <a>iteration duration</a>)</code>.
540
+
541
+ Since the <a>elapsed time</a> defined in the table and procedure above is
542
+ expressed in milliseconds, it must be divided by 1,000 to produce a value in
543
+ seconds before being assigned to the {{AnimationEvent/elapsedTime}} member of
544
+ the {{AnimationEvent}}.
423
545
424
546
# DOM Interfaces # {#interface-dom}
425
547
0 commit comments