-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.html
1748 lines (1710 loc) · 137 KB
/
Overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Animations Level 1</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="refining" name="csswg-work-status">
<meta content="ED" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background-image: url("https://www.w3.org/StyleSheets/TR/logo-ED");
};
</style>
<meta content="Bikeshed 1.0.0" name="generator">
<script defer="" src="//test.csswg.org/harness/annotate.js#css-animations-1_dev/css-animations-1" type="text/javascript"></script>
<style type="text/css">
table.event-handlers {
border-collapse: collapse;
}
table.event-handlers th,
table.event-handlers td {
padding: 0.2em 1em;
}
table.event-handlers td {
border: 1px solid black;
}
</style>
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">CSS Animations Level 1</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2016-01-31">31 January 2016</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://drafts.csswg.org/css-animations/">https://drafts.csswg.org/css-animations/</a>
<dt>Latest version:
<dd><a href="https://www.w3.org/TR/css3-animations/">https://www.w3.org/TR/css3-animations/</a>
<dt>Previous Versions:
<dd><a href="https://www.w3.org/TR/2013/WD-css3-animations-20130219/" rel="previous">https://www.w3.org/TR/2013/WD-css3-animations-20130219/</a>
<dd><a href="https://www.w3.org/TR/2012/WD-css3-animations-20120403/" rel="previous">https://www.w3.org/TR/2012/WD-css3-animations-20120403/</a>
<dt>Feedback:
<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-animations%5D%20YOUR%20TOPIC%20HERE">www-style@w3.org</a> with subject line “<kbd>[css-animations] <i data-lt="">… message topic …</i></kbd>” (<a href="http://lists.w3.org/Archives/Public/www-style/" rel="discussion">archives</a>)</span>
<dt>Test Suite:
<dd><a href="http://test.csswg.org/suites/css-animations-1_dev/nightly-unstable/">http://test.csswg.org/suites/css-animations-1_dev/nightly-unstable/</a>
<dt>Issue Tracking:
<dd><a href="#issues-index">Inline In Spec</a>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:dino@apple.com">Dean Jackson</a> (<span class="p-org org">Apple Inc.</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-url url" href="http://dbaron.org/">L. David Baron</a> (<span class="p-org org">Mozilla</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-url url" href="http://xanthir.com/contact/">Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:bbirtles@mozilla.com">Brian Birtles</a> (<span class="p-org org">Mozilla Japan</span>)
<dt class="editor">Former Editors:
<dd class="editor p-author h-card vcard"><span class="p-name fn">David Hyatt</span> (<span class="p-org org">Apple Inc.</span>)
<dd class="editor p-author h-card vcard"><span class="p-name fn">Chris Marrin</span> (<span class="p-org org">Apple Inc.</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:galineau@adobe.com">Sylvain Galineau</a> (<span class="p-org org">Adobe</span>)
<dt>Issues List:
<dd><span><a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=Animations&list_id=36653&product=CSS&query_format=advanced&resolution=---">In Bugzilla</a></span>
<dd><span></span>
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2016 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply. </p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>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.</p>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.
</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p> This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress. </p>
<p> The (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list <a href="mailto:www-style@w3.org?Subject=%5Bcss-animations%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a> (see <a href="http://www.w3.org/Mail/Request">instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-animations” in the subject,
preferably like this:
“[css-animations] <em>…summary of comment…</em>” </p>
<p> This document was produced by the <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of the <a href="http://www.w3.org/Style/">Style Activity</a>). </p>
<p> This document was produced by a group operating under
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
<p> This document is governed by the <a href="http://www.w3.org/2015/Process-20150901/" id="w3c_process_revision">1 September 2015 W3C Process Document</a>. </p>
<p></p>
</div>
<div data-fill-with="at-risk">
<p>The following features are at-risk, and may be dropped during the CR period: </p>
<ul>
<li>the <code>pseudoElement</code> property of the <span class="css">AnimationEvent</span> interface
<li>
</ul>
<p>“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulting being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.</p>
</div>
<nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content"> Introduction</span></a>
<li><a href="#values"><span class="secno">2</span> <span class="content"> Values</span></a>
<li><a href="#animations"><span class="secno">3</span> <span class="content"> Animations</span></a>
<li>
<a href="#keyframes"><span class="secno">4</span> <span class="content"> Keyframes</span></a>
<ol class="toc">
<li><a href="#timing-functions"><span class="secno">4.1</span> <span class="content"> Timing functions for keyframes</span></a>
<li><a href="#animation-name"><span class="secno">4.2</span> <span class="content"> The <span class="property">animation-name</span> property</span></a>
<li><a href="#animation-duration"><span class="secno">4.3</span> <span class="content"> The <span class="property">animation-duration</span> property</span></a>
<li><a href="#animation-timing-function"><span class="secno">4.4</span> <span class="content"> The <span class="property">animation-timing-function</span> property</span></a>
<li><a href="#animation-iteration-count"><span class="secno">4.5</span> <span class="content"> The <span class="property">animation-iteration-count</span> property</span></a>
<li><a href="#animation-direction"><span class="secno">4.6</span> <span class="content"> The <span class="property">animation-direction</span> property</span></a>
<li><a href="#animation-play-state"><span class="secno">4.7</span> <span class="content"> The <span class="property">animation-play-state</span> property</span></a>
<li><a href="#animation-delay"><span class="secno">4.8</span> <span class="content"> The <span class="property">animation-delay</span> property</span></a>
<li><a href="#animation-fill-mode"><span class="secno">4.9</span> <span class="content"> The <span class="property">animation-fill-mode</span> property</span></a>
<li><a href="#animation"><span class="secno">4.10</span> <span class="content"> The <span class="property">animation</span> shorthand property</span></a>
</ol>
<li>
<a href="#events"><span class="secno">5</span> <span class="content"> Animation Events</span></a>
<ol class="toc">
<li>
<a href="#interface-animationevent"><span class="secno">5.1</span> <span class="content"> The <code>AnimationEvent</code> Interface</span></a>
<ol class="toc">
<li><a href="#interface-animationevent-idl"><span class="secno">5.1.1</span> <span class="content"> IDL Definition</span></a>
<li><a href="#interface-animationevent-attributes"><span class="secno">5.1.2</span> <span class="content"> Attributes</span></a>
</ol>
<li>
<a href="#event-animationevent"><span class="secno">5.2</span> <span class="content"> Types of <code>AnimationEvent</code></span></a>
<ol class="toc">
<li><a href="#event-handlers-on-elements-document-objects-and-window-objects"><span class="secno">5.2.1</span> <span class="content">Event handlers on elements, <code>Document</code> objects, and <code>Window</code> objects</span></a>
</ol>
</ol>
<li>
<a href="#interface-dom"><span class="secno">6</span> <span class="content"> DOM Interfaces</span></a>
<ol class="toc">
<li>
<a href="#interface-cssrule"><span class="secno">6.1</span> <span class="content"> The <code>CSSRule</code> Interface</span></a>
<ol class="toc">
<li><a href="#interface-cssrule-idl"><span class="secno">6.1.1</span> <span class="content"> IDL Definition</span></a>
</ol>
<li>
<a href="#interface-csskeyframerule"><span class="secno">6.2</span> <span class="content"> The <code>CSSKeyframeRule</code> Interface</span></a>
<ol class="toc">
<li><a href="#interface-csskeyframerule-idl"><span class="secno">6.2.1</span> <span class="content"> IDL Definition</span></a>
<li><a href="#interface-csskeyframerule-attributes"><span class="secno">6.2.2</span> <span class="content"> Attributes</span></a>
</ol>
<li>
<a href="#interface-csskeyframesrule"><span class="secno">6.3</span> <span class="content"> The <code>CSSKeyframesRule</code> Interface</span></a>
<ol class="toc">
<li><a href="#interface-csskeyframesrule-idl"><span class="secno">6.3.1</span> <span class="content"> IDL Definition</span></a>
<li><a href="#interface-csskeyframesrule-attributes"><span class="secno">6.3.2</span> <span class="content"> Attributes</span></a>
<li><a href="#interface-csskeyframesrule-appendrule"><span class="secno">6.3.3</span> <span class="content"> The <code>appendRule</code> method</span></a>
<li><a href="#interface-csskeyframesrule-deleterule"><span class="secno">6.3.4</span> <span class="content"> The <code>deleteRule</code> method</span></a>
<li><a href="#interface-csskeyframesrule-findrule"><span class="secno">6.3.5</span> <span class="content"> The <code>findRule</code> method</span></a>
</ol>
<li>
<a href="#interface-globaleventhandlers"><span class="secno">6.4</span> <span class="content"> Extensions to the <code>GlobalEventHandlers</code> Interface</span></a>
<ol class="toc">
<li><a href="#interface-globaleventhandlers-idl"><span class="secno">6.4.1</span> <span class="content"> IDL Definition</span></a>
</ol>
</ol>
<li><a href="#acknowledgements"><span class="secno">7</span> <span class="content"> Acknowledgements</span></a>
<li><a href="#other-open-issues"><span class="secno">8</span> <span class="content">Other open issues</span></a>
<li><a href="#wg-resolutions-pending"><span class="secno">9</span> <span class="content"> Working Group Resolutions that are pending editing</span></a>
<li>
<a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
<ol class="toc">
<li><a href="#document-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
<li><a href="#conform-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
<li>
<a href="#conform-responsible"><span class="secno"></span> <span class="content"> Requirements for Responsible Implementation of CSS</span></a>
<ol class="toc">
<li><a href="#conform-partial"><span class="secno"></span> <span class="content"> Partial Implementations</span></a>
<li><a href="#conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a>
<li><a href="#conform-testing"><span class="secno"></span> <span class="content"> Implementations of CR-level Features</span></a>
</ol>
</ol>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
</ol>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a>
<li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
</ol>
</nav>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content"> Introduction</span><a class="self-link" href="#intro"></a></h2>
<p><em>This section is not normative</em></p>
<p>CSS Transitions <a data-link-type="biblio" href="#biblio-css3-transitions">[CSS3-TRANSITIONS]</a> 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.</p>
<p>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.</p>
<p>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.</p>
<h2 class="heading settled" data-level="2" id="values"><span class="secno">2. </span><span class="content"> Values</span><a class="self-link" href="#values"></a></h2>
<p>This specification follows the CSS property definition conventions
from <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>. Value types not defined in this specification are
defined in CSS Level 2 Revision 1 <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>. Other CSS modules may
expand the definitions of these value types: for example <a data-link-type="biblio" href="#biblio-css3val">[CSS3VAL]</a>,
when combined with this module, expands the definition of the <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#length-value"><length></a> value type as used in this specification.</p>
<p>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.</p>
<h2 class="heading settled" data-level="3" id="animations"><span class="secno">3. </span><span class="content"> Animations</span><a class="self-link" href="#animations"></a></h2>
<p>CSS Animations affect computed property values. This effect happens by
adding a specified value to the CSS cascade (<a data-link-type="biblio" href="#biblio-css3cascade">[CSS3CASCADE]</a>) (at the
level for CSS Animations) that will produce the correct computed value
for the current state of the animation. As defined in <a data-link-type="biblio" href="#biblio-css3cascade">[CSS3CASCADE]</a>,
animations override all normal rules, but are overridden by !important
rules.</p>
<p>If at one point in time there are multiple animations specifying behavior
for the same property, the animation which occurs last in the value
of <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> will override the other animations at that point.</p>
<p>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.</p>
<p>While running, the animation computes the value of those properties
it animates. Other values may take precedence over the animated value
according to the CSS cascade (<a data-link-type="biblio" href="#biblio-css3cascade">[CSS3CASCADE]</a>).</p>
<p>The start time of an animation is the time at which the style applying
the animation and the corresponding @keyframes rule are both resolved.
If an animation is specified for an element but the corresponding
@keyframes rule does not yet exist, the animation cannot start; the
animation will start from the beginning as soon as a matching @keyframes
rule can be resolved. An animation specified by dynamically modifying the
element’s style will start when this 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). Note that dynamically updating keyframe style
rules does not start or restart an animation.</p>
<p>An animation applies to an element if its name appears as one of the
identifiers in the computed value of the <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property and the
animation uses a valid @keyframes rule. Once an
animation has started it continues until it ends or the <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> is
removed. Changes to the values of animation properties while the animation
is running apply as if the animation had those values from when it
began. For example, shortening the <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> may cause the animation
to jump forwards or even finish immediately and dispatch an <a data-link-type="idl" href="#eventdef-animationevent-animationend">animationend</a> event.
Conversely, extending the <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> may cause an animation to
re-start and dispatch an <a data-link-type="idl" href="#eventdef-animationevent-animationstart">animationstart</a> event.</p>
<div class="example" id="example-dee38741">
<a class="self-link" href="#example-dee38741"></a>
<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>
<p>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).</p>
</div>
<p>Setting the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visuren.html#propdef-display">display</a> property to <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-none">none</a> will terminate any running animation applied
to the element and its descendants. If an element has a <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visuren.html#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-none">none</a>, updating <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visuren.html#propdef-display">display</a> to a value other than <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-none">none</a> will start all animations applied to the element
by the <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property, as well as all animations applied to descendants
with <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visuren.html#propdef-display">display</a> other than <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-none">none</a>.</p>
<p>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 (<a data-link-type="biblio" href="#biblio-wcag20">[WCAG20]</a>).</p>
<p>Implementations may ignore animations when the rendering medium is not interactive e.g. when printed.
A future version of this specification may define how to render animations for these media.</p>
<h2 class="heading settled" data-level="4" id="keyframes"><span class="secno">4. </span><span class="content"> Keyframes</span><a class="self-link" href="#keyframes"></a></h2>
<p>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 zero or more times.</p>
<p>Keyframes are specified using a specialized CSS at-rule. A <dfn class="css" data-dfn-type="at-rule" data-export="" id="at-ruledef-keyframes">@keyframes<a class="self-link" href="#at-ruledef-keyframes"></a></dfn> rule consists of the
keyword "@keyframes", followed by an identifier giving a name for the animation (which will
be referenced using <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a>), followed by a set of style rules (delimited by curly
braces).</p>
<p>The keyframe selector for a keyframe style rule consists of a comma-separated list of
percentage values or the keywords <span class="css">from</span> or <span class="css">to</span>. 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 <span class="css">from</span> is equivalent to the value <span class="css">0%</span>. The keyword <span class="css">to</span> is equivalent to the value <span class="css">100%</span>. <span class="note" role="note">Note that the percentage unit specifier must be used on percentage values.
Therefore, <span class="css">0</span> is an invalid keyframe selector.</span></p>
<p>If a <span class="css">0%</span> or <span class="css">from</span> keyframe is not specified, then the user agent constructs a <span class="css">0%</span> keyframe
using the computed values of the properties being animated. If a <span class="css">100%</span> or <span class="css">to</span> keyframe is not
specified, then the user agent constructs a <span class="css">100%</span> keyframe using the computed values of the
properties being animated. If a keyframe selector specifies negative percentage values or values
higher than <span class="css">100%</span>, then the keyframe will be ignored.</p>
<p>The keyframe declaration block for a keyframe rule consists of properties and values. The properties
defined by this specification are ignored in these rules, with the exception of <a class="property" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function</a>, the behavior of which is described below. In addition, keyframe rule
declarations qualified with !important are ignored.</p>
<p>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 <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property.</p>
<div class="example" id="example-06c21004">
<a class="self-link" href="#example-06c21004"></a>
<pre>div {
animation-name: slide-right;
animation-duration: 2s;
}
@keyframes slide-right {
from {
margin-left: 0px;
}
50% {
margin-left: 110px;
opacity: 1;
}
50% {
opacity: 0.9;
}
to {
margin-left: 200px;
}
}
</pre>
<p>At the 1s mark, the slide-right animation will have the same state as if we had defined the 50% rule like this:</p>
<pre>@keyframes slide-right {
50% {
margin-left: 110px;
opacity: 0.9;
}
to {
margin-left: 200px;
}
}
</pre>
</div>
<p>To determine the set of keyframes, all of the values in the selectors are sorted in increasing order
by time. The rules within the @keyframes rule then cascade; the properties of a keyframe may thus derive
from more than one @keyframes rule with the same selector value.</p>
<p>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.</p>
<div class="example" id="example-25879023">
<a class="self-link" href="#example-25879023"></a>
<pre>@keyframes wobble {
0% {
left: 100px;
}
40% {
left: 150px;
}
60% {
left: 75px;
}
100% {
left: 100px;
}
}
</pre>
<p>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 <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a> property being
animated is <span class="css">100px</span>. By 40% of the animation duration, <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a> has animated to <span class="css">150px</span>.
At 60% of the animation duration, <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a> has animated back to <span class="css">75px</span>. At the end of the
animation cycle, the value of <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a> has returned to <span class="css">100px</span>. The diagram below shows
the state of the animation if it were given a duration of <span class="css">10s</span>.</p>
<figure>
<img alt="" src="./animation1.png">
<figcaption>Animation states specified by keyframes</figcaption>
</figure>
</div>
<p>The following is the grammar for the keyframes rule:</p>
<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>
<p class="issue" id="issue-396f31a3"><a class="self-link" href="#issue-396f31a3"></a> This specification needs to define
how the value is determined from the keyframes,
like the section on <a href="https://drafts.csswg.org/css-transitions/#application">Application of transitions</a> does for CSS Transitions. </p>
<h3 class="heading settled" data-level="4.1" id="timing-functions"><span class="secno">4.1. </span><span class="content"> Timing functions for keyframes</span><a class="self-link" href="#timing-functions"></a></h3>
<p>A keyframe style rule may also declare the timing function that is to be used as the animation
moves to the next keyframe.</p>
<div class="example" id="example-5d14f501">
<a class="self-link" href="#example-5d14f501"></a>
<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>
<p>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.</p>
</div>
<p>A timing function specified on the <span class="css">to</span> or <span class="css">100%</span> keyframe is ignored.</p>
<p>See the <a class="property" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function</a> property for more information.</p>
<h3 class="heading settled" data-level="4.2" id="animation-name"><span class="secno">4.2. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property</span><a class="self-link" href="#animation-name"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property defines a list of animations that apply. Each name is used to select
the keyframe at-rule that provides the property values for the animation. If the name does not match
any keyframe at-rule, there are no properties to be animated and the animation will not execute.
Furthermore, if the animation name is <code>none</code> then there will be no animation. This can be
used to override any animations coming from the cascade. If multiple animations are attempting to
modify the same property, then the animation closest to the end of the list of names wins.</p>
<p>Each animation listed by name should have a corresponding value for the other animation properties
listed below. If the lists of values for the other animation properties do not have the same length,
the length of the <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> list determines the number of items in each list examined when
starting animations. The lists are matched up from the first value: excess values at the end are not
used. If one of the other properties doesn’t have enough comma-separated values to match the number of
values of <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a>, the UA must calculate its used value by repeating the list of values until
there are enough. This truncation or repetition does not affect the computed value.</p>
<p class="note" role="note">Note: This is analogous to the behavior of the ‘background-*’properties, with ‘background-image’ analogous
to <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a>.</p>
<table class="def propdef" data-link-for-hint="animation-name">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-name">animation-name<a class="self-link" href="#propdef-animation-name"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation-name"><single-animation-name></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>none
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation-name"><single-animation-name><a class="self-link" href="#typedef-single-animation-name"></a></dfn> = none | <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#identifier-value"><custom-ident></a></p>
<p>The values of <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> have the following meanings:</p>
<dl>
<dt><dfn class="css" data-dfn-for="animation-name" data-dfn-type="value" data-export="" id="valdef-animation-name-none">none<a class="self-link" href="#valdef-animation-name-none"></a></dfn>
<dd> No keyframes are specified at all, so there will be no animation.
Any other animations properties specified for this animation have no effect.
<dt><dfn class="css" data-dfn-for="animation-name" data-dfn-type="value" data-export="" id="valdef-animation-name-custom-ident"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#identifier-value"><custom-ident></a><a class="self-link" href="#valdef-animation-name-custom-ident"></a></dfn>
<dd>
The animation will use the keyframes with the name specified by the <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#identifier-value"><custom-ident></a>,
if they exist.If no such keyframes exist, there is no animation.
<p>The <a href="https://www.w3.org/TR/css3-values/#common-keywords">CSS-wide keywords</a> and keywords defined by this property are not valid animation names.</p>
</dl>
<h3 class="heading settled" data-level="4.3" id="animation-duration"><span class="secno">4.3. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-duration">animation-duration</a> property</span><a class="self-link" href="#animation-duration"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-duration">animation-duration</a> property defines duration of a single animation cycle.</p>
<table class="def propdef" data-link-for-hint="animation-duration">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-duration">animation-duration<a class="self-link" href="#propdef-animation-duration"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>0s
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<dl>
<dt><dfn class="css" data-dfn-for="animation-duration" data-dfn-type="value" data-export="" id="valdef-animation-duration-time"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a><a class="self-link" href="#valdef-animation-duration-time"></a></dfn>
<dd>
The <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> specifies the length of time that an animation takes to complete one cycle.
A negative <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> is invalid.
<p>If the <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> is <span class="css">0s</span>, like the initial value,
the keyframes of the animation have no effect,
but the animation itself still occurs instantaneously.
Specifically, start and end events are fired; if <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is set to <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-backwards">backwards</a> or <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-both">both</a>, the first frame of the animation, as defined by <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a>, will be displayed during the <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a>. Then the last frame of the animation,
as defined by <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a>, will be displayed if <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is set to <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-forwards">forwards</a> or <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-both">both</a>.
If <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is set to <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-none">none</a> then the animation has no visible effect.</p>
</dl>
<h3 class="heading settled" data-level="4.4" id="animation-timing-function"><span class="secno">4.4. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function</a> property</span><a class="self-link" href="#animation-timing-function"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function</a> property describes how the animation will progress over
one cycle of its duration. See the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-transitions-1/#propdef-transition-timing-function">transition-timing-function</a> property <a data-link-type="biblio" href="#biblio-css3-transitions">[CSS3-TRANSITIONS]</a> for a complete description of timing function calculation.</p>
<table class="def propdef" data-link-for-hint="animation-timing-function">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-timing-function">animation-timing-function<a class="self-link" href="#propdef-animation-timing-function"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-timing-function"><single-timing-function></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>ease
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p>The values and meaning of <dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-timing-function"><single-timing-function><a class="self-link" href="#typedef-single-timing-function"></a></dfn> are identical to those of <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-transitions-1/#single-transition-timing-function" title="Expands to: linear | step-start | cubic-bezier() | ease | ease-out | step-end | ease-in-out | ease-in | steps()"><single-transition-timing-function></a> <a data-link-type="biblio" href="#biblio-css3-transitions">[CSS3-TRANSITIONS]</a>.</p>
<p>The timing function specified applies to each iteration of the animation,
not the entire animation in full.
For example, if an animation has <a class="css" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function: ease-in-out; animation-iteration-count: 2;</a>,
it will ease in at the start,
ease out as it approaches the end of its first iteration,
ease in at the start of its second iteration,
and ease out again as it approaches the end of the animation.</p>
<p>When specified in a keyframe, <a class="property" data-link-type="propdesc" href="#propdef-animation-timing-function">animation-timing-function</a> defines
the progression of the animation
between the current keyframe
and the next keyframe for the animating property
in sorted keyframe selector order
(which may be an implicit 100% keyframe).
The specified timing function
will apply over this interval
independently of the animation’s current direction.</p>
<h3 class="heading settled" data-level="4.5" id="animation-iteration-count"><span class="secno">4.5. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a> property</span><a class="self-link" href="#animation-iteration-count"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a> property specifies the number of times an animation cycle
is played. The initial value is <span class="css">1</span>, meaning the animation will play from beginning to end
once. This property is often used in conjunction with an <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a> value of <a class="css" data-link-type="maybe" href="#valdef-animation-direction-alternate">alternate</a>, which will cause the animation to play in
reverse on alternate cycles.</p>
<p>The time window during which the animation is active
(<code>duration</code> x <code>iteration-count</code>)
is known as the <dfn data-dfn-type="dfn" data-noexport="" id="active-duration">active duration<a class="self-link" href="#active-duration"></a></dfn>.</p>
<table class="def propdef" data-link-for-hint="animation-iteration-count">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-iteration-count">animation-iteration-count<a class="self-link" href="#propdef-animation-iteration-count"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation-iteration-count"><single-animation-iteration-count></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>1
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation-iteration-count"><single-animation-iteration-count><a class="self-link" href="#typedef-single-animation-iteration-count"></a></dfn> = infinite | <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#number-value"><number></a></p>
<dl>
<dt><dfn class="css" data-dfn-for="animation-iteration-count" data-dfn-type="value" data-export="" id="valdef-animation-iteration-count-infinite">infinite<a class="self-link" href="#valdef-animation-iteration-count-infinite"></a></dfn>
<dd> The animation will repeat forever.
<dt><dfn class="css" data-dfn-for="animation-iteration-count" data-dfn-type="value" data-export="" id="valdef-animation-iteration-count-number"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#number-value"><number></a><a class="self-link" href="#valdef-animation-iteration-count-number"></a></dfn>
<dd>
<p>The animation will repeat the specified number of times.
If the number is not an integer,
the animation will end partway through its last cycle.
Negative numbers are invalid. </p>
<p>A value of <span class="css">0</span> is valid and, similar to an <a class="property" data-link-type="propdesc" href="#propdef-animation-duration">animation-duration</a> of <span class="css">0s</span>, causes the animation to occur instantaneously. </p>
</dl>
<p>If the animation has a duration of <span class="css">0s</span>, it will occur instantaneously for any
valid value of <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a>, including <a class="css" data-link-type="maybe" href="#valdef-animation-iteration-count-infinite">infinite</a>.</p>
<h3 class="heading settled" data-level="4.6" id="animation-direction"><span class="secno">4.6. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a> property</span><a class="self-link" href="#animation-direction"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a> 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 <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-transitions-1/#valdef-transition-timing-function-ease-in">ease-in</a> animation would appear to be an <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-transitions-1/#valdef-transition-timing-function-ease-out">ease-out</a> animation.</p>
<table class="def propdef" data-link-for-hint="animation-direction">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-direction">animation-direction<a class="self-link" href="#propdef-animation-direction"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation-direction"><single-animation-direction></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>normal
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation-direction"><single-animation-direction><a class="self-link" href="#typedef-single-animation-direction"></a></dfn> = normal | reverse | alternate | alternate-reverse</p>
<dl>
<dt><dfn class="css" data-dfn-for="animation-direction" data-dfn-type="value" data-export="" id="valdef-animation-direction-normal">normal<a class="self-link" href="#valdef-animation-direction-normal"></a></dfn>
<dd> All iterations of the animation are played as specified.
<dt><dfn class="css" data-dfn-for="animation-direction" data-dfn-type="value" data-export="" id="valdef-animation-direction-reverse">reverse<a class="self-link" href="#valdef-animation-direction-reverse"></a></dfn>
<dd> All iterations of the animation are played in the reverse direction
from the way they were specified.
<dt><dfn class="css" data-dfn-for="animation-direction" data-dfn-type="value" data-export="" id="valdef-animation-direction-alternate">alternate<a class="self-link" href="#valdef-animation-direction-alternate"></a></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 class="css" data-dfn-for="animation-direction" data-dfn-type="value" data-export="" id="valdef-animation-direction-alternate-reverse">alternate-reverse<a class="self-link" href="#valdef-animation-direction-alternate-reverse"></a></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>
<p class="note" role="note">Note: For the purpose of determining whether an iteration is even or odd,
iterations start counting from 1.</p>
<h3 class="heading settled" data-level="4.7" id="animation-play-state"><span class="secno">4.7. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-play-state">animation-play-state</a> property</span><a class="self-link" href="#animation-play-state"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-play-state">animation-play-state</a> property defines whether the animation is running or paused.</p>
<table class="def propdef" data-link-for-hint="animation-play-state">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-play-state">animation-play-state<a class="self-link" href="#propdef-animation-play-state"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation-play-state"><single-animation-play-state></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>running
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation-play-state"><single-animation-play-state><a class="self-link" href="#typedef-single-animation-play-state"></a></dfn> = running | paused</p>
<dl>
<dt><dfn class="css" data-dfn-for="animation-play-state" data-dfn-type="value" data-export="" id="valdef-animation-play-state-running">running<a class="self-link" href="#valdef-animation-play-state-running"></a></dfn>
<dd> While this property is set to <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-running">running</a>,
the animation proceeds as normal.
<dt><dfn class="css" data-dfn-for="animation-play-state" data-dfn-type="value" data-export="" id="valdef-animation-play-state-paused">paused<a class="self-link" href="#valdef-animation-play-state-paused"></a></dfn>
<dd>
While this property is set to <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-paused">paused</a>,
the animation is paused.
The animation continues to apply to the element with the progress it had made before being paused.
When unpaused (set back to <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-running">running</a>), it restarts from where it left off,
as if the "clock" that controls the animation had stopped and started again.
<p>If the property is set to <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-paused">paused</a> during the delay phase of the animation,
the delay clock is also paused and resumes as soon as <a class="property" data-link-type="propdesc" href="#propdef-animation-play-state">animation-play-state</a> is set back to <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-running">running</a>.</p>
</dl>
<h3 class="heading settled" data-level="4.8" id="animation-delay"><span class="secno">4.8. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> property</span><a class="self-link" href="#animation-delay"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> property defines when the animation will start. It allows an animation
to begin execution some time after it is applied,
or to appear to have begun execution some time <em>before</em> it is applied.</p>
<table class="def propdef" data-link-for-hint="animation-delay">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-delay">animation-delay<a class="self-link" href="#propdef-animation-delay"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>0s
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<dl>
<dt><dfn class="css" data-dfn-for="animation-delay" data-dfn-type="value" data-export="" id="valdef-animation-delay-time"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a><a class="self-link" href="#valdef-animation-delay-time"></a></dfn>
<dd>
The <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> defines how long of a delay there is between the start of the animation
(when the animation is applied to the element via these properties)
and when it begins executing.
A delay of <span class="css">0s</span> (the initial value) means that the animation will execute as soon as it is applied.
<p>A negative delay is <strong>valid</strong>.
Similar to a delay of <span class="css">0s</span>, it means that the animation executes immediately,
but is automatically progressed by the absolute value of the delay,
as if the animation had started the specified time in the past,
and so it appears to start partway through its <a href="#animation-iteration-count">active duration</a>.
If an animation’s keyframes have an implied starting value,
the values are taken from the time the animation starts,
not some time in the past.</p>
</dl>
<h3 class="heading settled" data-level="4.9" id="animation-fill-mode"><span class="secno">4.9. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> property</span><a class="self-link" href="#animation-fill-mode"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> 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 <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> property). Also, by default an animation does not affect property values after the
animation ends (determined by the <a class="property" data-link-type="propdesc" href="#propdef-animation-duration">animation-duration</a> and <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a> properties).
The <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> property can override this behavior. Dynamic updates to the property will
be reflected by property values as needed, whether during the animation delay or after the animation ends.</p>
<table class="def propdef" data-link-for-hint="animation-fill-mode">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation-fill-mode">animation-fill-mode<a class="self-link" href="#propdef-animation-fill-mode"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation-fill-mode"><single-animation-fill-mode></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation-fill-mode"><single-animation-fill-mode><a class="self-link" href="#typedef-single-animation-fill-mode"></a></dfn> = none | forwards | backwards | both</p>
<dl>
<dt><dfn class="css" data-dfn-for="animation-fill-mode" data-dfn-type="value" data-export="" id="valdef-animation-fill-mode-none">none<a class="self-link" href="#valdef-animation-fill-mode-none"></a></dfn>
<dd> The animation has no effect when it is applied but not executing.
<dt><dfn class="css" data-dfn-for="animation-fill-mode" data-dfn-type="value" data-export="" id="valdef-animation-fill-mode-forwards">forwards<a class="self-link" href="#valdef-animation-fill-mode-forwards"></a></dfn>
<dd> After the animation ends (as determined by its <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a>), the animation
will apply the property values for the time the animation ended. When <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a> 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 <a class="property" data-link-type="propdesc" href="#propdef-animation-iteration-count">animation-iteration-count</a> is zero, the values applied will be
those that would start the first iteration (just as when <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-backwards">backwards</a>).
<dt><dfn class="css" data-dfn-for="animation-fill-mode" data-dfn-type="value" data-export="" id="valdef-animation-fill-mode-backwards">backwards<a class="self-link" href="#valdef-animation-fill-mode-backwards"></a></dfn>
<dd> During the period defined by <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a>, the animation will apply the property values
defined in the keyframe that will start the first iteration of the animation.
These are either the values of the <span class="css">from</span> keyframe (when <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-direction-normal">normal</a> or <a class="css" data-link-type="maybe" href="#valdef-animation-direction-alternate">alternate</a>) or those of the <span class="css">to</span> keyframe (when <a class="property" data-link-type="propdesc" href="#propdef-animation-direction">animation-direction</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-direction-reverse">reverse</a> or <a class="css" data-link-type="maybe" href="#valdef-animation-direction-alternate-reverse">alternate-reverse</a>).
<dt><dfn class="css" data-dfn-for="animation-fill-mode" data-dfn-type="value" data-export="" id="valdef-animation-fill-mode-both">both<a class="self-link" href="#valdef-animation-fill-mode-both"></a></dfn>
<dd> The effects of both <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-forwards">forwards</a> and <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-backwards">backwards</a> fill apply.
</dl>
<h3 class="heading settled" data-level="4.10" id="animation"><span class="secno">4.10. </span><span class="content"> The <a class="property" data-link-type="propdesc" href="#propdef-animation">animation</a> shorthand property</span><a class="self-link" href="#animation"></a></h3>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-animation">animation</a> 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 <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> for what happens when these
properties have lists of different lengths, a problem that cannot occur when they are defined using
only the <a class="property" data-link-type="propdesc" href="#propdef-animation">animation</a> shorthand.)</p>
<table class="def propdef" data-link-for-hint="animation">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-animation">animation<a class="self-link" href="#propdef-animation"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" href="#typedef-single-animation"><single-animation></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-comma">#</a>
<tr>
<th>Initial:
<td>see individual properties
<tr>
<th>Applies to:
<td>all elements, ::before and ::after pseudo-elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>interactive
<tr>
<th>Computed value:
<td>As specified
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td>per grammar
</table>
<p><dfn class="css" data-dfn-type="type" data-export="" id="typedef-single-animation"><single-animation><a class="self-link" href="#typedef-single-animation"></a></dfn> = <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> || <a class="production css" data-link-type="type" href="#typedef-single-timing-function"><single-timing-function></a> || <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> || <a class="production css" data-link-type="type" href="#typedef-single-animation-iteration-count"><single-animation-iteration-count></a> || <a class="production css" data-link-type="type" href="#typedef-single-animation-direction"><single-animation-direction></a> || <a class="production css" data-link-type="type" href="#typedef-single-animation-fill-mode"><single-animation-fill-mode></a> || <a class="production css" data-link-type="type" href="#typedef-single-animation-play-state"><single-animation-play-state></a> || <a class="production css" data-link-type="type" href="#typedef-single-animation-name"><single-animation-name></a></p>
<p>Note that order is important within each animation definition: the first value in each <a class="production css" data-link-type="type" href="#typedef-single-animation"><single-animation></a> that can be parsed as a <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> is assigned to the <a class="property" data-link-type="propdesc" href="#propdef-animation-duration">animation-duration</a>,
and the second value in each <a class="production css" data-link-type="type" href="#typedef-single-animation"><single-animation></a> that can be parsed as a <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#time-value"><time></a> is assigned to <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a>.</p>
<p>Note that order is also important within each animation definition for distinguishing <a class="production css" data-link-type="type" href="#typedef-single-animation-name"><single-animation-name></a> values from other keywords. When parsing, keywords that are valid for
properties other than <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> whose values were not found earlier in the shorthand
must be accepted for those properties rather than for <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a>. Furthermore, when serializing, default values of other properties must be
output in at least the cases necessary to distinguish an <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> that could
be a value of another property, and may be output in additional cases.</p>
<div class="example" id="example-acb6018a"><a class="self-link" href="#example-acb6018a"></a> For example, a value parsed from <a class="css" data-link-type="propdesc" href="#propdef-animation">animation: 3s none backwards</a> (where <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-none">none</a> and <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> is <span class="css">backwards</span>)
must not be serialized as <a class="css" data-link-type="propdesc" href="#propdef-animation">animation: 3s backwards</a> (where <a class="property" data-link-type="propdesc" href="#propdef-animation-fill-mode">animation-fill-mode</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-fill-mode-backwards">backwards</a> and <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> is <a class="css" data-link-type="maybe" href="#valdef-animation-name-none">none</a>). </div>
<h2 class="heading settled" data-level="5" id="events"><span class="secno">5. </span><span class="content"> Animation Events</span><a class="self-link" href="#events"></a></h2>
<p>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 <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> value with keyframes containing multiple properties, or with
multiple <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> values. For the purposes of events, each <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> specifies
a single animation. Therefore an event will be generated for each <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> value and
not necessarily for each property being animated.</p>
<p>Any animation for which a valid keyframe rule is defined will run
and generate events; this includes animations with empty keyframe rules.</p>
<p>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 <a class="css" data-link-type="maybe" href="#valdef-animation-play-state-paused">paused</a> play state.</p>
<h3 class="heading settled" data-level="5.1" id="interface-animationevent"><span class="secno">5.1. </span><span class="content"> The <code>AnimationEvent</code> Interface</span><a class="self-link" href="#interface-animationevent"></a></h3>
<p>The <code>AnimationEvent</code> interface provides specific contextual information associated with
Animation events.</p>
<h4 class="heading settled" data-level="5.1.1" id="interface-animationevent-idl"><span class="secno">5.1.1. </span><span class="content"> IDL Definition</span><a class="self-link" href="#interface-animationevent-idl"></a></h4>
<pre class="idl">[<dfn class="idl-code" data-dfn-for="AnimationEvent" data-dfn-type="constructor" data-export="" data-lt="AnimationEvent(type, animationEventInitDict)" id="dom-animationevent-animationevent">Constructor<a class="self-link" href="#dom-animationevent-animationevent"></a></dfn>(DOMString <dfn class="idl-code" data-dfn-for="AnimationEvent/AnimationEvent(type, animationEventInitDict)" data-dfn-type="argument" data-export="" id="dom-animationevent-animationevent-type-animationeventinitdict-type">type<a class="self-link" href="#dom-animationevent-animationevent-type-animationeventinitdict-type"></a></dfn>, optional <a data-link-type="idl-name" href="#dictdef-animationeventinit">AnimationEventInit</a> <dfn class="idl-code" data-dfn-for="AnimationEvent/AnimationEvent(type, animationEventInitDict)" data-dfn-type="argument" data-export="" id="dom-animationevent-animationevent-type-animationeventinitdict-animationeventinitdict">animationEventInitDict<a class="self-link" href="#dom-animationevent-animationevent-type-animationeventinitdict-animationeventinitdict"></a></dfn>)]
interface <dfn class="idl-code" data-dfn-type="interface" data-export="" id="animationevent">AnimationEvent<a class="self-link" href="#animationevent"></a></dfn> : <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#event">Event</a> {
readonly attribute DOMString <a class="idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString " href="#dom-animationevent-animationname">animationName</a>;
readonly attribute float <a class="idl-code" data-link-type="attribute" data-readonly="" data-type="float " href="#dom-animationevent-elapsedtime">elapsedTime</a>;
readonly attribute DOMString <a class="idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString " href="#dom-animationevent-pseudoelement">pseudoElement</a>;
};
dictionary <dfn class="idl-code" data-dfn-type="dictionary" data-export="" id="dictdef-animationeventinit">AnimationEventInit<a class="self-link" href="#dictdef-animationeventinit"></a></dfn> : <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
DOMString <dfn class="idl-code" data-default="""" data-dfn-for="AnimationEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-animationeventinit-animationname">animationName<a class="self-link" href="#dom-animationeventinit-animationname"></a></dfn> = "";
float <dfn class="idl-code" data-default="0.0" data-dfn-for="AnimationEventInit" data-dfn-type="dict-member" data-export="" data-type="float " id="dom-animationeventinit-elapsedtime">elapsedTime<a class="self-link" href="#dom-animationeventinit-elapsedtime"></a></dfn> = 0.0;
DOMString <dfn class="idl-code" data-default="""" data-dfn-for="AnimationEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-animationeventinit-pseudoelement">pseudoElement<a class="self-link" href="#dom-animationeventinit-pseudoelement"></a></dfn> = "";
};
</pre>
<h4 class="heading settled" data-level="5.1.2" id="interface-animationevent-attributes"><span class="secno">5.1.2. </span><span class="content"> Attributes</span><a class="self-link" href="#interface-animationevent-attributes"></a></h4>
<dl>
<dt><dfn class="idl-code" data-dfn-for="AnimationEvent" data-dfn-type="attribute" data-export="" id="dom-animationevent-animationname">animationName<a class="self-link" href="#dom-animationevent-animationname"></a></dfn>, of type , <span> of type <a data-link-type="idl-name" href="http://heycam.github.io/webidl/#idl-DOMString">DOMString</a>, readonly</span><a class="idl-code" data-link-type="interface" href="http://heycam.github.io/webidl/#idl-DOMString">DOMString</a>, readonly
<dd> The value of the <a class="property" data-link-type="propdesc" href="#propdef-animation-name">animation-name</a> property of the animation that fired the event.
<dt><dfn class="idl-code" data-dfn-for="AnimationEvent" data-dfn-type="attribute" data-export="" id="dom-animationevent-elapsedtime">elapsedTime<a class="self-link" href="#dom-animationevent-elapsedtime"></a></dfn>, of type float, readonly
, <span> of type <a data-link-type="idl-name">float</a>, readonly</span>
<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 <span class="css">animationstart</span> event, the
elapsedTime is zero unless there was a negative value for <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a>, in which
case the event will be fired with an elapsedTime of (-1 * delay).
<dt><dfn class="idl-code" data-dfn-for="AnimationEvent" data-dfn-type="attribute" data-export="" id="dom-animationevent-pseudoelement">pseudoElement<a class="self-link" href="#dom-animationevent-pseudoelement"></a></dfn>, of type , <span> of type <a data-link-type="idl-name" href="http://heycam.github.io/webidl/#idl-DOMString">DOMString</a>, readonly</span><a class="idl-code" data-link-type="interface" href="http://heycam.github.io/webidl/#idl-DOMString">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>
<p><dfn class="css" data-dfn-type="function" data-export="" data-lt="AnimationEvent()" id="funcdef-animationevent">AnimationEvent(type, animationEventInitDict)<a class="self-link" href="#funcdef-animationevent"></a></dfn> is an <a data-link-type="dfn" href="http://w3c.github.io/dom/#constructing-events">event constructor</a>.</p>
<h3 class="heading settled" data-level="5.2" id="event-animationevent"><span class="secno">5.2. </span><span class="content"> Types of <code>AnimationEvent</code></span><a class="self-link" href="#event-animationevent"></a></h3>
<p>The different types of animation events that can occur are:</p>
<dl>
<dt><dfn class="idl-code" data-dfn-for="animationevent" data-dfn-type="event" data-export="" id="eventdef-animationevent-animationstart">animationstart<a class="self-link" href="#eventdef-animationevent-animationstart"></a></dfn>
<dd>
The <a data-link-type="idl" href="#eventdef-animationevent-animationstart">animationstart</a> event occurs at the start of the animation.
If there is an <a class="property" data-link-type="propdesc" href="#propdef-animation-delay">animation-delay</a> 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; in this case the