forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.html
More file actions
1330 lines (1083 loc) · 111 KB
/
Overview.html
File metadata and controls
1330 lines (1083 loc) · 111 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
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>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<script defer src=//test.csswg.org/harness/annotate.js#css-animations-1_dev type=text/javascript></script>
</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=http://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 heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20150109>9 January 2015</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css3-animations/>http://dev.w3.org/csswg/css3-animations/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css3-animations/>http://www.w3.org/TR/css3-animations/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css3-animations/>http://dev.w3.org/csswg/css3-animations/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css3-animations-20130219/ rel=previous>http://www.w3.org/TR/2013/WD-css3-animations-20130219/</a><dd><a href=http://www.w3.org/TR/2012/WD-css3-animations-20120403/ rel=previous>http://www.w3.org/TR/2012/WD-css3-animations-20120403/</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-animations%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-animations] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<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>Editors:
<dd class="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="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:dbaron@dbaron.org>L. David Baron</a> (<span class="p-org org">Mozilla</span>)<dd class="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>Former Editors:
<dd class="p-author h-card vcard"><span class="p-name fn">David Hyatt</span> (<span class="p-org org">Apple Inc.</span>)<dd class="p-author h-card vcard"><span class="p-name fn">Chris Marrin</span> (<span class="p-org org">Apple Inc.</span>)<dt>Issues List:<dd><a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=Animations&list_id=36653&product=CSS&query_format=advanced&resolution=---">In Bugzilla</a></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> © 2014 <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>), All Rights Reserved. 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 heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=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.
<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.</p>
<h2 class="no-num no-toc no-ref heading settled heading" 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>
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>
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>
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>.</div>
<div data-fill-with=at-risk><p>The following features are at-risk, and may be dropped during the CR period:
<ul><li>the <code>pseudoElement</code> property of the <a class=css data-link-type=maybe href=#animationevent title=animationevent>AnimationEvent</a> interface</ul></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#intro><span class=secno>1</span> Introduction</a>
<li><a href=#values><span class=secno>2</span> Values</a>
<li><a href=#animations><span class=secno>3</span> Animations</a>
<li><a href=#keyframes><span class=secno>4</span> Keyframes</a>
<ul class=toc>
<li><a href=#timing-functions><span class=secno>4.1</span> Timing functions for keyframes</a>
<li><a href=#animation-name><span class=secno>4.2</span> The <span class=property data-link-type=propdesc title=animation-name>animation-name</span> property</a>
<li><a href=#animation-duration><span class=secno>4.3</span> The <span class=property data-link-type=propdesc title=animation-duration>animation-duration</span> property</a>
<li><a href=#animation-timing-function><span class=secno>4.4</span> The <span class=property data-link-type=propdesc title=animation-timing-function>animation-timing-function</span> property</a>
<li><a href=#animation-iteration-count><span class=secno>4.5</span> The <span class=property data-link-type=propdesc title=animation-iteration-count>animation-iteration-count</span> property</a>
<li><a href=#animation-direction><span class=secno>4.6</span> The <span class=property data-link-type=propdesc title=animation-direction>animation-direction</span> property</a>
<li><a href=#animation-play-state><span class=secno>4.7</span> The <span class=property data-link-type=propdesc title=animation-play-state>animation-play-state</span> property</a>
<li><a href=#animation-delay><span class=secno>4.8</span> The <span class=property data-link-type=propdesc title=animation-delay>animation-delay</span> property</a>
<li><a href=#animation-fill-mode><span class=secno>4.9</span> The <span class=property data-link-type=propdesc title=animation-fill-mode>animation-fill-mode</span> property</a>
<li><a href=#animation><span class=secno>4.10</span> The <span class=property data-link-type=propdesc title=animation>animation</span> shorthand property</a></ul>
<li><a href=#events><span class=secno>5</span> Animation Events</a>
<ul class=toc>
<li><a href=#interface-animationevent><span class=secno>5.1</span> The <code>AnimationEvent</code> Interface</a>
<ul class=toc>
<li><a href=#interface-animationevent-idl><span class=secno>5.1.1</span> IDL Definition</a>
<li><a href=#interface-animationevent-attributes><span class=secno>5.1.2</span> Attributes</a></ul>
<li><a href=#event-animationevent><span class=secno>5.2</span> Types of <code>AnimationEvent</code></a></ul>
<li><a href=#interface-dom><span class=secno>6</span> DOM Interfaces</a>
<ul class=toc>
<li><a href=#interface-cssrule><span class=secno>6.1</span> The <code>CSSRule</code> Interface</a>
<ul class=toc>
<li><a href=#interface-cssrule-idl><span class=secno>6.1.1</span> IDL Definition</a></ul>
<li><a href=#interface-csskeyframerule><span class=secno>6.2</span> The <code>CSSKeyframeRule</code> Interface</a>
<ul class=toc>
<li><a href=#interface-csskeyframerule-idl><span class=secno>6.2.1</span> IDL Definition</a>
<li><a href=#interface-csskeyframerule-attributes><span class=secno>6.2.2</span> Attributes</a></ul>
<li><a href=#interface-csskeyframesrule><span class=secno>6.3</span> The <code>CSSKeyframesRule</code> Interface</a>
<ul class=toc>
<li><a href=#interface-csskeyframesrule-idl><span class=secno>6.3.1</span> IDL Definition</a>
<li><a href=#interface-csskeyframesrule-attributes><span class=secno>6.3.2</span> Attributes</a>
<li><a href=#interface-csskeyframesrule-appendrule><span class=secno>6.3.3</span> The <code>appendRule</code> method</a>
<li><a href=#interface-csskeyframesrule-deleterule><span class=secno>6.3.4</span> The <code>deleteRule</code> method</a>
<li><a href=#interface-csskeyframesrule-findrule><span class=secno>6.3.5</span> The <code>findRule</code> method</a></ul></ul>
<li><a href=#acknowledgements><span class=secno>7</span> Acknowledgements</a>
<li><a href=#wg-resolutions-pending><span class=secno>8</span> Working Group Resolutions that are pending editing</a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a></ul></div>
<h2 class="heading settled heading" 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> CSS Transitions <a data-biblio-type=informative data-link-type=biblio href=#css3-transitions title=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> 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> 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 class="heading settled heading" 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-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>. Value types not defined in this specification are
defined in CSS Level 2 Revision 1 <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>. Other CSS modules may
expand the definitions of these value types: for example <a data-biblio-type=normative data-link-type=biblio href=#css3val title=css3val>[CSS3VAL]</a>,
when combined with this module, expands the definition of the
<a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> value type as used in this specification.
<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.
<h2 class="heading settled heading" 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-biblio-type=normative data-link-type=biblio href=#css3cascade title=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-biblio-type=normative data-link-type=biblio href=#css3cascade title=css3cascade>[CSS3CASCADE]</a>,
animations override all normal rules, but are overridden by !important
rules.
<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 title=animation-name>animation-name</a> will override the other animations at that point.
<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> 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-biblio-type=normative data-link-type=biblio href=#css3cascade title=css3cascade>[CSS3CASCADE]</a>).
<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> 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 title=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 title=animation-name>animation-name</a> is
removed. Changing the values of animation properties while the animation
is running has no effect on the amount of time that has elapsed since the
animation started running i.e. once the animation is running, updates to
<a class=property data-link-type=propdesc href=#propdef-animation-delay title=animation-delay>animation-delay</a> have no effect. The remainder of the animation runs
according to the new animation property values.
<p> Note also that changing the value
of <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> 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.
<p> The end of the animation is defined by the combination of the
<a class=property data-link-type=propdesc href=#propdef-animation-duration title=animation-duration>animation-duration</a>, <a class=property data-link-type=propdesc href=#propdef-animation-iteration-count title=animation-iteration-count>animation-iteration-count</a> and <a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=animation-fill-mode>animation-fill-mode</a>
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>
<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).
</div>
<p> Setting the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> property to <a class=css data-link-for=display data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-none title=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=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> of <a class=css data-link-for=display data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-none title=none>none</a>, updating
<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> to a value other than <a class=css data-link-for=display data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-none title=none>none</a> will start all animations applied to the element
by the <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> property, as well as all animations applied to descendants
with <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> other than <a class=css data-link-for=display data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-none title=none>none</a>.
<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-biblio-type=normative data-link-type=biblio href=#wcag20 title=wcag20>[WCAG20]</a>).
<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.
<h2 class="heading settled heading" 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 one or more times.
<p> Keyframes are specified using a specialized CSS at-rule. A <dfn class=css-code 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 title=animation-name>animation-name</a>), followed by a set of style rules (delimited by curly
braces).
<p> The keyframe selector for a keyframe style rule consists of a comma-separated list of
percentage values or the keywords <span class=css data-link-type=maybe title=from>from</span> or <span class=css data-link-type=maybe title=to>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 data-link-type=maybe title=from>from</span> is equivalent to the value <span class=css data-link-type=maybe title=0%>0%</span>. The keyword <span class=css data-link-type=maybe title=to>to</span> is equivalent to the value <span class=css data-link-type=maybe title=100%>100%</span>.
<span class=note>Note that the percentage unit specifier must be used on percentage values.
Therefore, <span class=css data-link-type=maybe title=0>0</span> is an invalid keyframe selector.</span>
<p> If a <span class=css data-link-type=maybe title=0%>0%</span> or <span class=css data-link-type=maybe title=from>from</span> keyframe is not specified, then the user agent constructs a <span class=css data-link-type=maybe title=0%>0%</span> keyframe
using the computed values of the properties being animated. If a <span class=css data-link-type=maybe title=100%>100%</span> or <span class=css data-link-type=maybe title=to>to</span> keyframe is not
specified, then the user agent constructs a <span class=css data-link-type=maybe title=100%>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 data-link-type=maybe title=100%>100%</span>, then the keyframe will be ignored.
<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 title=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> 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 title=animation-name>animation-name</a> property.
<div class=example>
<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:
<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> 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>
<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=http://dev.w3.org/csswg/css-position-3/#propdef-left title=left>left</a> property being
animated is <span class=css data-link-type=maybe title=100px>100px</span>. By 40% of the animation duration, <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#propdef-left title=left>left</a> has animated to <span class=css data-link-type=maybe title=150px>150px</span>.
At 60% of the animation duration, <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#propdef-left title=left>left</a> has animated back to <span class=css data-link-type=maybe title=75px>75px</span>. At the end of the
animation cycle, the value of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#propdef-left title=left>left</a> has returned to <span class=css data-link-type=maybe title=100px>100px</span>. The diagram below shows
the state of the animation if it were given a duration of <span class=css data-link-type=maybe title=10s>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:
<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 class="heading settled heading" 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.
<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>
<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.
</div>
<p> A timing function specified on the <span class=css data-link-type=maybe title=to>to</span> or <span class=css data-link-type=maybe title=100%>100%</span> keyframe is ignored.
<p> See the <a class=property data-link-type=propdesc href=#propdef-animation-timing-function title=animation-timing-function>animation-timing-function</a> property for more information.
<h3 class="heading settled heading" 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 title=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 title=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> 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 title=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 title=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 class=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 title=animation-name>animation-name</a>.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-animation-name>animation-name<a class=self-link href=#propdef-animation-name></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation-name title="<single-animation-name>"><single-animation-name></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a>
<p> The values of <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> have the following meanings:
<dl data-dfn-for=animation-name data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=animation-name data-dfn-type=value data-export="" id=valuedef-none0>none<a class=self-link href=#valuedef-none0></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-code data-dfn-for=animation-name data-dfn-type=value data-export="" id=valuedef-custom-ident><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a><a class=self-link href=#valuedef-custom-ident></a></dfn>
<dd>
The animation will use the keyframes with the name specified by the <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a>,
if they exist.If no such keyframes exist, there is no animation.
<p> The <a href=http://www.w3.org/TR/css3-values/#common-keywords>CSS-wide keywords</a>
and keywords defined by this property are not valid animation names.
</dl>
<h3 class="heading settled heading" 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 title=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 title=animation-duration>animation-duration</a> property defines duration of a single animation cycle.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-animation-duration>animation-duration<a class=self-link href=#propdef-animation-duration></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<dl>
<dt><dfn class=css-code data-dfn-for=animation-duration data-dfn-type=value data-export="" id=valuedef-time0><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a><a class=self-link href=#valuedef-time0></a></dfn>
<dd>
The <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> specifies the length of time that an animation takes to complete one cycle.
A negative <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> is invalid.
<p> If the <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> is <span class=css data-link-type=maybe title=0s>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 title=animation-fill-mode>animation-fill-mode</a> is set to <a class=css data-link-type=maybe href=#valuedef-backwards title=backwards>backwards</a> or
<a class=css data-link-type=maybe href=#valuedef-both title=both>both</a>, the first frame of the animation, as defined by
<a class=property data-link-type=propdesc href=#propdef-animation-direction title=animation-direction>animation-direction</a>, will be displayed during the
<a class=property data-link-type=propdesc href=#propdef-animation-delay title=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 title=animation-direction>animation-direction</a>, will be displayed if
<a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=animation-fill-mode>animation-fill-mode</a> is set to <a class=css data-link-type=maybe href=#valuedef-forwards title=forwards>forwards</a> or <a class=css data-link-type=maybe href=#valuedef-both title=both>both</a>.
If <a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=animation-fill-mode>animation-fill-mode</a> is set to <a class=css data-link-for=animation-fill-mode data-link-type=maybe href=#valuedef-none title=none>none</a>
then the animation has no visible effect.
</dl>
<h3 class="heading settled heading" 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 title=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 title=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=http://dev.w3.org/csswg/css-transitions-1/#transition-timing-function title=transition-timing-function>transition-timing-function</a> property <a data-biblio-type=normative data-link-type=biblio href=#css3-transitions title=css3-transitions>[CSS3-TRANSITIONS]</a>
for a complete description of timing function calculation.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code 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><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-timing-function title="<single-timing-function>"><single-timing-function></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> The values and meaning of <dfn class=css-code 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-code" data-link-type=type href=http://dev.w3.org/csswg/css-transitions-1/#single-transition-timing-function title="<single-transition-timing-function>"><single-transition-timing-function></a> <a data-biblio-type=normative data-link-type=biblio href=#css3-transitions title=css3-transitions>[CSS3-TRANSITIONS]</a>.
<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 title=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> When specified in a keyframe, <a class=property data-link-type=propdesc href=#propdef-animation-timing-function title=animation-timing-function>animation-timing-function</a> defines the progression of the
animation between the current keyframe and the next keyframe that defines <a class=property data-link-type=propdesc href=#propdef-animation-timing-function title=animation-timing-function>animation-timing-function</a>
in sorted keyframe selector order (or the end of the animation if no other keyframe specifies
'animation-timing function'). The specified timing function will apply over this interval independently
of the animation’s current direction.
<h3 class="heading settled heading" 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 title=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 title=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 data-link-type=maybe title=1>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 title=animation-direction>animation-direction</a> value of <a class=css data-link-type=maybe href=#valuedef-alternate title=alternate>alternate</a>, which will cause the animation to play in
reverse on alternate cycles.
<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>.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code 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><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation-iteration-count title="<single-animation-iteration-count>"><single-animation-iteration-count></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#number-value title="<number>"><number></a>
<dl data-dfn-for=animation-iteration-count data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=animation-iteration-count data-dfn-type=value data-export="" id=valuedef-infinite>infinite<a class=self-link href=#valuedef-infinite></a></dfn>
<dd>
The animation will repeat forever.
<dt><dfn class=css-code data-dfn-for=animation-iteration-count data-dfn-type=value data-export="" id=valuedef-number><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#number-value title="<number>"><number></a><a class=self-link href=#valuedef-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>A value of <span class=css data-link-type=maybe title=0>0</span> is valid and, similar to an <a class=property data-link-type=propdesc href=#propdef-animation-duration title=animation-duration>animation-duration</a>
of <span class=css data-link-type=maybe title=0s>0s</span>, causes the animation to occur instantaneously.
</dl>
<p> If the animation has a duration of <span class=css data-link-type=maybe title=0s>0s</span>, it will occur instantaneously for any
valid value of <a class=property data-link-type=propdesc href=#propdef-animation-iteration-count title=animation-iteration-count>animation-iteration-count</a>, including <a class=css data-link-type=maybe href=#valuedef-infinite title=infinite>infinite</a>.
<h3 class="heading settled heading" 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 title=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 title=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 <span class=css data-link-type=maybe title=ease-in>ease-in</span> animation would appear to be an
<span class=css data-link-type=maybe title=ease-out>ease-out</span> animation.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-animation-direction>animation-direction<a class=self-link href=#propdef-animation-direction></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation-direction title="<single-animation-direction>"><single-animation-direction></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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
<dl data-dfn-for=animation-direction data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=animation-direction data-dfn-type=value data-export="" id=valuedef-normal>normal<a class=self-link href=#valuedef-normal></a></dfn>
<dd>
All iterations of the animation are played as specified.
<dt><dfn class=css-code data-dfn-for=animation-direction data-dfn-type=value data-export="" id=valuedef-reverse>reverse<a class=self-link href=#valuedef-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-code data-dfn-for=animation-direction data-dfn-type=value data-export="" id=valuedef-alternate>alternate<a class=self-link href=#valuedef-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-code data-dfn-for=animation-direction data-dfn-type=value data-export="" id=valuedef-alternate-reverse>alternate-reverse<a class=self-link href=#valuedef-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> Note: For the purpose of determining whether an iteration is even or odd,
iterations start counting from 1.
<h3 class="heading settled heading" 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 title=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 title=animation-play-state>animation-play-state</a> property defines whether the animation is running or paused.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code 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><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation-play-state title="<single-animation-play-state>"><single-animation-play-state></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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
<dl data-dfn-for=animation-play-state data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=animation-play-state data-dfn-type=value data-export="" id=valuedef-running>running<a class=self-link href=#valuedef-running></a></dfn>
<dd>
While this property is set to <a class=css data-link-type=maybe href=#valuedef-running title=running>running</a>,
the animation proceeds as normal.
<dt><dfn class=css-code data-dfn-for=animation-play-state data-dfn-type=value data-export="" id=valuedef-paused>paused<a class=self-link href=#valuedef-paused></a></dfn>
<dd>
While this property is set to <a class=css data-link-type=maybe href=#valuedef-paused title=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=#valuedef-running title=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=#valuedef-paused title=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 title=animation-play-state>animation-play-state</a> is set back to <a class=css data-link-type=maybe href=#valuedef-running title=running>running</a>.
</dl>
<h3 class="heading settled heading" 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 title=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 title=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.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-animation-delay>animation-delay<a class=self-link href=#propdef-animation-delay></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<dl>
<dt><dfn class=css-code data-dfn-for=animation-delay data-dfn-type=value data-export="" id=valuedef-time><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a><a class=self-link href=#valuedef-time></a></dfn>
<dd>
The <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><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 data-link-type=maybe title=0s>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 data-link-type=maybe title=0s>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.
</dl>
<h3 class="heading settled heading" 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 title=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 title=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 title=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 title=animation-duration>animation-duration</a> and <a class=property data-link-type=propdesc href=#propdef-animation-iteration-count title=animation-iteration-count>animation-iteration-count</a> properties).
The <a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=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.
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code 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><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation-fill-mode title="<single-animation-fill-mode>"><single-animation-fill-mode></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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
<dl data-dfn-for=animation-fill-mode data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=animation-fill-mode data-dfn-type=value data-export="" id=valuedef-none>none<a class=self-link href=#valuedef-none></a></dfn>
<dd>
The animation has no effect when it is applied but not executing.
<dt><dfn class=css-code data-dfn-for=animation-fill-mode data-dfn-type=value data-export="" id=valuedef-forwards>forwards<a class=self-link href=#valuedef-forwards></a></dfn>
<dd>
After the animation ends (as determined by its <a class=property data-link-type=propdesc href=#propdef-animation-iteration-count title=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 title=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 title=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 title=animation-fill-mode>animation-fill-mode</a> is <a class=css data-link-type=maybe href=#valuedef-backwards title=backwards>backwards</a>).
<dt><dfn class=css-code data-dfn-for=animation-fill-mode data-dfn-type=value data-export="" id=valuedef-backwards>backwards<a class=self-link href=#valuedef-backwards></a></dfn>
<dd>
During the period defined by <a class=property data-link-type=propdesc href=#propdef-animation-delay title=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 data-link-type=maybe title=from>from</span> keyframe (when <a class=property data-link-type=propdesc href=#propdef-animation-direction title=animation-direction>animation-direction</a> is <a class=css data-link-type=maybe href=#valuedef-normal title=normal>normal</a>
or <a class=css data-link-type=maybe href=#valuedef-alternate title=alternate>alternate</a>) or those of the <span class=css data-link-type=maybe title=to>to</span> keyframe (when <a class=property data-link-type=propdesc href=#propdef-animation-direction title=animation-direction>animation-direction</a> is <a class=css data-link-type=maybe href=#valuedef-reverse title=reverse>reverse</a>
or <a class=css data-link-type=maybe href=#valuedef-alternate-reverse title=alternate-reverse>alternate-reverse</a>).
<dt><dfn class=css-code data-dfn-for=animation-fill-mode data-dfn-type=value data-export="" id=valuedef-both>both<a class=self-link href=#valuedef-both></a></dfn>
<dd>
The effects of both <a class=css data-link-type=maybe href=#valuedef-forwards title=forwards>forwards</a> and <a class=css data-link-type=maybe href=#valuedef-backwards title=backwards>backwards</a> fill apply.
</dl>
<h3 class="heading settled heading" 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 title=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 title=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 title=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 title=animation>animation</a> shorthand.)
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-animation>animation<a class=self-link href=#propdef-animation></a></dfn><tr><th>Value:<td class=prod><a class="production css-code" data-link-type=type href=#typedef-single-animation title="<single-animation>"><single-animation></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>Media:<td>interactive<tr><th>Computed value:<td>As specified<tr><th>Canonical order:<td>per grammar<tr><th>Percentages:<td>N/A<tr><th>Animatable:<td>no</table>
<p> <dfn class=css-code 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-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> || <a class="production css-code" data-link-type=type href=#typedef-single-timing-function title="<single-timing-function>"><single-timing-function></a> || <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> || <a class="production css-code" data-link-type=type href=#typedef-single-animation-iteration-count title="<single-animation-iteration-count>"><single-animation-iteration-count></a> || <a class="production css-code" data-link-type=type href=#typedef-single-animation-direction title="<single-animation-direction>"><single-animation-direction></a> || <a class="production css-code" data-link-type=type href=#typedef-single-animation-fill-mode title="<single-animation-fill-mode>"><single-animation-fill-mode></a> || <a class="production css-code" data-link-type=type href=#typedef-single-animation-play-state title="<single-animation-play-state>"><single-animation-play-state></a> || <a class="production css-code" data-link-type=type href=#typedef-single-animation-name title="<single-animation-name>"><single-animation-name></a>
<p> Note that order is important within each animation definition: the first value in each
<a class="production css-code" data-link-type=type href=#typedef-single-animation title="<single-animation>"><single-animation></a> that can be parsed as a <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> is assigned to the <a class=property data-link-type=propdesc href=#propdef-animation-duration title=animation-duration>animation-duration</a>,
and the second value in each <a class="production css-code" data-link-type=type href=#typedef-single-animation title="<single-animation>"><single-animation></a> that can be parsed as a <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#time-value title="<time>"><time></a> is assigned to
<a class=property data-link-type=propdesc href=#propdef-animation-delay title=animation-delay>animation-delay</a>.
<p> Note that order is also important within each animation definition for distinguishing
<a class="production css-code" data-link-type=type href=#typedef-single-animation-name title="<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 title=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 title=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 title=animation-name>animation-name</a> that could
be a value of another property, and may be output in additional cases.
<div class=example>
For example, a value parsed from <a class=css data-link-type=propdesc href=#propdef-animation title=animation>animation: 3s none backwards</a>
(where <a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=animation-fill-mode>animation-fill-mode</a> is <a class=css data-link-for=animation-fill-mode data-link-type=maybe href=#valuedef-none title=none>none</a>
and <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> is <span class=css data-link-for=animation-name data-link-type=maybe title=backwards>backwards</span>)
must not be serialized as <a class=css data-link-type=propdesc href=#propdef-animation title=animation>animation: 3s backwards</a>
(where <a class=property data-link-type=propdesc href=#propdef-animation-fill-mode title=animation-fill-mode>animation-fill-mode</a> is <a class=css data-link-for=animation-fill-mode data-link-type=maybe href=#valuedef-backwards title=backwards>backwards</a>
and <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> is <a class=css data-link-for=animation-name data-link-type=maybe href=#valuedef-none0 title=none>none</a>).
</div>
<h2 class="heading settled heading" 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 title=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 title=animation-name>animation-name</a> values. For the purposes of events, each <a class=property data-link-type=propdesc href=#propdef-animation-name title=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 title=animation-name>animation-name</a> value and
not necessarily for each property being animated.
<p> Any animation for which a valid keyframe rule is defined will run
and generate events; this includes animations with empty keyframe rules.
<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=#valuedef-paused title=paused>paused</a>
play state.
<h3 class="heading settled heading" 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 <dfn data-dfn-type=dfn data-noexport="" id=animationevent>AnimationEvent<a class=self-link href=#animationevent></a></dfn> interface provides specific contextual information associated with
Animation events.
<h4 class="heading settled heading" 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>[Constructor(DOMString <dfn class=idl-code data-dfn-for=AnimationEvent/AnimationEvent() data-dfn-type=argument data-export="" data-global-name="AnimationEvent<interface>/AnimationEvent()<method>/type<argument>" id=dom-animationeventanimationevent-type>type<a class=self-link href=#dom-animationeventanimationevent-type></a></dfn>, optional <a data-link-type=idl href=#dictdef-animationeventinit title=animationeventinit>AnimationEventInit</a> <dfn class=idl-code data-dfn-for=AnimationEvent/AnimationEvent() data-dfn-type=argument data-export="" data-global-name="AnimationEvent<interface>/AnimationEvent()<method>/animationeventinitdict<argument>" id=dom-animationeventanimationevent-animationeventinitdict>animationEventInitDict<a class=self-link href=#dom-animationeventanimationevent-animationeventinitdict></a></dfn>)]
interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-animationevent>AnimationEvent<a class=self-link href=#dom-animationevent></a></dfn> : <a data-link-type=idl href=http://dom.spec.whatwg.org/#event title=event>Event</a> {
readonly attribute DOMString <a class=idl-code data-global-name="AnimationEvent<interface>/animationname<attribute>" data-link-for=AnimationEvent data-link-type=attribute href=#dom-animationevent-animationname title=animationname>animationName</a>;
readonly attribute float <a class=idl-code data-global-name="AnimationEvent<interface>/elapsedtime<attribute>" data-link-for=AnimationEvent data-link-type=attribute href=#dom-animationevent-elapsedtime title=elapsedtime>elapsedTime</a>;
readonly attribute DOMString <a class=idl-code data-global-name="AnimationEvent<interface>/pseudoelement<attribute>" data-link-for=AnimationEvent data-link-type=attribute href=#dom-animationevent-pseudoelement title=pseudoelement>pseudoElement</a>;
};
dictionary <dfn class=idl-code data-dfn-type=dictionary data-export="" data-global-name="" id=dictdef-animationeventinit>AnimationEventInit<a class=self-link href=#dictdef-animationeventinit></a></dfn> : <a data-link-type=idl href=http://dom.spec.whatwg.org/#eventinit title=eventinit>EventInit</a> {
DOMString <dfn class=idl-code data-dfn-for=AnimationEventInit data-dfn-type=dict-member data-export="" data-global-name="AnimationEventInit<dictionary>/animationname<dict-member>" id=dom-animationeventinit-animationname>animationName<a class=self-link href=#dom-animationeventinit-animationname></a></dfn> = "";
float <dfn class=idl-code data-dfn-for=AnimationEventInit data-dfn-type=dict-member data-export="" data-global-name="AnimationEventInit<dictionary>/elapsedtime<dict-member>" id=dom-animationeventinit-elapsedtime>elapsedTime<a class=self-link href=#dom-animationeventinit-elapsedtime></a></dfn> = 0.0;
DOMString <dfn class=idl-code data-dfn-for=AnimationEventInit data-dfn-type=dict-member data-export="" data-global-name="AnimationEventInit<dictionary>/pseudoelement<dict-member>" id=dom-animationeventinit-pseudoelement>pseudoElement<a class=self-link href=#dom-animationeventinit-pseudoelement></a></dfn> = "";
};
</pre>
<h4 class="heading settled heading" 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 data-dfn-for=AnimationEvent data-dfn-type=attribute>
<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 <a class=idl-code data-link-type=interface title=domstring>DOMString</a>, readonly
<dd>
The value of the <a class=property data-link-type=propdesc href=#propdef-animation-name title=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
<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 data-link-type=maybe title=animationstart>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 title=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 <a class=idl-code data-link-type=interface title=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-code data-dfn-type=function data-export="" id=funcdef-animationevent title=animationevent()>AnimationEvent(type, animationEventInitDict)<a class=self-link href=#funcdef-animationevent></a></dfn> is an <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events>event constructor</a>.
<h3 class="heading settled heading" 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:
<dl data-dfn-for=animationevent data-dfn-type=event>
<dt><dfn class=idl-code data-dfn-for=animationevent data-dfn-type=event data-export="" id=dom-animationevent-animationstart>animationstart<a class=self-link href=#dom-animationevent-animationstart></a></dfn>
<dd>
The <a data-link-type=idl href=#dom-animationevent-animationstart title=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 title=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
event will fire whether <a class=property data-link-type=propdesc href=#propdef-animation-play-state title=animation-play-state>animation-play-state</a> is set to <a class=css data-link-type=maybe href=#valuedef-running title=running>running</a> or <a class=css data-link-type=maybe href=#valuedef-paused title=paused>paused</a>.
<ul>
<li>Bubbles: Yes</li>
<li>Cancelable: No</li>
<li>Context Info: animationName, pseudoElement</li>
</ul>
<dt><dfn class=idl-code data-dfn-for=animationevent data-dfn-type=event data-export="" id=dom-animationevent-animationend>animationend<a class=self-link href=#dom-animationevent-animationend></a></dfn>
<dd>
The <a data-link-type=idl href=#dom-animationevent-animationend title=animationend>animationend</a> 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 class=idl-code data-dfn-for=animationevent data-dfn-type=event data-export="" id=dom-animationevent-animationiteration>animationiteration<a class=self-link href=#dom-animationevent-animationiteration></a></dfn>
<dd>
The <a data-link-type=idl href=#dom-animationevent-animationiteration title=animationiteration>animationiteration</a> 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>
<h2 class="heading settled heading" data-level=6 id=interface-dom><span class=secno>6 </span><span class=content>
DOM Interfaces</span><a class=self-link href=#interface-dom></a></h2>
<p> CSS animations are exposed to the CSSOM through a pair of new interfaces describing the keyframes.
<h3 class="heading settled heading" data-level=6.1 id=interface-cssrule><span class=secno>6.1 </span><span class=content>
The <code>CSSRule</code> Interface</span><a class=self-link href=#interface-cssrule></a></h3>
<p> The following two rule types are added to the <a data-link-type=idl href=http://dev.w3.org/csswg/cssom-1/#cssrule title=cssrule>CSSRule</a> interface. They provide
identification for the new keyframe and keyframes rules.
<h4 class="heading settled heading" data-level=6.1.1 id=interface-cssrule-idl><span class=secno>6.1.1 </span><span class=content>
IDL Definition</span><a class=self-link href=#interface-cssrule-idl></a></h4>
<pre class=idl>partial interface <a class=idl-code data-global-name="" data-link-type=interface href=http://dev.w3.org/csswg/cssom-1/#cssrule title=cssrule>CSSRule</a> {
const unsigned short <dfn class=idl-code data-dfn-for=CSSRule data-dfn-type=const data-export="" data-global-name="CSSRule<interface>/keyframes_rule<const>" id=dom-cssrule-keyframes_rule>KEYFRAMES_RULE<a class=self-link href=#dom-cssrule-keyframes_rule></a></dfn> = 7;
const unsigned short <dfn class=idl-code data-dfn-for=CSSRule data-dfn-type=const data-export="" data-global-name="CSSRule<interface>/keyframe_rule<const>" id=dom-cssrule-keyframe_rule>KEYFRAME_RULE<a class=self-link href=#dom-cssrule-keyframe_rule></a></dfn> = 8;
};
</pre>
<h3 class="heading settled heading" data-level=6.2 id=interface-csskeyframerule><span class=secno>6.2 </span><span class=content>
The <code>CSSKeyframeRule</code> Interface</span><a class=self-link href=#interface-csskeyframerule></a></h3>
<p> The <a data-link-type=idl href=#dom-csskeyframerule title=csskeyframerule>CSSKeyframeRule</a> interface represents the style rule for a single key.
<h4 class="heading settled heading" data-level=6.2.1 id=interface-csskeyframerule-idl><span class=secno>6.2.1 </span><span class=content>
IDL Definition</span><a class=self-link href=#interface-csskeyframerule-idl></a></h4>
<pre class=idl>interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-csskeyframerule>CSSKeyframeRule<a class=self-link href=#dom-csskeyframerule></a></dfn> : <a data-link-type=idl href=http://dev.w3.org/csswg/cssom-1/#cssrule title=cssrule>CSSRule</a> {
attribute DOMString <a class=idl-code data-global-name="CSSKeyframeRule<interface>/keytext<attribute>" data-link-for=CSSKeyframeRule data-link-type=attribute href=#dom-csskeyframerule-keytext title=keytext>keyText</a>;
readonly attribute <a data-link-type=idl href=http://dev.w3.org/csswg/cssom-1/#cssstyledeclaration title=cssstyledeclaration>CSSStyleDeclaration</a> <a class=idl-code data-global-name="CSSKeyframeRule<interface>/style<attribute>" data-link-for=CSSKeyframeRule data-link-type=attribute href=#dom-csskeyframerule-style title=style>style</a>;
};
</pre>
<h4 class="heading settled heading" data-level=6.2.2 id=interface-csskeyframerule-attributes><span class=secno>6.2.2 </span><span class=content>
Attributes</span><a class=self-link href=#interface-csskeyframerule-attributes></a></h4>
<dl data-dfn-for=CSSKeyframeRule data-dfn-type=attribute>
<dt><dfn class=idl-code data-dfn-for=CSSKeyframeRule data-dfn-type=attribute data-export="" id=dom-csskeyframerule-keytext>keyText<a class=self-link href=#dom-csskeyframerule-keytext></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dd>
This attribute represents the keyframe selector as a comma-separated list of
percentage values. The <span class=css data-link-type=maybe title=from>from</span> and <span class=css data-link-type=maybe title=to>to</span> keywords map to 0% and 100%,
respectively.
<p> If <a class=idl-code data-link-for=CSSKeyframeRule data-link-type=attribute href=#dom-csskeyframerule-keytext title=keytext>keyText</a> is updated with an invalid keyframe selector,
a <a data-link-spec=webidl data-link-type=dfn href=https://heycam.github.io/webidl/#syntaxerror title=syntaxerror>SyntaxError</a> exception must be thrown.
<dt><dfn class=idl-code data-dfn-for=CSSKeyframeRule data-dfn-type=attribute data-export="" id=dom-csskeyframerule-style>style<a class=self-link href=#dom-csskeyframerule-style></a></dfn>, of type <a class=idl-code data-link-type=interface href=http://dev.w3.org/csswg/cssom-1/#cssstyledeclaration title=cssstyledeclaration>CSSStyleDeclaration</a>
<dd>
This attribute represents the style associated with this keyframe.
</dl>
<h3 class="heading settled heading" data-level=6.3 id=interface-csskeyframesrule><span class=secno>6.3 </span><span class=content>
The <code>CSSKeyframesRule</code> Interface</span><a class=self-link href=#interface-csskeyframesrule></a></h3>
<p> The <a data-link-type=idl href=#dom-csskeyframesrule title=csskeyframesrule>CSSKeyframesRule</a> interface represents a complete set of keyframes for
a single animation.
<h4 class="heading settled heading" data-level=6.3.1 id=interface-csskeyframesrule-idl><span class=secno>6.3.1 </span><span class=content>
IDL Definition</span><a class=self-link href=#interface-csskeyframesrule-idl></a></h4>
<pre class=idl>interface <dfn class=idl-code data-dfn-type=interface data-export="" data-global-name="" id=dom-csskeyframesrule>CSSKeyframesRule<a class=self-link href=#dom-csskeyframesrule></a></dfn> : <a data-link-type=idl href=http://dev.w3.org/csswg/cssom-1/#cssrule title=cssrule>CSSRule</a> {
attribute DOMString <a class=idl-code data-global-name="CSSKeyframesRule<interface>/name<attribute>" data-link-for=CSSKeyframesRule data-link-type=attribute href=#dom-csskeyframesrule-name title=name>name</a>;
readonly attribute <a data-link-type=idl href=http://dev.w3.org/csswg/cssom-1/#cssrulelist title=cssrulelist>CSSRuleList</a> <a class=idl-code data-global-name="CSSKeyframesRule<interface>/cssrules<attribute>" data-link-for=CSSKeyframesRule data-link-type=attribute href=#dom-csskeyframesrule-cssrules title=cssrules>cssRules</a>;
void <a class=idl-code data-global-name="CSSKeyframesRule<interface>/appendrule()<method>" data-link-for=CSSKeyframesRule data-link-type=method href=#dom-csskeyframesrule-appendrule title=appendrule()>appendRule</a>(DOMString <a class=idl-code data-global-name="CSSKeyframesRule<interface>/appendRule()<method>/rule<argument>" data-link-for=CSSKeyframesRule/appendRule() data-link-type=argument href=#dom-csskeyframesruleappendrule-rule title=rule>rule</a>);
void <a class=idl-code data-global-name="CSSKeyframesRule<interface>/deleterule()<method>" data-link-for=CSSKeyframesRule data-link-type=method href=#dom-csskeyframesrule-deleterule title=deleterule()>deleteRule</a>(DOMString <a class=idl-code data-global-name="CSSKeyframesRule<interface>/deleteRule()<method>/select<argument>" data-link-for=CSSKeyframesRule/deleteRule() data-link-type=argument href=#dom-csskeyframesruledeleterule-select title=select>select</a>);
<a data-link-type=idl href=#dom-csskeyframerule title=csskeyframerule>CSSKeyframeRule</a>? <a class=idl-code data-global-name="CSSKeyframesRule<interface>/findrule()<method>" data-link-for=CSSKeyframesRule data-link-type=method href=#dom-csskeyframesrule-findrule title=findrule()>findRule</a>(DOMString <a class=idl-code data-global-name="CSSKeyframesRule<interface>/findRule()<method>/select<argument>" data-link-for=CSSKeyframesRule/findRule() data-link-type=argument href=#dom-csskeyframesrulefindrule-select title=select>select</a>);
};
</pre>
<h4 class="heading settled heading" data-level=6.3.2 id=interface-csskeyframesrule-attributes><span class=secno>6.3.2 </span><span class=content>
Attributes</span><a class=self-link href=#interface-csskeyframesrule-attributes></a></h4>
<dl data-dfn-for=CSSKeyframesRule data-dfn-type=attribute>
<dt><dfn class=idl-code data-dfn-for=CSSKeyframesRule data-dfn-type=attribute data-export="" id=dom-csskeyframesrule-name>name<a class=self-link href=#dom-csskeyframesrule-name></a></dfn>, of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dd>
This attribute is the name of the keyframes, used by the <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> property.
<p> Setting this property to a value matching a
<a href=http://www.w3.org/TR/css3-values/#common-keywords>CSS-wide keyword</a>
or any keyword defined for the <a class=property data-link-type=propdesc href=#propdef-animation-name title=animation-name>animation-name</a> property will throw a <a data-link-spec=webidl data-link-type=dfn href=https://heycam.github.io/webidl/#syntaxerror title=syntaxerror>SyntaxError</a>
exception.
<dt><dfn class=idl-code data-dfn-for=CSSKeyframesRule data-dfn-type=attribute data-export="" id=dom-csskeyframesrule-cssrules>cssRules<a class=self-link href=#dom-csskeyframesrule-cssrules></a></dfn>, of type <a class=idl-code data-link-type=interface href=http://dev.w3.org/csswg/cssom-1/#cssrulelist title=cssrulelist>CSSRuleList</a>
<dd>
This attribute gives access to the keyframes in the list.
</dl>
<h4 class="heading settled heading" data-level=6.3.3 id=interface-csskeyframesrule-appendrule><span class=secno>6.3.3 </span><span class=content>
The <code>appendRule</code> method</span><a class=self-link href=#interface-csskeyframesrule-appendrule></a></h4>
<p> The <dfn class=idl-code data-dfn-for=CSSKeyframesRule data-dfn-type=method data-export="" id=dom-csskeyframesrule-appendrule title=appendrule()>appendRule()<a class=self-link href=#dom-csskeyframesrule-appendrule></a></dfn> method appends the passed
<a data-link-type=idl href=#dom-csskeyframerule title=csskeyframerule>CSSKeyframeRule</a> at the end of the keyframes rule.
<p> Parameters:
<dl>
<dt><dfn class=idl-code data-dfn-for=CSSKeyframesRule/appendRule() data-dfn-type=argument data-export="" id=dom-csskeyframesruleappendrule-rule>rule<a class=self-link href=#dom-csskeyframesruleappendrule-rule></a></dfn> of type <a class=idl-code data-link-type=interface title=domstring>DOMString</a>
<dd>
The rule to be appended, expressed in the same syntax as one entry in the
<a class=css data-link-type=maybe href=#at-ruledef-keyframes title=@keyframes>@keyframes</a> rule. A valid rule is always appended e.g. even if its key(s) already
exists.
</dl>
<p> No Return Value
<p> No Exceptions
<h4 class="heading settled heading" data-level=6.3.4 id=interface-csskeyframesrule-deleterule><span class=secno>6.3.4 </span><span class=content>
The <code>deleteRule</code> method</span><a class=self-link href=#interface-csskeyframesrule-deleterule></a></h4>
<p> The <dfn class=idl-code data-dfn-for=CSSKeyframesRule data-dfn-type=method data-export="" id=dom-csskeyframesrule-deleterule title=deleterule()>deleteRule()<a class=self-link href=#dom-csskeyframesrule-deleterule></a></dfn> deletes the