-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.bs
More file actions
691 lines (563 loc) · 28.5 KB
/
Overview.bs
File metadata and controls
691 lines (563 loc) · 28.5 KB
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
<h1>CSS Animations Level 1</h1>
<pre class='metadata'>
Status: ED
Shortname: css-animations
Level: 1
Group: csswg
TR: http://www.w3.org/TR/css3-animations/
ED: http://dev.w3.org/csswg/css3-animations/
Previous Version: http://www.w3.org/TR/2013/WD-css3-animations-20130219/
Previous Version: http://www.w3.org/TR/2012/WD-css3-animations-20120403/
Editor: Dean Jackson, Apple Inc., dino@apple.com
Editor: L. David Baron, Mozilla, dbaron@dbaron.org
Editor: Sylvain Galineau, Adobe, galineau@adobe.com
Former Editor: David Hyatt, Apple Inc.
Former Editor: Chris Marrin, Apple Inc.
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 Terms: domstring, float, animationeventinit, eventinit, eventtarget, document
</pre>
<h2 id="intro">
Introduction</h2>
<em>This section is not normative</em>
CSS Transitions [[CSS3-TRANSITIONS]] provide a way to interpolate
CSS property values when they change as a result of underlying
property changes. This provides an easy way to do simple animation,
but the start and end states of the animation are controlled by the
existing property values, and transitions provide little control to
the author on how the animation progresses.
This proposal introduces defined animations, in which the author can
specify the changes in CSS properties over time as a set of keyframes.
Animations are similar to transitions in that they change the
presentational value of CSS properties over time. The principal difference
is that while transitions trigger implicitly when property values change,
animations are explicitly executed when the animation properties are applied.
Because of this, animations require explicit values for the properties
being animated. These values are specified using animation keyframes,
described below.
Many aspects of the animation can be controlled, including how many times
the animation iterates, whether or not it alternates between the begin and
end values, and whether or not the animation should be running or paused.
An animation can also delay its start time.
<h2 id="values">
Values</h2>
This specification follows the CSS property definition conventions
from [[!CSS21]]. Value types not defined in this specification are
defined in CSS Level 2 Revision 1 [[!CSS21]]. Other CSS modules may
expand the definitions of these value types: for example [[!CSS3VAL]],
when combined with this module, expands the definition of the
<length> value type as used in this specification.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the ‘initial’
and ‘inherit’ keyword as their property value. For readability it has
not been repeated explicitly.
<h2 id="animations">
Animations</h2>
CSS Animations affect computed property values. This effect happens by
adding a specified value to the CSS cascade ([[!CSS3CASCADE]]) (at the
level for CSS Animations) that will produce the correct computed value
for the current state of the animation. As defined in [[!CSS3CASCADE]],
animations override all normal rules, but are overridden by !important
rules.
If at one point in time there are multiple animations specifying behavior
for the same property, the animation whose name occurs last in the value
of ‘animation-name’ will override the other animations at that point.
An animation does not affect the computed value before the application of
the animation, before the animation delay has expired, and after the end of
the animation.
<figure>
<img src="./sandwich.png" alt="">
<figcaption>Computation of animated property values</figcaption>
</figure>
The diagram above shows how property values are computed. The intrinsic
style is shown at the top of the diagram. The computed value is derived
from intrinsic style at the times when an animation is not running and
also when an animation is delayed (see below for specification of animation
delay). During an animation, the computed style is derived from the
animated value.
The start time of an animation is the latter of two moments: the time at
which the style is resolved that specifies the animation, or the time the
document's load event is fired. Therefore, an animation specified in the
document style sheet will begin at the document load. An animation specified
on an element by modifying the style after the document has loaded will start
when the style is resolved. That may be immediately in the case of a pseudo
style rule such as hover, or may be when the scripting engine returns control
to the browser (in the case of style applied by script).
An animation applies to an element if its name appears as one of the
identifiers in the computed value of the 'animation-name' property. Once an
animation has started it continues until it ends or the 'animation-name' is
removed. The values used for the keyframes and animation properties are
snapshotted at the time the animation starts. Changing them during the
execution of the animation has no effect. Note also that changing the value
of 'animation-name' does not necessarily restart an animation (e.g., if a list
of animations are applied and one is removed from the list, only that animation
will stop; The other animations will continue). In order to restart an animation,
it must be removed then reapplied.
The end of the animation is defined by the combination of the
'animation-duration', 'animation-iteration-count' and 'animation-fill-mode'
properties.
<div class='example'>
<pre>
div {
animation-name: diagonal-slide;
animation-duration: 5s;
animation-iteration-count: 10;
}
@keyframes diagonal-slide {
from {
left: 0;
top: 0;
}
to {
left: 100px;
top: 100px;
}
}
</pre>
This will produce an animation that moves an element from (0, 0) to
(100px, 100px) over five seconds and repeats itself nine times
(for a total of ten iterations).
</div>
Setting the display property to ''none'' will terminate any running animation applied
to the element and its descendants. If an element has a display of ''none'', updating
display to a value other than ''none'' will start all animations applied to the element
by the 'animation-name' property, as well as all animations applied to descendants
with display other than ''none''.
While authors can use animations to create dynamically changing content, dynamically
changing content can lead to seizures in some users. For information on how to avoid
content that can lead to seizures, see Guideline 2.3: Seizures: Do not design content
in a way that is known to cause seizures ([[!WCAG20]]).
<h2 id="keyframes">
Keyframes</h2>
Keyframes are used to specify the values for the animating properties at various points
during the animation. The keyframes specify the behavior of one cycle of the animation;
the animation may iterate one or more times.
Keyframes are specified using a specialized CSS at-rule. A @keyframes rule consists of the
keyword "@keyframes", followed by an identifier giving a name for the animation (which will
be referenced using 'animation-name'), followed by a set of style rules (delimited by curly
braces).
The keyframe selector for a keyframe style rule consists of a comma-separated list of
percentage values or the keywords ‘from’ or ‘to’. The selector is used to specify the
percentage along the duration of the animation that the keyframe represents. The keyframe
itself is specified by the block of property values declared on the selector. The keyword
‘from’ is equivalent to the value ‘0%’. The keyword ‘to’ is equivalent to the value ‘100%’.
<span class="note">Note that the percentage unit specifier must be used on percentage values.
Therefore, ‘0’ is an invalid keyframe selector.</span>
If a 0% or ''from'' keyframe is not specified, then the user agent constructs a 0% keyframe
using the computed values of the properties being animated. If a 100% or ''to'' keyframe is not
specified, then the user agent constructs a 100% keyframe using the computed values of the
properties being animated. If a keyframe selector specifies negative percentage values or values
higher than 100%, then the keyframe will be ignored.
The keyframe declaration block for a keyframe rule consists of properties and values. Properties
that are unable to be animated are ignored in these rules, with the exception of
'animation-timing-function', the behavior of which is described below. In addition, keyframe rule
declarations qualified with !important are ignored.
Issue: Need to describe what happens if a property is not present in all keyframes.
The @keyframes rule that is used by an animation will be the last one encountered in sorted rules
order that matches the name of the animation specified by the 'animation-name' property. @keyframes
rules do not cascade; therefore, an animation will never derive keyframes from more than one
@keyframes rule.
Note: Note that since empty @keyframes rule are valid, they may hide the keyframes of those
preceding animation definitions with a matching name.
To determine the set of keyframes, all of the values in the selectors are sorted in increasing order
by time. If there are any duplicates, then the last keyframe specified inside the @keyframes rule
will be used to provide the keyframe information for that time. There is no cascading within a
@keyframes rule if multiple keyframes specify the same keyframe selector values.
If a property is not specified for a keyframe, or is specified but invalid, the animation of that
property proceeds as if that keyframe did not exist. Conceptually, it is as if a set of keyframes is
constructed for each property that is present in any of the keyframes, and an animation is run
independently for each property.
<div class='example'>
<pre>
@keyframes wobble {
0% {
left: 100px;
}
40% {
left: 150px;
}
60% {
left: 75px;
}
100% {
left: 100px;
}
}
</pre>
Four keyframes are specified for the animation named "wobble". In the first keyframe,
shown at the beginning of the animation cycle, the value of the 'left' property being
animated is 100px. By 40% of the animation duration, 'left' has animated to 150px.
At 60% of the animation duration, 'left' has animated back to 75px. At the end of the
animation cycle, the value of 'left' has returned to 100px. The diagram below shows
the state of the animation if it were given a duration of 10s.
<figure>
<img src="./animation1.png" alt="">
<figcaption>Animation states specified by keyframes</figcaption>
</figure>
</div>
The following is the grammar for the keyframes rule:
<pre>
keyframes_rule: KEYFRAMES_SYM S+ IDENT S* '{' S* keyframes_blocks '}' S*;
keyframes_blocks: [ keyframe_selector '{' S* declaration? [ ';' S* declaration? ]* '}' S* ]* ;
keyframe_selector: [ FROM_SYM | TO_SYM | PERCENTAGE ] S* [ ',' S* [ FROM_SYM | TO_SYM | PERCENTAGE ] S* ]*;
@{K}{E}{Y}{F}{R}{A}{M}{E}{S} {return KEYFRAMES_SYM;}
{F}{R}{O}{M} {return FROM_SYM;}
{T}{O} {return TO_SYM;}
</pre>
<h3 id="timing-funtions">
Timing functions for keyframes</h3>
A keyframe style rule may also declare the timing function that is to be used as the animation
moves to the next keyframe.
<div class='example'>
<pre>
@keyframes bounce {
from {
top: 100px;
animation-timing-function: ease-out;
}
25% {
top: 50px;
animation-timing-function: ease-in;
}
50% {
top: 100px;
animation-timing-function: ease-out;
}
75% {
top: 75px;
animation-timing-function: ease-in;
}
to {
top: 100px;
}
}
</pre>
Five keyframes are specified for the animation named "bounce". Between the first and second
keyframe (i.e., between 0% and 25%) an ease-out timing function is used. Between the second
and third keyframe (i.e., between 25% and 50%) an ease-in timing function is used. And so on.
The effect will appear as an element that moves up the page 50px, slowing down as it reaches
its highest point then speeding up as it falls back to 100px. The second half of the animation
behaves in a similar manner, but only moves the element 25px up the page.
</div>
<h3 id="animation-name">
The 'animation-name' property</h3>
<pre class='propdef'>
Name: animation-name
Value: <<single-animation-name>> [',' <<single-animation-name>>]*
Initial: none
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: none
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation-name></dfn> = none | <<IDENT>>
<h3 id="animation-duration">
The 'animation-duration' property</h3>
The ‘animation-duration’ property defines the length of time that an animation takes to
complete one cycle.
<pre class='propdef'>
Name: animation-duration
Value: <<time>> [, <<time>>]*
Initial: 0s
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
The initial value is 0s, meaning that the animation takes no time. When the duration is 0s
'animation-fill-mode' still applies, so an animation that fills backwards will show the value of
the 0% keyframe during any delay period, and an animation that fills forwards will retain the
value specified at the 100% keyframe, even if the animation was instantaneous. Also, animation
events are still fired. A negative 'animation-duration' value renders the declaration invalid.
<h3 id="animation-timing-function">
The 'animation-timing-function' property</h3>
The 'animation-timing-function' property describes how the animation will progress over
one cycle of its duration. See the ‘transition-timing-function’ property [[!CSS3-TRANSITIONS]]
for a complete description of timing function calculation.
<pre class='propdef'>
Name: animation-timing-function
Value: <<single-timing-function>> [ ‘,’ <<single-timing-function>> ]*
Initial: ease
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
All the valid values of <dfn><single-timing-function></dfn> are defined by the 'transition-timing-function'
property [[!CSS3-TRANSITIONS]].
For a keyframed animation, the 'animation-timing-function' applies between keyframes, not over the
entire animation. For example, in the case of an ease-in-out timing function, an animation will
ease in at the start of the keyframe and ease out at the end of the keyframe. An 'animation-timing-function'
defined within a keyframe block applies to that keyframe, otherwise the timing function specified for
the animation is used. In addition, only the first value of the property applies when it is used in
a keyframe block.
<h3 id="animation-iteration-count">
The 'animation-iteration-count' property</h3>
The 'animation-iteration-count' property specifies the number of times an animation cycle
is played. The initial value is 1, meaning the animation will play from beginning to end
once. A value of ''infinite'' will cause the animation to repeat forever. Non-integer numbers
will cause the animation to end part-way through a cycle. Negative values of
'animation-iteration-count' are invalid. This property is often used in conjunction an
'animation-direction' value of ‘alternate’, which will cause the animation to play in
reverse on alternate cycles.
<pre class='propdef'>
Name: animation-iteration-count
Value: <<single-animation-iteration-count>> [ ‘,’ <<single-animation-iteration-count>> ]*
Initial: 1
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation-iteration-count></dfn> = infinite | <<number>>
<h3 id="animation-direction">
The 'animation-direction' property</h3>
The 'animation-direction' property defines whether or not the animation should play in reverse
on some or all cycles. When an animation is played in reverse the timing functions are also
reversed. For example, when played in reverse an ease-in animation would appear to be an
ease-out animation.
<pre class='propdef'>
Name: animation-direction
Value: <<single-animation-direction>> [ ‘,’ <<single-animation-direction>> ]*
Initial: normal
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation-direction></dfn> = normal | reverse | alternate | alternate-reverse
<dl dfn-type=value dfn-for=animation-direction>
<dt><dfn>normal</dfn>
<dd>
All iterations of the animation are played as specified.
<dt><dfn>reverse</dfn>
<dd>
All iterations of the animation are played in the reverse direction
from the way they were specified.
<dt><dfn>alternate</dfn>
<dd>
The animation cycle iterations that are odd counts are played in the
normal direction, and the animation cycle iterations that are even
counts are played in a reverse direction.
<dt><dfn>alternate-reverse</dfn>
<dd>
The animation cycle iterations that are odd counts are played in the
reverse direction, and the animation cycle iterations that are even
counts are played in a normal direction.
</dl>
Note: Note that for the purpose of determining whether an iteration is even or odd,
iterations start counting from 1.
<h3 id="animation-play-state">
The 'animation-play-state' property</h3>
The 'animation-play-state' property defines whether the animation is running or paused.
A running animation can be paused by setting this property to ''paused''. To continue
running a paused animation this property can be set to ''running''. A paused animation will
continue to display the current value of the animation in a static state, as if the time
of the animation is constant. When a paused animation is resumed, it restarts from the
current value, not necessarily from the beginning of the animation.
<pre class='propdef'>
Name: animation-play-state
Value: <<single-animation-play-state>> [ , <<single-animation-play-state>> ]*
Initial: running
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation-play-state></dfn> = running | paused
<h3 id="animation-delay">
The 'animation-delay' property</h3>
The 'animation-delay' property defines when the animation will start. It allows an animation
to begin execution some time after it is applied. An 'animation-delay' value of ‘0s’ means
the animation will execute as soon as it is applied. Otherwise, the value specifies an offset
from the moment the animation is applied, and the animation will delay execution by that offset.
If the value for 'animation-delay' is a negative time offset then the animation will execute the
moment it is applied, but will appear to have begun execution at the specified offset. That is,
the animation will appear to begin part-way through its play cycle. In the case where an animation
has implied starting values and a negative 'animation-delay', the starting values are taken from
the moment the animation is applied.
<pre class='propdef'>
Name: animation-delay
Value: <<time>> [ , <<time>>]*
Initial: 0s
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<h3 id="animation-fill-mode">
The 'animation-fill-mode' property</h3>
The 'animation-fill-mode' property defines what values are applied by the animation
outside the time it is executing. By default, an animation will not affect property
values between the time it is applied (the ‘animation-name’ property is set on an
element) and the time it begins execution (which is determined by the 'animation-delay'
property). Also, by default an animation does not affect property values after the
animation ends (determined by the 'animation-duration' property). The 'animation-fill-mode'
property can override this behavior.
If the value for 'animation-fill-mode' is ''backwards'', then the animation will apply
the property values defined in the keyframe that will start the first iteration of the
animation, during the period defined by 'animation-delay'. These are either the values
of the ‘from’ keyframe (when 'animation-direction' is ''normal'' or ''alternate'') or
those of the ‘to’ keyframe (when 'animation-direction' is ''reverse'' or
''alternate-reverse'').
If the value for 'animation-fill-mode' is ''forwards'', then after the animation ends (as
determined by its 'animation-iteration-count'), the animation will apply the property values
for the time the animation ended. When 'animation-iteration-count' is an integer greater than
zero, the values applied will be those for the end of the last completed iteration of the
animation (rather than the values for the start of the iteration that would be next). When
'animation-iteration-count' is zero, the values applied will be those that would start the
first iteration (just as when 'animation-fill-mode' is ''backwards'').
If the value for 'animation-fill-mode' is ''both'', then the animation will follow the rules
for both ''forwards'' and ''backwards''. That is, it will extend the animation in both directions.
<pre class='propdef'>
Name: animation-fill-mode
Value: <<single-animation-fill-mode>> [ , <<single-animation-fill-mode>> ]*
Initial: none
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation-fill-mode></dfn> = none | forwards | backwards | both
<h3 id="animation">
The 'animation' shorthand property</h3>
The 'animation' shorthand property is a comma-separated list of animation definitions. Each item in
the list gives one item of the value for all of the subproperties of the shorthand, which are known
as the animation properties. (See the definition of 'animation-name' for what happens when these
properties have lists of different lengths, a problem that cannot occur when they are defined using
only the 'animation' shorthand.)
<pre class='propdef'>
Name: animation
Value: <<single-animation>> [ , <<single-animation>> ]*
Initial: see individual properties
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no
Animatable: no
Percentages: N/A
Media: visual
Computed value: As specified
Canonical order: per grammar
</pre>
<dfn><single-animation></dfn> = <<time>> || <<single-timing-function>> || <<time>> || <<single-animation-iteration-count>> || <<single-animation-direction>> || <<single-animation-fill-mode>> || <<single-animation-play-state>> || <<single-animation-name>>
Note that order is important within each animation definition: the first value in each
<<single-animation>> that can be parsed as a <<time>> is assigned to the 'animation-duration',
and the second value in each <<single-animation>> that can be parsed as a <time> is assigned to
'animation-delay'.
Note that order is also important within each animation definition for distinguishing
<<single-animation-name>> values from other keywords. When parsing, keywords that are valid for
properties other than 'animation-name' must be accepted for those properties rather than for
'animation-name'. Furthermore, when serializing, default values of other properties must be
output in at least the cases necessary to distinguish an 'animation-name' that could
be a value of another property, and may be output in additional cases.
<h2 id="events">
Animation Events</h2>
Several animation-related events are available through the DOM Event system. The start and
end of an animation, and the end of each iteration of an animation, all generate DOM events.
An element can have multiple properties being animated simultaneously. This can occur either
with a single 'animation-name' value with keyframes containing multiple properties, or with
multiple 'animation-name' values. For the purposes of events, each 'animation-name' specifies
a single animation. Therefore an event will be generated for each 'animation-name' value and
not necessarily for each property being animated.
Any animation for which both a valid keyframe rule and a non-zero duration are defined will run
and generate events; this includes animations with empty keyframe rules.
The time the animation has been running is sent with each event generated. This allows the event
handler to determine the current iteration of a looping animation or the current position of an
alternating animation. This time does not include any time the animation was in the ''paused''
play state.
<h3 id="interface-animationevent">
The <code>AnimationEvent</code> Interface</h3>
The <dfn>AnimationEvent</dfn> interface provides specific contextual information associated with
Animation events.
<h4 id="interface-animationevent-idl">
IDL Definition</h4>
<pre class="idl">
[Constructor(DOMString type, optional AnimationEventInit animationEventInitDict)]
interface AnimationEvent : Event {
readonly attribute DOMString animationName;
readonly attribute float elapsedTime;
readonly attribute DOMString pseudoElement;
};
dictionary AnimationEventInit : EventInit {
DOMString animationName = "";
float elapsedTime = 0.0;
DOMString pseudoElement = "";
};
</pre>
<h4 id="interface-animationevent-attributes">
Attributes</h4>
<dl dfn-type=attribute dfn-for=animationevent>
<dt><dfn>animationName</dfn>, of type <a interface>DOMString</a>, readonly
<dd>
The value of the 'animation-name' property of the animation that fired the event.
<dt><dfn>elapsedTime</dfn>, of type <a interface>float</a>, readonly
<dd>
The amount of time the animation has been running, in seconds, when this event fired,
excluding any time the animation was paused. For an ''animationstart'' event, the
elapsedTime is zero unless there was a negative value for 'animation-delay', in which
case the event will be fired with an elapsedTime of (-1 * delay).
<dt><dfn>pseudoElement</dfn>, of type <a interface>DOMString</a>, readonly
<dd>
The name (beginning with two colons) of the CSS pseudo-element on which the animation
runs (in which case the target of the event is that pseudo-element's corresponding
element), or the empty string if the animation runs on an element (which means the
target of the event is that element).
</dl>
<dfn>AnimationEvent(type, animationEventInitDict)</dfn> is an <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events">event constructor</a>.
<h3 id="event-animationevent">
Types of <code>AnimationEvent</code></h3>
The different types of animation events that can occur are:
<dl dfn-type=enum>
<dt><dfn>animationstart</dfn>
<dd>
The ''animationstart'' event occurs at the start of the animation. If there is an
'animation-delay' then this event will fire once the delay period has expired.
A negative delay will cause the event to fire with an elapsedTime equal to the
absolute value of the delay.
<ul>
<li>Bubbles: Yes</li>
<li>Cancelable: No</li>
<li>Context Info: animationName, pseudoElement</li>
</ul>
<dt><dfn>animationend</dfn>
<dd>
The ''animationend'' event occurs when the animation finishes.
<ul>
<li>Bubbles: Yes</li>
<li>Cancelable: No</li>
<li>Context Info: animationName, elapsedTime, pseudoElement</li>
</ul>
<dt><dfn>animationiteration</dfn>
<dd>
The ''animationiteration'' event occurs at the end of each iteration of an
animation, except when an animationend event would fire at the same time.
This means that this event does not occur for animations with an iteration
count of one or less.
<ul>
<li>Bubbles: Yes</li>
<li>Cancelable: No</li>
<li>Context Info: animationName, elapsedTime, pseudoElement</li>
</ul>
</dl>