-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.bs
810 lines (657 loc) · 30.7 KB
/
Overview.bs
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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
<style type="text/css">
table.event-state-transitions {
width: 100%;
border-spacing: 0px;
border-collapse: collapse;
}
table.event-state-transitions th:first-child {
width: 30%;
}
table.event-state-transitions th {
text-align: center;
}
table.event-state-transitions td {
padding: 0.2em 1em;
border: 1px solid black;
}
</style>
<pre class='metadata'>
Title: CSS Animations Level 2
Status: ED
Work Status: Exploring
Shortname: css-animations-2
Level: 2
Group: csswg
ED: https://drafts.csswg.org/css-animations-2/
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Editor: Brian Birtles, Mozilla https://www.mozilla.org/, bbirtles@mozilla.com, w3cid 43194
!Issues List: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=Animations&list_id=36653&product=CSS&query_format=advanced&resolution=---">In Bugzilla</a>
Abstract: This CSS module describes a way for authors to animate the values of CSS properties over time, using keyframes. The behavior of these keyframe animations can be controlled by specifying their duration, number of repeats, and repeating behavior.
Ignored Vars: auto-rewind
</pre>
<pre class=anchors>
urlPrefix: https://dom.spec.whatwg.org/; type: dfn; spec: dom
text: event target
</pre>
<pre class=link-defaults>
spec:web-animations-1; type:dfn;
text:active duration
text:active phase; for:animation effect
text:active time
text:after phase; for:animation effect
text:animation class
text:animation effect
text:animation playback events
text:associated effect
text:associated effect end
text:before phase; for:animation effect
text:current iteration
text:current time; for:animation
text:composite operation
text:fill mode
text:idle play state
text:idle phase; for:animation effect
text:iteration duration
text:iteration count
text:iteration start
text:keyframe
text:pause an animation
text:paused play state
text:pending pause task
text:pending play task
text:play an animation
text:play state
text:playback direction
text:start delay
text:target element
text:unresolved
</pre>
<h2 id="delta">Delta specification</h2>
<p>This is a delta specification, meaning that it currently contains
only the differences from CSS Animations Level 1 [[!CSS3-ANIMATIONS]].
Once the Level 1 specification is closer to complete, it will be merged
with the additions here into a complete level 2 specification.</p>
# Animations # {#animations}
Changes to any of the animation properties defined in this specification
cause the corresponding {{CSSAnimation}} object and its associated objects
to be updated according to the correspondence between these properties
and Web Animations concepts defined in [[#keyframes]].
However, if the author modifies the animation
using the Web Animations programming interface,
the changes from the programming interface take precedence as follows:
* After a successful call to {{KeyframeEffect/setKeyframes()}}
on the {{KeyframeEffect}} associated with a {{CSSAnimation}},
any subsequent change to matching ''@keyframes'' rules or the resolved value
of the 'animation-timing-function' property for the target element
will not be reflected in that animation.
However, if the last matching ''@keyframes'' rule is removed
the animation must still be canceled.
* After a successful call to {{AnimationEffect/updateTiming()}}
on the {{KeyframeEffect}} associated with a {{CSSAnimation}},
for each property included in the
{{AnimationEffect/updateTiming(timing)/timing}} parameter,
any subsequent change to a corresponding animation property
will not be reflected in that animation.
For example, calling
<code>cssAnimation.effect.updateTiming({ duration: 1000 })</code>
would cause subsequent changes to 'animation-duration' to be ignored
whilst changes to 'animation-delay' would still be reflected
in the {{KeyframeEffect}}'s timing.
* After a successful call to {{Animation/play()}} or {{Animation/pause()}}
on a {{CSSAnimation}},
any subsequent change to the 'animation-play-state' will no longer
cause the {{CSSAnimation}} to be played or paused
as defined in [[#animation-play-state]].
* After a successful call to {{Animation/reverse()}} on a {{CSSAnimation}}
or after successfully setting the {{Animation/startTime}}
on a {{CSSAnimation}},
if, as a result of that call the [=play state=] of the
{{CSSAnimation}} changes to or from the [=paused play state=],
any subsequent change to the 'animation-play-state' will no longer
cause the {{CSSAnimation}} to be played or paused
as defined in [[#animation-play-state]].
The requirement for a change to or from the [=paused play state=]
ensures that even after calling
{{Animation/reverse()}} or setting the {{Animation/startTime}}
on a running animation,
the animation continues to observe changes in 'animation-play-state'.
* After successfully setting the {{Animation/effect}} of a {{CSSAnimation}}
to <code>null</code>
or some {{AnimationEffect}} other than the original {{KeyframeEffect}},
all subsequent changes to animation properties other than
'animation-name' or 'animation-play-state'
will not be reflected in that animation.
Similarly, any change to matching ''@keyframes'' rules will not be reflected
in that animation.
However, if the last matching ''@keyframes'' rule is removed
the animation must still be canceled.
Note, the reference to a successful call in the above rules
is necessary to ensure that
when an exception is thrown by any of these methods,
the override behavior is <em>not</em> applied.
## Owning element ## {#owning-element-section}
The <dfn>owning element</dfn> of an animation refers to the element or
pseudo-element to which the 'animation-name' property was applied that generated
the animation.
If an animation generated using the markup defined in this specification is
later disassociated from that markup by an update to the computed value of the
'animation-name' property on the <a>owning element</a>, the animation is
disassociated from its <a>owning element</a> (that is, it has no <a>owning
element</a> from that point forwards).
<div class="note">
In the example below, <code>animation</code>'s initial <a>owning element</a>
is <code>elem</code>. <code>animation</code> is disassociated from
<code>element</code> through an update to the computed value of
<code>elem</code>'s 'animation-name' property.
<pre class="example lang-javascript">
elem.style.animation = 'spin 1s';
let animation = elem.getAnimations()[0]; // animation's owning element is elem
elem.style.animation = ''; // animation no longer has an owning element
</pre>
Note that although the <a>owning element</a> is often equal to the
[=target element=] of an animation's [=associated effect=],
this is not always the case.
The following example demonstrates some of the situations where these two
elements may differ.
<pre class="example lang-javascript">
elem.style.animation = 'move 1s';
let animation = elem.getAnimations()[0];
// animation.effect.target == elem == animation's owning element
animation.effect.target = elem2;
// animation.effect.target == elem2 != animation's owning element
animation.effect = null;
// animation.effect?.target is undefined != animation's owning element
</pre>
</div>
## Animation composite order ## {#animation-composite-order}
[=Animations=] generated from the markup defined in
this specification have an <a>animation class</a> of ‘CSS
Animation’.
CSS Animations <em>with</em> an <a>owning element</a> have a <em>later</em>
composite order than CSS Transitions but an <em>earlier</em> composite order
than animations without a specific <a>animation class</a>.
Within the set of CSS Animations <em>with</em> an <a>owning element</a>, two
animations <var>A</var> and <var>B</var> are sorted in composite order (first to
last) as follows:
1. If the <a>owning element</a> of <var>A</var> and <var>B</var>
differs, sort <var>A</var> and <var>B</var> by <a>tree order</a>
of their corresponding <a>owning elements</a>.
With regard to pseudo-elements, the sort order is as follows:
* element
* ::marker
* ::before
* any other pseudo-elements not mentioned specifically in this list,
sorted in ascending order by the Unicode codepoints that make up each selector
* ::after
* element children
1. Otherwise, sort <var>A</var> and <var>B</var> based on their position in the
computed value of the 'animation-name' property of the (common) <a>owning
element</a>.
The composite order of CSS Animations <em>without</em> an <a>owning element</a>
is based on their position in the <a>global animation list</a>.
Issue: This differs from the behavior defined for transitions. We should
probably sort transitions first, then animation, then use the global animation
list. The reason being that when developer tools etc. hang on to orphaned
animations and transitions in order to replay them, they should maintain
roughly the same composite order.
CSS Animations generated using the markup defined in this specification are
<em>not</em> added to the <a>global animation list</a> when they are created.
Instead, these animations are appended to the <a>global animation list</a> at
the first moment when they transition out of the <a>idle play state</a> after
being disassociated from their <a>owning element</a>.
CSS Animations that have been disassociated from their <a>owning element</a>
but are still <a lt="idle play state">idle</a> do not have a defined
composite order.
Note, this behavior relies on the fact that disassociating an animation
from its <a>owning element</a> always causes it to enter (or remain) in the
<a>idle play state</a>.
# Keyframes # {#keyframes}
For a given target (pseudo-)element, |element|, an animation name, |name|,
and the position of the animation in |element|'s 'animation-name' list,
|position|,
[=keyframe=] objects are generated as follows:
1. Let |default timing function| be
the timing function at position |position|
of the [=resolved value=] of the 'animation-timing-function' for |element|,
repeating the list as necessary as described in
[[CSS-ANIMATIONS-1#animation-name]].
1. Let |default composite| be ''replace''.
1. Find the last ''@keyframes'' at-rule in document order
with <<keyframes-name>> matching |name|.
If there is no ''@keyframes'' at-rule
with <<keyframes-name>> matching |name|,
abort this procedure.
In this case no animation is generated,
and any existing animation matching |name| is canceled.
1. Let |keyframes| be an empty sequence of [=keyframe=] objects.
1. Let |animated properties| be an empty set of longhand CSS property names.
1. Perform a stable sort of the keyframe blocks in the ''@keyframes'' rule
by the offset specified in the keyframe selector,
and iterate over the result in reverse
applying the following steps:
1. Let |keyframe offset| be the value of the keyframe selector
converted to a value in the range 0 ≤ |keyframe offset| ≤ 1.
1. Let |keyframe timing function| be the value of
the last valid declaration of 'animation-timing-function'
specified on the keyframe block, or,
if there is no such valid declaration, |default timing function|.
1. Let |keyframe composite| be the value of
the last valid declaration of 'animation-composition'
specified on the keyframe block, or,
if there is no such valid declaration, |default composite|.
1. After converting |keyframe timing function| to its canonical form
(e.g. such that ''step-end'' becomes ''steps(1, end)'')
let |keyframe| refer to the existing keyframe in |keyframes| with
matching keyframe offset, timing function and composite, if any.
If there is no such existing keyframe,
let |keyframe| be a new empty keyframe with
offset, |keyframe offset|,
timing function, |keyframe timing function|,
composite, |keyframe composite|,
and prepend it to |keyframes|.
1. Iterate over all declarations in the keyframe block and
add them to |keyframe| such that:
* Each shorthand property is expanded to its longhand
subproperties.
* All logical properties are converted to their
[[css-writing-modes-4#logical-to-physical|equivalent physical properties]].
* For any expanded physical longhand properties that appear more
than once,
only the last declaration in source order is added.
Note, since multiple keyframe blocks may specify the same
|keyframe offset|,
and since this algorithm iterates over these blocks in reverse,
this implies that if any properties are encountered that
have already added at this same |keyframe offset|,
they should be skipped.
1. Add each property name that was added to |keyframe|
to |animated properties|.
1. If there is no keyframe in |keyframes| with offset 0,
or if amongst the keyframes in |keyframes| with offset 0
not all of the properties in |animated properties| are present,
1. Let |initial keyframe| be the [=keyframe=] in |keyframes|
with offset 0, timing function |default timing function|
and composite |default composite|.
If there is no such keyframe,
let |initial keyframe| be a new empty keyframe with offset 0,
timing function |default timing function|,
composite |default composite,
and add it to |keyframes| after the last keyframe with offset 0.
1. For each property in |animated properties| that is not present
in some other keyframe with offset 0,
add the [=computed value=] of that property for |element|
to the keyframe.
1. Similarly, if there is no keyframe in |keyframes| with offset 1,
or if amongst the keyframes in |keyframes| with offset 1
not all of the properties in |animated properties| are present,
1. Let |final keyframe| be the [=keyframe=] in |keyframes|
with offset 1, timing function |default timing function|
and composite |default composite|.
If there is no such keyframe,
let |final keyframe| be a new empty keyframe with offset 1,
timing function |default timing function|
and composite |default composite|,
and add it to |keyframes| after the last keyframe with offset 1.
1. For each property in |animated properties| that is not present
in some other keyframe with offset 1,
add the [=computed value=] of that property for |element|
to the keyframe.
Issue: The above procedure requires iterating over keyframe blocks in reverse.
It could be rewritten so this is not required but that will likely change
the behavior for some edge cases.
We should verify what current implementations do and possible remove the
requirement to iterate in reverse.
## The 'animation-duration' property ## {#animation-duration}
The 'animation-duration' property specifies the [=iteration duration=]
of the animation's associated [=animation effect=].
## The 'animation-timing-function' property ## {#animation-timing-function}
The 'animation-timing-function' is used to determine the [=timing function=]
applied to each [=keyframe=] as defined in [[#keyframes]].
## The 'animation-iteration-count' property ## {#animation-iteration-count}
The 'animation-iteration-count' property specifies the [=iteration count=]
of the animation's associated [=animation effect=].
## The 'animation-direction' property ## {#animation-direction}
The 'animation-direction' property specifies the [=playback direction=]
of the animation's associated [=animation effect=].
## The 'animation-play-state' property ## {#animation-play-state}
The 'animation-play-state' is used to pause or play the animation.
If at any time,
including when the animation is first generated,
the resolved value of 'animation-play-state'
corresponding to an animation is newly ''running'',
the implementation must run the procedure to [=play an animation=]
for the given animation
with the <var ignore>auto-rewind flag</var> set to false.
If at any time,
including when the animation is first generated,
the resolved value of 'animation-play-state'
corresponding to an animation is newly ''paused'',
the implementation must run the procedure to [=pause an animation=]
for the given animation.
The above requirements do not apply
if the animation's play state is being overridden by the Web Animations API
as described in [[#animations]].
## The 'animation-delay' property ## {#animation-delay}
The 'animation-delay' property specifies the [=start delay=]
of the animation's associated [=animation effect=].
## The 'animation-fill-mode' property ## {#animation-fill-mode}
The 'animation-fill-mode' property specifies the [=fill mode=]
of the animation's associated [=animation effect=].
## The 'animation-composition' property ## {#animation-composition}
The 'animation-composition' property defines the <a>composite operation</a>
used when multiple animations affect the same property simultaneously.
<pre class='propdef'>
Name: animation-composition
Value: <<single-animation-composition>>#
Initial: replace
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: list, each item a keyword as specified
Animation type: not animatable
Canonical order: per grammar
</pre>
<span class=prod><dfn><single-animation-composition></dfn> = replace | add | accumulate</span>
The values of 'animation-composition' have the meaning defined for the
corresponding values of the <a>composite operation</a> defined in Web
Animations [[!WEB-ANIMATIONS]].
When specified in a keyframe, 'animation-composition' defines the composite
operation to use for each property specified in that keyframe until the next
keyframe specifying each property.
<div class='example'>
For example, the following stylesheet defines two different animations
targeting the 'scale' property.
<pre>
@keyframes heartbeat {
from {
scale: 1;
animation-timing-function: ease-out;
}
30% {
scale: 1.3;
}
}
.heartbeat {
animation: heartbeat 0.3s 2s infinite;
}
@keyframes throb {
50% {
scale: 1.8;
}
}
.icon:mouseover {
animation: throb 0.4s add;
}
</pre>
If these two animations are applied to the same element, normally only
one animation would apply, but by specifying ''add'' as the
'animation-composition' on the second animation, the result of the two
animations will be combined.
Since CSS Transitions [[CSS3-TRANSITIONS]] have a lower composite
order, it is possible to use 'animation-composition' to combine CSS
Animations with underlying transitions as in the following example.
<pre>
.icon {
filter: blur(20px);
transition: filter 0.5s;
}
.icon:hover {
filter: blur(0px);
animation: brightness-pulse 3s infinite add;
}
@keyframes brightness-pulse {
0% {
scale: 1.1;
filter: brightness(130%);
}
10% {
scale: 1;
filter: brightness(100%);
}
}
</pre>
Issue: Create pictures of these examples and verify they make sense.
</div>
## The 'animation-timeline' property ## {#animation-timeline}
The 'animation-timeline' property defines the <a>timeline</a> used with the
animation.
Note: This specification does not introduce any syntax to specify animation
timelines but instead it is up to others specifications such as Scroll-linked
Animations [[SCROLL-ANIMATIONS]] to do so.
<pre class='propdef'>
Name: animation-timeline
Value: <<single-animation-timeline>>#
Initial: auto
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: list, each item either a case-sensitive [=css identifier=] or
the keywords ''single-animation-timeline/none'',
''single-animation-timeline/auto''.
Canonical order: per grammar
Animatable: no
</pre>
<pre class=prod>
<dfn><single-animation-timeline></dfn> = auto | none | <<custom-ident>> | <<scroll()>> | <<view()>>
</pre>
The 'animation-timeline' property is similar to properties like 'animation-name'
and 'animation-duration' in that it can have one or more values, each one
imparting additional behavior to a corresponding [=animation=] on the element,
with the timelines matched up with animations as described
[[css-animations-1#animation-name|here]].
Each value has type <<single-animation-timeline>>, whose possible values have
the following effects:
<dl dfn-for="animation-timeline,<single-animation-timeline>" dfn-type=value>
: <dfn>auto</dfn>
:: The animation's [=timeline=] is a {{DocumentTimeline}}, more specifically
the <a>default document timeline</a>.
: <dfn>none</dfn>
:: The animation is not associated with a [=timeline=].
: <dfn><<custom-ident>></dfn>
:: If a named [=scroll progress timeline=] or [=view progress timeline=]
is in scope on this element,
use the referenced timeline
as defined in [[scroll-animations-1#timeline-scope]].
Otherwise the animation is not associated with a [=timeline=].
: <dfn><<scroll()>></dfn>
:: Use the [=scroll progress timeline=] indicated by the given ''scroll()'' function.
See [[scroll-animations-1#scroll-notation]].
: <dfn><<view()>></dfn>
:: Use the [=view progress timeline=] indicated by the given ''view()'' function.
See [[scroll-animations-1#view-notation]].
</dl>
Issue: Make it easier to use 'animation-name' to select the timeline when
'animation-timeline' is not specified. Allowing 'animation-name' to be used for
selecting timeline enables most common animations to have to use a single name
for both their keyframes and timeline which is simple and ergonomics. The
'animation-timeline' property gives authors additional control to independently
select keyframes and timeline if necessary.
## The 'animation' shorthand property ## {#animation-shorthand}
The 'animation' shorthand property syntax is as follows:
<span class=prod><dfn><single-animation></dfn> = <<time>> || <<easing-function>> || <<time>> || <<single-animation-iteration-count>> || <<single-animation-direction>> || <<single-animation-fill-mode>> || <<single-animation-play-state>> || [ none | <<keyframes-name>> ] || <<single-animation-timeline>></span>
# Animation Events # {#events}
## Event dispatch ## {#event-dispatch}
Note, this is a more general description of event dispatch than that of CSS
Animations Level 1 [[CSS3-ANIMATIONS]] since it must account for the
possibility of animations being seeked or reversed using the Web Animations API
[[WEB-ANIMATIONS]].
The [=event target|target=] for a CSS animation event is
the animation's [=owning element=].
If there is no [=owning element=], no CSS animation events are dispatched
(although the [=animation playback events=] defined in Web Animations are still
dispatched at the corresponding {{CSSAnimation}} object).
For the purpose of determining which events to dispatch, the
[[web-animations-1#animation-effect-phases-and-states|phases]] defined in
the Web Animations model are used. These definitions apply to an <a>animation
effect</a>, however, for the purpose of dispatching events, we consider a
CSS Animation to have the same phase as its [=associated effect=].
For example, a CSS Animation is in the [=animation effect/before phase=] if its
[=associated effect=] is in the [=animation effect/before phase=].
A CSS Animation that does not have an [=associated effect=]
is considered to be in the <a>idle phase</a>
if its [=animation/current time=] is <a>unresolved</a>, in the
[=animation effect/before phase=] if its <a>current time</a> is less than zero,
and in the [=animation effect/after phase=] otherwise.
Similarly, subsequent references to the <a>start delay</a>, <a>active
duration</a>, <a>current iteration</a>, <a>iteration start</a>, and
<a>iteration duration</a> of a CSS animation should be understood to refer
to the corresponding properties of the animation's [=associated effect=].
For calculating the {{AnimationEvent/elapsedTime}} of each event, the following
definitions are used:
* <dfn>interval start</dfn> =
<code>max(min(-<a>start delay</a>, <a>active duration</a>), 0)</code>
* <dfn>interval end</dfn> =
<code>max(min([=associated effect end=] - <a>start delay</a>,
<a>active duration</a>), 0)</code>
Each time a new [=animation frame=] is established and the animation does
<em>not</em> have a [=pending play task=] or [=pending pause task=],
the events to dispatch are determined by
comparing the animation's phase before and after establishing the new
[=animation frame=] as follows:
<table class="event-state-transitions">
<thead>
<tr>
<th>Change</th>
<th>Events dispatched</th>
<th><dfn>Elapsed time</dfn> (ms)</th>
</tr>
</thead>
<tbody>
<tr>
<td>[=animation effect/idle phase|idle=] or
[=animation effect/before phase|before=] →
[=animation effect/active phase|active=]</td>
<td>{{animationstart}}</td>
<td><a>interval start</a>
</td>
</tr>
<tr>
<td rowspan="2">
[=animation effect/idle phase|idle=] or
[=animation effect/before phase|before=] →
[=animation effect/after phase|after=] <a
href="#multiple-events-note">٭</a></td>
<td>{{animationstart}}</td>
<td><a>interval start</a>
</td>
</tr>
<tr>
<td>{{animationend}}</td>
<td><a>interval end</a>
</td>
</tr>
<tr>
<td>[=animation effect/active phase|active=] →
[=animation effect/before phase|before=]</td>
<td>{{animationend}}</td>
<td><a>interval start</a></td>
</tr>
<tr>
<td>[=animation effect/active phase|active=] →
[=animation effect/active phase|active=]
<em>and</em>
the <a>current iteration</a> of the animation's [=associated effect=]
has changed since the previous animation frame
</td>
<td>{{animationiteration}}</td>
<td>(See below)
<a href="#animation-iteration-elapsed-time">†</a></td>
</tr>
<tr>
<td>[=animation effect/active phase|active=] →
[=animation effect/after phase|after=]</td>
<td>{{animationend}}</td>
<td><a>interval end</a></td>
</tr>
<tr>
<td>[=animation effect/after phase|after=] →
[=animation effect/active phase|active=]</td>
<td>{{animationstart}}</td>
<td><a>interval end</a></td>
</tr>
<tr>
<td rowspan="2">[=animation effect/after phase|after=] →
[=animation effect/before phase|before=] <a
href="#multiple-events-note">٭</a></td>
<td>{{animationstart}}</td>
<td><a>interval end</a></td>
</tr>
<tr>
<td>{{animationend}}</td>
<td><a>interval start</a></td>
</tr>
<tr>
<td><em>not</em> [=animation effect/idle phase|idle=] and <em>not</em>
[=animation effect/after phase|after=] →
[=animation effect/idle phase|idle=]</td>
<td>{{animationcancel}}</td>
<td>The <a>active time</a> of the animation at the moment it was cancelled
calculated using a <a>fill mode</a> of both.</td>
</tr>
</tbody>
</table>
<p id="multiple-events-note">٭ Where multiple events are listed for
a state change, all events are dispatched in the order listed and in immediate
succession.</p>
<p id="animation-iteration-elapsed-time">† The <a>elapsed time</a> for
an {{animationiteration}} event is defined as follows:</p>
1. Let <var>previous current iteration</var> be the <a>current iteration</a>
from the previous animation frame.
1. If <var>previous current iteration</var> is greater than <a>current
iteration</a>, let <var>iteration boundary</var> be <code><a>current
iteration</a> + 1</code>, otherwise let it be <a>current iteration</a>.
1. The <a>elapsed time</a> is the result of evaluating
<code>(<var>iteration boundary</var> - <a>iteration start</a>) ×
<a>iteration duration</a>)</code>.
Since the <a>elapsed time</a> defined in the table and procedure above is
expressed in milliseconds, it must be divided by 1,000 to produce a value in
seconds before being assigned to the {{AnimationEvent/elapsedTime}} member of
the {{AnimationEvent}}.
# DOM Interfaces # {#interface-dom}
## The CSSAnimation interface ## {#the-CSSAnimation-interface}
<pre class="idl">
[Exposed=Window]
interface CSSAnimation : Animation {
readonly attribute CSSOMString animationName;
};
</pre>
: <dfn attribute for=CSSAnimation>animationName</dfn>
:: The key used to find matching keyframes rules that define the
[=associated effect=] at the point when the animation was created.
This is the value of the 'animation-name' property that caused this
object to be generated.
## Requirements on pending style changes ## {#requirements-on-pending-style-changes}
Various operations may affect the <a lt="computed value">computed values</a> of
properties on elements. User agents may, as an optimization, defer recomputing
these values until it becomes necessary.
However, all operations included in programming interface defined in this
specification, as well as those operations defined in Web Animations
[[!WEB-ANIMATIONS]] that may return objects or animation state defined by this
specification, must produce a result consistent with having fully processed
any such pending changes to computed values.
<div class="note">
As an example, in the following code fragment, when the specified style of
<code>elem</code> is initially updated, a user agent may defer recalculating
the computed value of the 'animation' property.
However, the {{Animatable/getAnimations()}} method called on <code>elem</code>
is specified by Web Animations and can return {{CSSAnimation}} objects as
defined in this specification.
Hence, as result of the requirements in this section, the user agent must
calculate the updated value of <code>elem</code>'s 'animation' property and
create the requested {{CSSAnimation}} object before returning its result.
<div><pre class="example lang-javascript">
elem.style.animation = 'fadeOut 1s';
elem.getAnimations()[0].pause();
</pre></div>
Similarly, reading {{Animation/playState}} may depend on pending style
changes.
<div><pre class="example lang-javascript">
elem.style.animation = 'fadeOut 1s paused';
const anim = elem.getAnimations()[0];
elem.style.animationPlayState = 'running';
console.log(anim.playState); // Should be 'running'.
</pre></div>
</div>
<h2 id="priv-sec">
Privacy and Security Considerations</h2>
This specification introduces no new privacy or security considerations.