css3-animations/Overview.html

Wed, 28 Mar 2012 22:14:48 -0700

author
L. David Baron <dbaron@dbaron.org>
date
Wed, 28 Mar 2012 22:14:48 -0700
changeset 5304
b531bcdc39f7
parent 5303
083f80ca0535
child 5312
f2453d922d28
permissions
-rw-r--r--

Add two additional values for animation-direction: reverse and alternate-reverse .

This is as proposed in
http://lists.w3.org/Archives/Public/www-style/2011May/0548.html
and resolved in the group's 2012 March 28 teleconference per
http://lists.w3.org/Archives/Public/www-style/2012Mar/0655.html

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
     2 "http://www.w3.org/TR/html4/strict.dtd">
     4 <html lang=en>
     5  <head>
     6   <title>CSS Animations</title>
     7   <link href="../default.css" rel=stylesheet type="text/css">
     8   <link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
     9   type="text/css">
    11  <body>
    12   <div class=head> <!--begin-logo-->
    13    <p><a href="http://www.w3.org/"><img alt=W3C height=48
    14     src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
    16    <h1>CSS Animations</h1>
    18    <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 29 March 2012</h2>
    20    <dl>
    21     <dt>This version:
    23     <dd><a
    24      href="http://www.w3.org/TR/2012/ED-css3-animations-20120329/">http://dev.w3.org/csswg/css3-animations/</a>
    25      <!--http://www.w3.org/TR/2012/WD-css3-animations-20120329-->
    27     <dt>Latest version:
    29     <dd><a
    30      href="http://www.w3.org/TR/css3-animations">http://www.w3.org/TR/css3-animations/</a>
    33     <dt>Editor's draft:
    35     <dd><a
    36      href="http://dev.w3.org/csswg/css3-animations/">http://dev.w3.org/csswg/css3-animations/</a>
    39     <dt>Previous version:
    41     <dd><a href="http://www.w3.org/TR/2009/WD-css3-animations-20090320/">
    42      http://www.w3.org/TR/2009/WD-css3-animations-20090320/</a>
    44     <dt id=editors-list>Editors:
    46     <dd><a href="mailto:dino@apple.com">Dean Jackson</a> (<a
    47      href="http://www.apple.com/">Apple Inc</a>)
    49     <dd><a href="mailto:hyatt@apple.com">David Hyatt</a> (<a
    50      href="http://www.apple.com/">Apple Inc</a>)
    52     <dd><a href="mailto:cmarrin@apple.com">Chris Marrin</a> (<a
    53      href="http://www.apple.com/">Apple Inc</a>)
    55     <dd><a href="mailto:sylvaing@microsoft.com">Sylvain Galineau</a> (<a
    56      class=org href="http://www.microsoft.com/">Microsoft</a>)
    58     <dd class=vcard><a class=fn href="http://dbaron.org/">L. David Baron</a>
    59      (<a class=org href="http://www.mozilla.org/">Mozilla</a>)
    61     <dt>Issues list:
    63     <dd><a
    64      href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&amp;product=CSS&amp;component=Animations&amp;resolution=---&amp;cmdtype=doit">in
    65      Bugzilla</a>
    67     <dt>Discussion:
    69     <dd><a
    70      href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a>
    71      with subject line &ldquo;<kbd>[css3-animations] <var>&hellip; message
    72      topic &hellip;</var></kbd>&rdquo;
    74     <dt>Test suite:
    76     <dd>none yet
    77    </dl>
    78    <!--begin-copyright-->
    79    <p class=copyright><a
    80     href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
    81     rel=license>Copyright</a> &copy; 2012 <a href="http://www.w3.org/"><abbr
    82     title="World Wide Web Consortium">W3C</abbr></a><sup>&reg;</sup> (<a
    83     href="http://www.csail.mit.edu/"><abbr
    84     title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
    85     href="http://www.ercim.eu/"><abbr
    86     title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
    87     <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
    88     href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
    89     <a
    90     href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
    91     and <a
    92     href="http://www.w3.org/Consortium/Legal/copyright-documents">document
    93     use</a> rules apply.</p>
    94    <!--end-copyright-->
    95    <hr title="Separator for header">
    96   </div>
    98   <h2 class="no-num no-toc" id=abstract>Abstract</h2>
   100   <p>This CSS module describes a way for authors to animate the values of CSS
   101    properties over time, using keyframes. The behavior of these keyframe
   102    animations can be controlled by specifying their duration, number of
   103    repeats, and repeating behavior.
   105   <h2 class="no-num no-toc" id=status>Status of this document</h2>
   106   <!--begin-status-->
   108   <p>This is a public copy of the editors' draft. It is provided for
   109    discussion only and may change at any moment. Its publication here does
   110    not imply endorsement of its contents by W3C. Don't cite this document
   111    other than as work in progress.
   113   <p>The (<a
   114    href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
   115    mailing list <a
   116    href="mailto:www-style@w3.org?Subject=%5Bcss3-animations%5D%20PUT%20SUBJECT%20HERE">
   117    www-style@w3.org</a> (see <a
   118    href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
   119    discussion of this specification. When sending e-mail, please put the text
   120    &#8220;css3-animations&#8221; in the subject, preferably like this:
   121    &#8220;[<!---->css3-animations<!---->] <em>&hellip;summary of
   122    comment&hellip;</em>&#8221;
   124   <p>This document was produced by the <a href="/Style/CSS/members">CSS
   125    Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
   127   <p>This document was produced by a group operating under the <a
   128    href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
   129    Policy</a>. W3C maintains a <a href="/2004/01/pp-impl/32061/status"
   130    rel=disclosure>public list of any patent disclosures</a> made in
   131    connection with the deliverables of the group; that page also includes
   132    instructions for disclosing a patent. An individual who has actual
   133    knowledge of a patent which the individual believes contains <a
   134    href="/Consortium/Patent-Policy-20040205/#def-essential">Essential
   135    Claim(s)</a> must disclose the information in accordance with <a
   136    href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
   137    W3C Patent Policy</a>.</p>
   138   <!--end-status-->
   140   <h2 class="no-num no-toc" id=contents>Table of contents</h2>
   141   <!--begin-toc-->
   143   <ul class=toc>
   144    <li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
   146    <li><a href="#animations"><span class=secno>2. </span>Animations</a>
   148    <li><a href="#keyframes"><span class=secno>3. </span>Keyframes</a>
   149     <ul class=toc>
   150      <li><a href="#timing-functions-for-keyframes-"><span class=secno>3.1.
   151       </span> Timing functions for keyframes </a>
   153      <li><a href="#the-animation-name-property-"><span class=secno>3.2.
   154       </span> The <code class=property>'animation-name'</code> Property </a>
   156      <li><a href="#the-animation-duration-property-"><span class=secno>3.3.
   157       </span> The <code class=property>'animation-duration'</code> Property
   158       </a>
   160      <li><a href="#animation-timing-function_tag"><span class=secno>3.4.
   161       </span> The <code class=property>'animation-timing-function'</code>
   162       Property </a>
   164      <li><a href="#the-animation-iteration-count-property-"><span
   165       class=secno>3.5. </span> The <code
   166       class=property>'animation-iteration-count'</code> Property </a>
   168      <li><a href="#the-animation-direction-property-"><span class=secno>3.6.
   169       </span> The <code class=property>'animation-direction'</code> Property
   170       </a>
   172      <li><a href="#the-animation-play-state-property-"><span class=secno>3.7.
   173       </span> The <code class=property>'animation-play-state'</code> Property
   174       </a>
   176      <li><a href="#the-animation-delay-property-"><span class=secno>3.8.
   177       </span> The <code class=property>'animation-delay'</code> Property </a>
   180      <li><a href="#the-animation-fill-mode-property-"><span class=secno>3.9.
   181       </span> The <code class=property>'animation-fill-mode'</code> Property
   182       </a>
   184      <li><a href="#the-animation-shorthand-property-"><span class=secno>3.10.
   185       </span> The <code class=property>'animation'</code> Shorthand Property
   186       </a>
   187     </ul>
   189    <li><a href="#animation-events-"><span class=secno>4. </span> Animation
   190     Events </a>
   192    <li><a href="#dom-interfaces-"><span class=secno>5. </span> DOM Interfaces
   193     </a>
   195    <li><a href="#acknowledgments"><span class=secno>6.
   196     </span>Acknowledgments</a>
   198    <li><a href="#references"><span class=secno>7. </span>References</a>
   199     <ul class=toc>
   200      <li class=no-num><a href="#normative-references">Normative
   201       references</a>
   203      <li class=no-num><a href="#other-references">Other references</a>
   204     </ul>
   206    <li class=no-num><a href="#property-index">Property index</a>
   208    <li class=no-num><a href="#index">Index</a>
   209   </ul>
   210   <!--end-toc-->
   212   <h2 id=introduction><span class=secno>1. </span>Introduction</h2>
   214   <p><em>This section is not normative.</em>
   216   <p> CSS Transitions <a href="#CSS3-TRANSITIONS"
   217    rel=biblioentry>[CSS3-TRANSITIONS]<!--{{!CSS3-TRANSITIONS}}--></a> provide
   218    a way to interpolate CSS property values when they change as a result of
   219    underlying property changes. This provides an easy way to do simple
   220    animation, but the start and end states of the animation are controlled by
   221    the existing property values, and transitions provide little control to
   222    the author on how the animation progresses.
   224   <p> This proposal introduces <em>defined animations</em>, in which the
   225    author can specify the changes in CSS properties over time as a set of
   226    keyframes. Animations are similar to transitions in that they change the
   227    presentational value of CSS properties over time. The principal difference
   228    is that while transitions trigger <i>implicitly</i> when property values
   229    change, animations are <i>explicitly</i> executed when the animation
   230    properties are applied. Because of this, animations require explicit
   231    values for the properties being animated. These values are specified using
   232    animation keyframes, described below.
   234   <p> Many aspects of the animation can be controlled, including how many
   235    times the animation iterates, whether or not it alternates between the
   236    begin and end values, and whether or not the animation should be running
   237    or paused. An animation can also delay its start time.
   239   <h2 id=animations><span class=secno>2. </span>Animations</h2>
   241   <p> CSS Animations affect computed property values. During the execution of
   242    an animation, the computed value for a property is controlled by the
   243    animation. This overrides the value specified in the normal styling
   244    system.
   246   <p> In the case of multiple animations specifying behavior for the same
   247    property, the animation defined last will override the previously defined
   248    animations.
   250   <p> An animation does not affect the computed value before the application
   251    of the animation, before the animation delay has expired, and after the
   252    end of the animation.
   254   <div class=figure> <img alt="" src=sandwich.png></div>
   256   <p class=caption> Computation of animated property values
   258   <p> The diagram above shows how property values are computed. The intrinsic
   259    style is shown at the top of the diagram. The computed value is derived
   260    from intrinsic style at the times when an animation is not running and
   261    also when an animation is delayed (see below for specification of
   262    animation delay). During an animation, the computed style is derived from
   263    the animated value.
   265   <p> The start time of an animation is the latter of two moments: the time
   266    at which the style is resolved that specifies the animation, or the time
   267    the document's load event is fired. Therefore, an animation specified in
   268    the document style sheet will begin at the document load. An animation
   269    specified on an element by modifying the style after the document has
   270    loaded will start when the style is resolved. That may be immediately in
   271    the case of a pseudo style rule such as hover, or may be when the
   272    scripting engine returns control to the browser (in the case of style
   273    applied by script).
   275   <p> An animation applies to an element if the element has a value for <a
   276    href="#animation-name"><code class=property>'animation-name'</code></a>
   277    that references a valid keyframes rule. Once an animation has started it
   278    continues until it ends or the <a href="#animation-name"><code
   279    class=property>'animation-name'</code></a> is removed. The values used for
   280    the keyframes and animation properties are snapshotted at the time the
   281    animation starts. Changing them during the execution of the animation has
   282    no effect. Note also, that changing the value of <a
   283    href="#animation-name"><code class=property>'animation-name'</code></a>
   284    does not necessarily restart an animation (e.g., if a list of animations
   285    are applied and one is removed from the list, only that animation will
   286    stop; The other animations will continue). In order to restart an
   287    animation, it must be removed then reapplied.
   289   <p> The end of the animation is defined by the combination of the <a
   290    href="#animation-duration"><code
   291    class=property>'animation-duration'</code></a>, <a
   292    href="#animation-iteration-count"><code
   293    class=property>'animation-iteration-count'</code></a> and <a
   294    href="#animation-fill-mode"><code
   295    class=property>'animation-fill-mode'</code></a> properties.
   297   <div class=example>
   298    <p style="display:none"> Example(s):</p>
   300    <pre>
   301     div {
   302       animation-name: diagonal-slide;
   303       animation-duration: 5s;
   304       animation-iteration-count: 10;
   305     }
   307     @keyframes diagonal-slide {
   309       from {
   310         left: 0;
   311         top: 0;
   312       }
   314       to {
   315         left: 100px;
   316         top: 100px;
   317       }
   319     }
   321     </pre>
   322    This will produce an animation that moves an element from (0, 0) to
   323    (100px, 100px) over five seconds and repeats itself nine times (for a
   324    total of ten iterations).</div>
   326   <h2 id=keyframes><span class=secno>3. </span>Keyframes</h2>
   328   <p> Keyframes are used to specify the values for the animating properties
   329    at various points during the animation. The keyframes specify the behavior
   330    of one cycle of the animation; the animation may iterate one or more
   331    times.
   333   <p> Keyframes are specified using a specialized CSS at-rule. A <code
   334    class=property>@keyframes</code> rule consists of the keyword
   335    "@keyframes", followed by an identifier giving a name for the animation
   336    (which will be referenced using <a href="#animation-name"><code
   337    class=property>'animation-name'</code></a>), followed by a set of style
   338    rules (delimited by curly braces).
   340   <p> The <i>keyframe selector</i> for a keyframe style rule consists of a
   341    comma-separated list of percentage values or the keywords &lsquo;<code
   342    class=property>from</code>&rsquo; or &lsquo;<code
   343    class=property>to</code>&rsquo;. The selector is used to specify the
   344    percentage along the duration of the animation that the keyframe
   345    represents. The keyframe itself is specified by the block of property
   346    values declared on the selector. The keyword &lsquo;<code
   347    class=property>from</code>&rsquo; is equivalent to the value 0%. The
   348    keyword &lsquo;<code class=property>to</code>&rsquo; is equivalent to the
   349    value 100%. Note that the percentage unit specifier must be used on
   350    percentage values. Therefore, "0" is an invalid keyframe selector.
   352   <p> If a 0% or "from" keyframe is not specified, then the user agent
   353    constructs a 0% keyframe using the computed values of the properties being
   354    animated. If a 100% or "to" keyframe is not specified, then the user agent
   355    constructs a 100% keyframe using the computed values of the properties
   356    being animated.
   358   <p> The <i>keyframe declaration</i> for a keyframe rule consists of
   359    properties and values. Properties that are unable to be animated are
   360    ignored in these rules, with the exception of <a
   361    href="#animation-timing-function"><code
   362    class=property>'animation-timing-function'</code></a>, the behavior of
   363    which is described below.
   365   <p class=note> NOTE: describe what happens if a property is not present in
   366    all keyframes.
   368   <p> The @keyframes rule that is used by an animation will be the last one
   369    encountered in sorted rules order that matches the name of the animation
   370    specified by the <a href="#animation-name"><code
   371    class=property>'animation-name'</code></a> property. <code
   372    class=css>@keyframes</code> rules do not cascade; therefore an animation
   373    will never derive keyframes from more than one <code
   374    class=css>@keyframes</code> rule.
   376   <p> To determine the set of keyframes, all of the values in the selectors
   377    are sorted in increasing order by time. If there are any duplicates, then
   378    the last keyframe specified inside the <code class=css>@keyframes</code>
   379    rule will be used to provide the keyframe information for that time. There
   380    is no cascading within a <code class=css>@keyframes</code> rule if
   381    multiple keyframes specify the same keyframe selector values.
   383   <p> If property is not specified for a keyframe, or is specified but
   384    invalid, the animation of that property proceeds as if that keyframe did
   385    not exist. Conceptually, it is as if a set of keyframes is constructed for
   386    each property that is present in any of the keyframes, and an animation is
   387    run independently for each property.
   389   <div class=example>
   390    <p style="display:none"> Example(s):</p>
   392    <pre>
   393   @keyframes wobble {
   394     0% {
   395       left: 100px;
   396     }
   398     40% {
   399       left: 150px;
   400     }
   402     60% {
   403       left: 75px;
   404     }
   406     100% {
   407       left: 100px;
   408     }
   409   }
   411   </pre>
   412    Four keyframes are specified for the animation named "wobble". In the
   413    first keyframe, shown at the beginning of the animation cycle, the
   414    &lsquo;<code class=property>left</code>&rsquo; value of the animation is
   415    100px. By 40% of the animation duration, &lsquo;<code
   416    class=property>left</code>&rsquo; value has animated to 150px. At 60% of
   417    the animation duration, the &lsquo;<code class=property>left</code>&rsquo;
   418    value has animated back to 75px. At the end of the animation cycle, the
   419    &lsquo;<code class=property>left</code>&rsquo; value has returned to
   420    100px. The diagram below shows the state of the animation if it were given
   421    a duration of 10s.
   422    <div class=figure> <img alt="" src=animation1.png></div>
   424    <p class=caption> Animations states specified by keyframes</p>
   425   </div>
   427   <p> The following is the grammar for the keyframes rule.
   429   <pre>
   431         keyframes_rule: KEYFRAMES_SYM S+ IDENT S* '{' S* keyframes_blocks '}' S*;
   433         keyframes_blocks: [ keyframe_selector '{' S* declaration? [ ';' S* declaration? ]* '}' S* ]* ;
   435         keyframe_selector: [ FROM_SYM | TO_SYM | PERCENTAGE ] S* [ ',' S* [ FROM_SYM | TO_SYM | PERCENTAGE ] S* ]*;
   437         @{K}{E}{Y}{F}{R}{A}{M}{E}{S}   {return KEYFRAMES_SYM;}
   438         {F}{R}{O}{M}                   {return FROM_SYM;}
   439         {T}{O}                         {return TO_SYM;}
   440       </pre>
   441   <!-- ======================================================================================================= -->
   443   <h3 id=timing-functions-for-keyframes-><span class=secno>3.1. </span>
   444    Timing functions for keyframes</h3>
   446   <p> A keyframe style rule may also declare the timing function that is to
   447    be used as the animation moves to the next keyframe.
   449   <div class=example>
   450    <p style="display:none"> Example(s):</p>
   452    <pre>
   453   @keyframes bounce {
   455     from {
   456       top: 100px;
   457       animation-timing-function: ease-out;
   458     }
   460     25% {
   461       top: 50px;
   462       animation-timing-function: ease-in;
   463     }
   465     50% {
   466       top: 100px;
   467       animation-timing-function: ease-out;
   468     }
   470     75% {
   471       top: 75px;
   472       animation-timing-function: ease-in;
   473     }
   475     to {
   476       top: 100px;
   477     }
   479   }
   481   </pre>
   482    Five keyframes are specified for the animation named "bounce". Between the
   483    first and second keyframe (i.e., between 0% and 25%) an "ease-out" timing
   484    function is used. Between the second and third keyframe (i.e., between 25%
   485    and 50%) an "ease-in" timing function is used. And so on. The effect will
   486    appear as an element that moves up the page 50px, slowing down as it
   487    reaches its highest point then speeding up as it falls back to 100px. The
   488    second half of the animation behaves in a similar manner, but only moves
   489    the element 25px units up the page. A timing function specified on the
   490    "to" or 100% keyframe is ignored</div>
   492   <p> See <a href="#animation-timing-function_tag">the <code
   493    class=property>'animation-timing-function'</code> property</a> for more
   494    information.</p>
   495   <!-- ======================================================================================================= -->
   496   <!-- ======================================================================================================= -->
   498   <h3 id=the-animation-name-property-><span class=secno>3.2. </span> The <a
   499    href="#animation-name"><code class=property>'animation-name'</code></a>
   500    Property</h3>
   502   <p> The <a href="#animation-name"><code
   503    class=property>'animation-name'</code></a> property defines a list of
   504    animations that apply. Each name is used to select the keyframe at-rule
   505    that provides the property values for the animation. If the name does not
   506    match any keyframe at-rule, there are no properties to be animated and the
   507    animation will not execute. Furthermore, if the animation name is
   508    &lsquo;<code class=property>none</code>&rsquo; then there will be no
   509    animation. This can be used to override any animations coming from the
   510    cascade. If animations are attempting to modify the same property, then
   511    the animation closest to the end of the list of names wins.
   513   <p> Each animation listed by name should have a corresponding value for the
   514    other animation properties listed below. In the case where the other
   515    properties do not have lists of the correct length, their values are
   516    repeated to form a list with the same number of entries as <a
   517    href="#animation-name"><code class=property>'animation-name'</code></a>.
   519   <table class=propdef>
   520    <tbody>
   521     <tr>
   522      <td> <em>Name:</em>
   524      <td> <dfn id=animation-name>animation-name</dfn>
   526     <tr>
   527      <td> <em>Value:</em>
   529      <td> none | IDENT [, [ none | IDENT ] ]*
   531     <tr>
   532      <td> <em>Initial:</em>
   534      <td> none
   536     <tr>
   537      <td> <em>Applies&nbsp;to:</em>
   539      <td> all elements, :before and :after pseudo elements
   541     <tr>
   542      <td> <em>Inherited:</em>
   544      <td> no
   546     <tr>
   547      <td> <em>Percentages:</em>
   549      <td> N/A
   551     <tr>
   552      <td> <em>Media:</em>
   554      <td> visual
   556     <tr>
   557      <td> <em>Computed value:</em>
   559      <td> Same as specified value.
   560   </table>
   561   <!--
   562       <p>
   563         It is possible for elements to have multiple animations running that change the same property or properties. In this case the animations combine in a manner defined by the property. For example, animations on <code class="property">'opacity'</code> will add together and animations on <code class="property">'transform'</code> will have their transformation matrices multiplied.
   564       </p>
   565       <div class="example">
   566         <p style="display:none">
   567           Example(s):
   568         </p>
   569         <pre>
   570         @keyframes 'border-bloat' {
   571           from {
   572             border-width: 0;
   573           }
   574           to {
   575             border-width: 10px;
   576           }
   577         }
   579         @keyframes 'border-diet' {
   580           from {
   581             border-width: 4px;
   582           }
   583           to {
   584             border-width: 2px;
   585           }
   586         }
   588         div {
   589           animation-name: 'border-bloat', 'border-diet';
   590           animation-duration: 10s, 4s;
   591         }
   592       </pre>
   593       <p>
   594       The above example has two animations executing on the same property, <code class="property">'border-width'</code>. The animations are additive. That is, the 
   595       resulting value for the property will be the addition of the values from the
   596       two animations.
   597       </p>
   598       <p>
   599         At time '0s' the element's border will be 4px wide (0px from 'border-bloat' plus 4px from 'border-diet'). 
   600         At time '4s' the element's border will be 6px wide (4px from 'border-bloat' plus 2px from 'border-diet').
   601         At time '10s' the element's border will be 10px wide (10px from 'border-bloat' and no addition from
   602         'border-diet' as it is no longer executing).
   603       </p>
   604     </div>
   605   -->
   606   <!-- ======================================================================================================= -->
   608   <h3 id=the-animation-duration-property-><span class=secno>3.3. </span> The
   609    <a href="#animation-duration"><code
   610    class=property>'animation-duration'</code></a> Property</h3>
   612   <p> The <a href="#animation-duration"><code
   613    class=property>'animation-duration'</code></a> property defines the length
   614    of time that an animation takes to complete one cycle.
   616   <table class=propdef>
   617    <tbody>
   618     <tr>
   619      <td> <em>Name:</em>
   621      <td> <dfn id=animation-duration>animation-duration</dfn>
   623     <tr>
   624      <td> <em>Value:</em>
   626      <td> &lt;time&gt; [, &lt;time&gt;]*
   628     <tr>
   629      <td> <em>Initial:</em>
   631      <td> 0s
   633     <tr>
   634      <td> <em>Applies&nbsp;to:</em>
   636      <td> all elements, :before and :after pseudo elements
   638     <tr>
   639      <td> <em>Inherited:</em>
   641      <td> no
   643     <tr>
   644      <td> <em>Percentages:</em>
   646      <td> N/A
   648     <tr>
   649      <td> <em>Media:</em>
   651      <td> visual
   653     <tr>
   654      <td> <em>Computed value:</em>
   656      <td> Same as specified value.
   657   </table>
   659   <p> By default the value is &lsquo;<code class=css>0s</code>&rsquo;,
   660    meaning that the animation cycle is immediate. A negative value for <a
   661    href="#animation-duration"><code
   662    class=property>'animation-duration'</code></a> is treated as &lsquo;<code
   663    class=css>0s</code>&rsquo;. In this case <a
   664    href="#animation-fill-mode"><code
   665    class=property>'animation-fill-mode'</code></a> still applies, so an
   666    animation that fills backwards will show the value of the 0% keyframe
   667    during any delay period, and an animation that fill forwards will retain
   668    the value specified at the 100% keyframe, even if the animation was
   669    instantaneous. Also, animation events are still fired.</p>
   670   <!-- ======================================================================================================= -->
   672   <h3 id="animation-timing-function_tag"><span class=secno>3.4. </span> The
   673    <a href="#animation-timing-function"><code
   674    class=property>'animation-timing-function'</code></a> Property</h3>
   676   <p> The <a href="#animation-timing-function"><code
   677    class=property>'animation-timing-function'</code></a> property describes
   678    how the animation will progress over one cycle of its duration. See the
   679    <code class=property>'transition-timing-function'</code> property <a
   680    href="#CSS3-TRANSITIONS"
   681    rel=biblioentry>[CSS3-TRANSITIONS]<!--{{!CSS3-TRANSITIONS}}--></a> for a
   682    complete description of timing function calculation.
   684   <table class=propdef>
   685    <tbody>
   686     <tr>
   687      <td> <em>Name:</em>
   689      <td> <dfn id=animation-timing-function>animation-timing-function</dfn>
   691     <tr>
   692      <td> <em>Value:</em>
   694      <td> ease | linear | ease-in | ease-out | ease-in-out | step-start |
   695       step-end | steps(&lt;number&gt;[, [ start | end ] ]?) |
   696       cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
   697       &lt;number&gt;) [, [ ease | linear | ease-in | ease-out | ease-in-out |
   698       step-start | step-end | steps(&lt;number&gt;[, [ start | end ] ]?) |
   699       cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
   700       &lt;number&gt;)] ]*
   702     <tr>
   703      <td> <em>Initial:</em>
   705      <td> ease
   707     <tr>
   708      <td> <em>Applies&nbsp;to:</em>
   710      <td> all elements, :before and :after pseudo elements
   712     <tr>
   713      <td> <em>Inherited:</em>
   715      <td> no
   717     <tr>
   718      <td> <em>Percentages:</em>
   720      <td> N/A
   722     <tr>
   723      <td> <em>Media:</em>
   725      <td> visual
   727     <tr>
   728      <td> <em>Computed value:</em>
   730      <td> Same as specified value.
   731   </table>
   733   <p> For a keyframed animation, the <a
   734    href="#animation-timing-function"><code
   735    class=property>'animation-timing-function'</code></a> applies between
   736    keyframes, not over the entire animation. For example, in the case of an
   737    ease-in-out timing function, an animation will ease in at the start of the
   738    keyframe and ease out at the end of the keyframe. A <a
   739    href="#animation-timing-function"><code
   740    class=property>'animation-timing-function'</code></a> defined within a
   741    keyframe block applies to that keyframe, otherwise the timing function
   742    specified for the animation is used.</p>
   743   <!-- ======================================================================================================= -->
   745   <h3 id=the-animation-iteration-count-property-><span class=secno>3.5.
   746    </span> The <a href="#animation-iteration-count"><code
   747    class=property>'animation-iteration-count'</code></a> Property</h3>
   749   <p> The <a href="#animation-iteration-count"><code
   750    class=property>'animation-iteration-count'</code></a> property defines the
   751    number of times an animation cycle is played. The default value is one,
   752    meaning the animation will play from beginning to end once. A value of
   753    <code class=css>'infinite'</code> will cause the animation to repeat
   754    forever. Non-integer numbers will cause the animation to end part-way
   755    through a cycle. Negative values of <a
   756    href="#animation-iteration-count"><code
   757    class=property>'animation-iteration-count'</code></a> are invalid. This
   758    property is often used with an <a href="#animation-direction"><code
   759    class=property>'animation-direction'</code></a> value of <code
   760    class=css>alternate</code>, which will cause the animation to play in
   761    reverse on alternate cycles.
   763   <table class=propdef>
   764    <tbody>
   765     <tr>
   766      <td> <em>Name:</em>
   768      <td> <dfn id=animation-iteration-count>animation-iteration-count</dfn>
   770     <tr>
   771      <td> <em>Value:</em>
   773      <td> infinite | &lt;number&gt; [, [ infinite | &lt;number&gt; ] ]*
   775     <tr>
   776      <td> <em>Initial:</em>
   778      <td> 1
   780     <tr>
   781      <td> <em>Applies&nbsp;to:</em>
   783      <td> all elements, :before and :after pseudo elements
   785     <tr>
   786      <td> <em>Inherited:</em>
   788      <td> no
   790     <tr>
   791      <td> <em>Percentages:</em>
   793      <td> N/A
   795     <tr>
   796      <td> <em>Media:</em>
   798      <td> visual
   800     <tr>
   801      <td> <em>Computed value:</em>
   803      <td> Same as specified value.
   804   </table>
   805   <!-- ======================================================================================================= -->
   807   <h3 id=the-animation-direction-property-><span class=secno>3.6. </span> The
   808    <a href="#animation-direction"><code
   809    class=property>'animation-direction'</code></a> Property</h3>
   811   <p> The <a href="#animation-direction"><code
   812    class=property>'animation-direction'</code></a> property defines whether
   813    or not the animation should play in reverse on some or all cycles. When an
   814    animation is played in reverse the timing functions are also reversed. For
   815    example, when played in reverse an ease-in animation would appear to be an
   816    ease-out animation.
   818   <table class=propdef>
   819    <tbody>
   820     <tr>
   821      <td> <em>Name:</em>
   823      <td> <dfn id=animation-direction>animation-direction</dfn>
   825     <tr>
   826      <td> <em>Value:</em>
   828      <td> normal | reverse | alternate | alternate-reverse [, [ normal |
   829       reverse | alternate | alternate-reverse ] ]*
   831     <tr>
   832      <td> <em>Initial:</em>
   834      <td> normal
   836     <tr>
   837      <td> <em>Applies&nbsp;to:</em>
   839      <td> all elements, :before and :after pseudo elements
   841     <tr>
   842      <td> <em>Inherited:</em>
   844      <td> no
   846     <tr>
   847      <td> <em>Percentages:</em>
   849      <td> N/A
   851     <tr>
   852      <td> <em>Media:</em>
   854      <td> visual
   856     <tr>
   857      <td> <em>Computed value:</em>
   859      <td> Same as specified value.
   860   </table>
   862   <dl>
   863    <dt>normal
   865    <dd>All iterations of the animation are played as specified.
   867    <dt>reverse
   869    <dd>All iterations of the animation are played in the reverse direction
   870     from the way they were specified.
   872    <dt>alternate
   874    <dd>The animation cycle iterations that are odd counts are played in the
   875     normal direction, and the animation cycle iterations that are even counts
   876     are played in a reverse direction.
   878    <dt>alternate-reverse
   880    <dd>The animation cycle iterations that are odd counts are played in the
   881     reverse direction, and the animation cycle iterations that are even
   882     counts are played in a normal direction.
   883   </dl>
   884   <!-- ======================================================================================================= -->
   886   <h3 id=the-animation-play-state-property-><span class=secno>3.7. </span>
   887    The <a href="#animation-play-state"><code
   888    class=property>'animation-play-state'</code></a> Property</h3>
   890   <p> The <a href="#animation-play-state"><code
   891    class=property>'animation-play-state'</code></a> property defines whether
   892    the animation is running or paused. A running animation can be paused by
   893    setting this property to <code class=css>'paused'</code>. To continue
   894    running a paused animation this property can be set to <code
   895    class=css>'running'</code>. A paused animation will continue to display
   896    the current value of the animation in a static state, as if the time of
   897    the animation is constant. When a paused animation is resumed, it restarts
   898    from the current value, not necessarily from the beginning of the
   899    animation.
   901   <table class=propdef>
   902    <tbody>
   903     <tr>
   904      <td> <em>Name:</em>
   906      <td> <dfn id=animation-play-state>animation-play-state</dfn>
   908     <tr>
   909      <td> <em>Value:</em>
   911      <td> running | paused [, [ running | paused ] ]*
   913     <tr>
   914      <td> <em>Initial:</em>
   916      <td> running
   918     <tr>
   919      <td> <em>Applies&nbsp;to:</em>
   921      <td> all elements, :before and :after pseudo elements
   923     <tr>
   924      <td> <em>Inherited:</em>
   926      <td> no
   928     <tr>
   929      <td> <em>Percentages:</em>
   931      <td> N/A
   933     <tr>
   934      <td> <em>Media:</em>
   936      <td> visual
   938     <tr>
   939      <td> <em>Computed value:</em>
   941      <td> Same as specified value.
   942   </table>
   943   <!-- ======================================================================================================= -->
   945   <h3 id=the-animation-delay-property-><span class=secno>3.8. </span> The <a
   946    href="#animation-delay"><code class=property>'animation-delay'</code></a>
   947    Property</h3>
   949   <p> The <a href="#animation-delay"><code
   950    class=property>'animation-delay'</code></a> property defines when the
   951    animation will start. It allows an animation to begin execution some time
   952    after it is applied. An <a href="#animation-delay"><code
   953    class=property>'animation-delay'</code></a> value of &lsquo;<code
   954    class=css>0s</code>&rsquo; means the animation will execute as soon as it
   955    is applied. Otherwise, the value specifies an offset from the moment the
   956    animation is applied, and the animation will delay execution by that
   957    offset.
   959   <p> If the value for <a href="#animation-delay"><code
   960    class=property>'animation-delay'</code></a> is a negative time offset then
   961    the animation will execute the moment it is applied, but will appear to
   962    have begun execution at the specified offset. That is, the animation will
   963    appear to begin part-way through its play cycle. In the case where an
   964    animation has implied starting values and a negative <a
   965    href="#animation-delay"><code class=property>'animation-delay'</code></a>,
   966    the starting values are taken from the moment the animation is applied.
   968   <table class=propdef>
   969    <tbody>
   970     <tr>
   971      <td> <em>Name:</em>
   973      <td> <dfn id=animation-delay>animation-delay</dfn>
   975     <tr>
   976      <td> <em>Value:</em>
   978      <td> &lt;time&gt; [, &lt;time&gt;]*
   980     <tr>
   981      <td> <em>Initial:</em>
   983      <td> 0s
   985     <tr>
   986      <td> <em>Applies&nbsp;to:</em>
   988      <td> all elements, :before and :after pseudo elements
   990     <tr>
   991      <td> <em>Inherited:</em>
   993      <td> no
   995     <tr>
   996      <td> <em>Percentages:</em>
   998      <td> N/A
  1000     <tr>
  1001      <td> <em>Media:</em>
  1003      <td> visual
  1005     <tr>
  1006      <td> <em>Computed value:</em>
  1008      <td> Same as specified value.
  1009   </table>
  1010   <!-- ======================================================================================================= -->
  1012   <h3 id=the-animation-fill-mode-property-><span class=secno>3.9. </span> The
  1013    <a href="#animation-fill-mode"><code
  1014    class=property>'animation-fill-mode'</code></a> Property</h3>
  1016   <p> The <a href="#animation-fill-mode"><code
  1017    class=property>'animation-fill-mode'</code></a> property defines what
  1018    values are applied by the animation outside the time it is executing. By
  1019    default, an animation will not affect property values between the time it
  1020    is applied (the <a href="#animation-name"><code
  1021    class=property>'animation-name'</code></a> property is set on an element)
  1022    and the time it begins execution (which is determined by the <a
  1023    href="#animation-delay"><code class=property>'animation-delay'</code></a>
  1024    property). Also, by default an animation does not affect property values
  1025    after the animation ends (determined by the <a
  1026    href="#animation-duration"><code
  1027    class=property>'animation-duration'</code></a> property). The value of <a
  1028    href="#animation-fill-mode"><code
  1029    class=property>'animation-fill-mode'</code></a> can override this
  1030    behavior.
  1032   <p> If the value for <a href="#animation-fill-mode"><code
  1033    class=property>'animation-fill-mode'</code></a> is <code
  1034    class=css>'backwards'</code>, then the animation will apply the property
  1035    values defined in its 0% or &lsquo;<code class=property>from</code>&rsquo;
  1036    keyframe as soon as the animation is applied, during the period defined by
  1037    <a href="#animation-delay"><code
  1038    class=property>'animation-delay'</code></a>.
  1040   <p> If the value for <a href="#animation-fill-mode"><code
  1041    class=property>'animation-fill-mode'</code></a> is <code
  1042    class=css>'forwards'</code>, then the animation will apply the property
  1043    values defined in its last executing keyframe after the final iteration of
  1044    the animation, until the animation style is removed. The last executing
  1045    keyframe is the &lsquo;<code class=property>to</code>&rsquo; or
  1046    &lsquo;<code class=css>100%</code>&rsquo; keyframe, unless the animation
  1047    has <a href="#animation-direction"><code
  1048    class=property>'animation-direction'</code></a> set to <code
  1049    class=css>'alternate'</code> and both a finite and even iteration count,
  1050    in which case it is the &lsquo;<code class=property>from</code>&rsquo; or
  1051    &lsquo;<code class=css>0%</code>&rsquo; keyframe.
  1053   <p> If the value for <a href="#animation-fill-mode"><code
  1054    class=property>'animation-fill-mode'</code></a> is <code
  1055    class=css>'both'</code>, then the animation will follow the rules for both
  1056    &lsquo;<code class=property>forwards</code>&rsquo; and &lsquo;<code
  1057    class=property>backwards</code>&rsquo;. That is, it will extend the
  1058    animation properties in both directions.
  1060   <table class=propdef>
  1061    <tbody>
  1062     <tr>
  1063      <td> <em>Name:</em>
  1065      <td> <dfn id=animation-fill-mode>animation-fill-mode</dfn>
  1067     <tr>
  1068      <td> <em>Value:</em>
  1070      <td> none | forwards | backwards | both [, [ none | forwards | backwards
  1071       | both ] ]*
  1073     <tr>
  1074      <td> <em>Initial:</em>
  1076      <td> none
  1078     <tr>
  1079      <td> <em>Applies&nbsp;to:</em>
  1081      <td> all elements, :before and :after pseudo elements
  1083     <tr>
  1084      <td> <em>Inherited:</em>
  1086      <td> no
  1088     <tr>
  1089      <td> <em>Percentages:</em>
  1091      <td> N/A
  1093     <tr>
  1094      <td> <em>Media:</em>
  1096      <td> visual
  1098     <tr>
  1099      <td> <em>Computed value:</em>
  1101      <td> Same as specified value.
  1102   </table>
  1103   <!-- ======================================================================================================= -->
  1105   <h3 id=the-animation-shorthand-property-><span class=secno>3.10. </span>
  1106    The <a href="#animation"><code class=property>'animation'</code></a>
  1107    Shorthand Property</h3>
  1109   <p> The <a href="#animation"><code class=property>'animation'</code></a>
  1110    shorthand property combines seven of the animation properties into a
  1111    single property.
  1113   <p> Note that order is important in this property. The first value that can
  1114    be parsed as a time is assigned to the animation-duration. The second
  1115    value that can be parsed as a time is assigned to animation-delay.
  1117   <p class=issue> An alternative proposal is to accept the font shorthand
  1118    approach of using a "/" character between the values of the same type.
  1119    e.g. 2s/4s would mean a duration of 2 seconds and a delay of 4 seconds.
  1121   <table class=propdef>
  1122    <tbody>
  1123     <tr>
  1124      <td> <em>Name:</em>
  1126      <td> <dfn id=animation>animation</dfn>
  1128     <tr>
  1129      <td> <em>Value:</em>
  1131      <td> [&lt;animation-name&gt; || &lt;animation-duration&gt; ||
  1132       &lt;animation-timing-function&gt; || &lt;animation-delay&gt; ||
  1133       &lt;animation-iteration-count&gt; || &lt;animation-direction&gt; ||
  1134       &lt;animation-fill-mode&gt;] [, [&lt;animation-name&gt; ||
  1135       &lt;animation-duration&gt; || &lt;animation-timing-function&gt; ||
  1136       &lt;animation-delay&gt; || &lt;animation-iteration-count&gt; ||
  1137       &lt;animation-direction&gt; || &lt;animation-fill-mode&gt;] ]*
  1139     <tr>
  1140      <td> <em>Initial:</em>
  1142      <td> see individual properties
  1144     <tr>
  1145      <td> <em>Applies&nbsp;to:</em>
  1147      <td> all elements, :before and :after pseudo elements
  1149     <tr>
  1150      <td> <em>Inherited:</em>
  1152      <td> no
  1154     <tr>
  1155      <td> <em>Percentages:</em>
  1157      <td> N/A
  1159     <tr>
  1160      <td> <em>Media:</em>
  1162      <td> visual
  1164     <tr>
  1165      <td> <em>Computed value:</em>
  1167      <td> Same as specified value.
  1168   </table>
  1169   <!-- ======================================================================================================= -->
  1171   <h2 id=animation-events-><span class=secno>4. </span> Animation Events</h2>
  1173   <p> Several animation related events are available through the <a
  1174    href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM Event
  1175    system</a>. The start and end of an animation, and the end of each
  1176    iteration of an animation all generate DOM events. An element can have
  1177    multiple properties being animated simultaneously. This can occur either
  1178    with a single <a href="#animation-name"><code
  1179    class=property>animation-name</code></a> value with keyframes containing
  1180    multiple properties, or with multiple <a href="#animation-name"><code
  1181    class=property>animation-name</code></a> values. For the purposes of
  1182    events, each <a href="#animation-name"><code
  1183    class=property>animation-name</code></a> specifies a single animation.
  1184    Therefore an event will be generated for each <a
  1185    href="#animation-name"><code class=property>animation-name</code></a>
  1186    value and not necessarily for each property being animated.
  1188   <p> The time the animation has been running is sent with each event
  1189    generated. This allows the event handler to determine the current
  1190    iteration of a looping animation or the current position of an alternating
  1191    animation. This time does not include any time the animation was in the
  1192    <code>paused</code> play state.
  1194   <dl>
  1195    <dt> <b>Interface <i><a id=Events-AnimationEvent
  1196     name=Events-AnimationEvent>AnimationEvent</a></i></b>
  1198    <dd>
  1199     <p> The <code>AnimationEvent</code> interface provides specific
  1200      contextual information associated with Animation events.</p>
  1202     <dl>
  1203      <dt> <br>
  1204       <b>IDL Definition</b>
  1206      <dd>
  1207       <div class=idl-code>
  1208        <pre>
  1209   interface AnimationEvent : Event {
  1210     readonly attribute DOMString          animationName;
  1211     readonly attribute float              elapsedTime;
  1212     void               initAnimationEvent(in DOMString typeArg, 
  1213                                           in boolean canBubbleArg, 
  1214                                           in boolean cancelableArg, 
  1215                                           in DOMString animationNameArg,
  1216                                           in float elapsedTimeArg);
  1217   };
  1218   </pre>
  1219       </div>
  1221      <dt> <b>Attributes</b>
  1223      <dd>
  1224       <dl>
  1225        <dt> <code class=attribute-name><a
  1226         id=Events-AnimationEvent-animationName
  1227         name=Events-AnimationEvent-animationName>animationName</a></code> of
  1228         type <code>DOMString</code>, readonly
  1230        <dd> The value of the <a href="#animation-name"><code
  1231         class=property>animation-name</code></a> property of the animation
  1232         that fired the event.
  1233       </dl>
  1235       <dl>
  1236        <dt> <code class=attribute-name><a
  1237         id=Events-AnimationEvent-elapsedTime
  1238         name=Events-AnimationEvent-elapsedTime>elapsedTime</a></code> of type
  1239         <code>float</code>, readonly
  1241        <dd> The amount of time the animation has been running, in seconds,
  1242         when this event fired, excluding any time the animation was paused.
  1243         For an "animationstart" event, the elapsedTime is zero unless there
  1244         was a negative value for <a href="#animation-delay"><code
  1245         class=property>animation-delay</code></a>, in which case the event
  1246         will be fired with an elapsedTime of (-1 * delay).
  1247       </dl>
  1249      <dt> <b>Methods</b>
  1251      <dd>
  1252       <dl>
  1253        <dt> <code class=method-name><a
  1254         id=Events-AnimationEvent-initAnimationEvent
  1255         name=Events-AnimtionEvent-initAnimationEvent>initAnimationEvent</a></code>
  1258        <dd>
  1259         <div class=method> The <code>initAnimationEvent</code> method is used
  1260          to initialize the value of an <code>AnimationEvent</code> created
  1261          through the <a
  1262          href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent"><code>DocumentEvent</code></a>
  1263          interface. This method may only be called before the
  1264          <code>AnimationEvent</code> has been dispatched via the
  1265          <code>dispatchEvent</code> method, though it may be called multiple
  1266          times during that phase if necessary. If called multiple times, the
  1267          final invocation takes precedence.
  1268          <div class=parameters> <b>Parameters</b>
  1269           <div class=paramtable>
  1270            <dl>
  1271             <dt> <code class=parameter-name>typeArg</code> of type
  1272              <code>DOMString</code>
  1274             <dd> Specifies the event type.<br>
  1276             <dt> <code class=parameter-name>canBubbleArg</code> of type
  1277              <code>boolean</code>
  1279             <dd> Specifies whether or not the event can bubble.<br>
  1281             <dt> <code class=parameter-name>cancelableArg</code> of type
  1282              <code>boolean</code>
  1284             <dd> Specifies whether or not the event's default action can be
  1285              prevented.
  1287             <dt> <code class=parameter-name>animationNameArg</code> of type
  1288              <code>DOMString</code>
  1290             <dd> Specifies the <a
  1291              href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event"><code>Event</code></a>&lsquo;<code
  1292              class=css>s animation name.<br>
  1293              </code>
  1295             <dt> <code class=parameter-name>elapsedTimeArg</code> of type
  1296              <code>float</code>
  1298             <dd> Specifies the amount of time, in seconds, the animation has
  1299              been running at the time of initialization.
  1300            </dl>
  1301           </div>
  1302          </div>
  1303          <!-- parameters -->
  1304          <div> <b>No Return Value</b></div>
  1306          <div> <b>No Exceptions</b></div>
  1307         </div>
  1308         <!-- method -->
  1309       </dl>
  1310     </dl>
  1311   </dl>
  1313   <p> The different types of Animation events that can occur are:
  1315   <dl>
  1316    <dt> <b>animationstart</b>
  1318    <dd> The &rsquo;animationstart' event occurs at the start of the
  1319     animation. If there is an <a href="#animation-delay"><code
  1320     class=property>animation-delay</code></a> then this event will fire once
  1321     the delay period has expired. A negative delay will cause the event to
  1322     fire with an elapsedTime equal to the absolute value of the delay.
  1323     <ul>
  1324      <li>Bubbles: Yes
  1326      <li>Cancelable: No
  1328      <li>Context Info: animationName
  1329     </ul>
  1331    <dt> <b>animationend</b>
  1333    <dd> The &lsquo;<code class=property>animationend</code>&rsquo; event
  1334     occurs when the animation finishes.
  1335     <ul>
  1336      <li>Bubbles: Yes
  1338      <li>Cancelable: No
  1340      <li>Context Info: animationName, elapsedTime
  1341     </ul>
  1343    <dt> <b>animationiteration</b>
  1345    <dd> The &lsquo;<code class=property>animationiteration</code>&rsquo;
  1346     event occurs at the end of each iteration of an animation for which <a
  1347     href="#animation-iteration-count"><code>animation-iteration-count</code></a>
  1348     is greater than one. This event does not occur for animations with an
  1349     iteration count of one.
  1350     <ul>
  1351      <li>Bubbles: Yes
  1353      <li>Cancelable: No
  1355      <li>Context Info: animationName, elapsedTime
  1356     </ul>
  1357   </dl>
  1358   <!-- ======================================================================================================= -->
  1360   <h2 id=dom-interfaces-><span class=secno>5. </span> DOM Interfaces</h2>
  1362   <p> CSS animation is exposed to the CSSOM through a pair of new interfaces
  1363    describing the keyframes.
  1365   <dl>
  1366    <dt> <b>Interface <i><a id=DOM-CSSRule
  1367     name=DOM-CSSRule>CSSRule</a></i></b>
  1369    <dd>
  1370     <p> The following 2 rule types are added to the <code>CSSRule</code>
  1371      interface. They provide identification for the new keyframe and
  1372      keyframes rules.</p>
  1374     <dl>
  1375      <dt> <b>IDL Definition</b>
  1377      <dd>
  1378       <div class=idl-code>
  1379        <pre>
  1380     interface CSSRule {
  1381       ...
  1382       const unsigned short KEYFRAMES_RULE = 7;
  1383       const unsigned short KEYFRAME_RULE = 8;
  1384       ...
  1385     };</pre>
  1386       </div>
  1387      </dd>
  1388      <!-- IDL -->
  1389     </dl>
  1391    <dt> <b>Interface <i><a id=DOM-CSSKeyframeRule
  1392     name=DOM-CSSKeyframeRule>CSSKeyframeRule</a></i></b>
  1394    <dd>
  1395     <p> The <code>CSSKeyframeRule</code> interface represents the style rule
  1396      for a single key.</p>
  1398     <dl>
  1399      <dt> <br>
  1400       <b>IDL Definition</b>
  1402      <dd>
  1403       <div class=idl-code>
  1404        <pre>
  1405     interface CSSKeyframeRule : CSSRule {
  1406         attribute DOMString keyText;
  1407         readonly attribute CSSStyleDeclaration style;
  1408     };
  1409     </pre>
  1410       </div>
  1411       <br>
  1413      <dt> <b>Attributes</b>
  1415      <dd>
  1416       <dl>
  1417        <dt> <code class=attribute-name><a id=DOM-CSSKeyframeRule-keyText
  1418         name=DOM-CSSKeyframeRule-keyText>keyText</a></code> of type
  1419         <code>DOMString</code>
  1421        <dd> This attribute represents the key as the string representation of
  1422         a floating point number between 0 and 1. If the value in the CSS
  1423         style is <code>from</code> this value will be 0, and if the value in
  1424         the CSS style is <code>to</code> this value will be 1.<br>
  1425       </dl>
  1427      <dd>
  1428       <dl>
  1429        <dt> <code class=attribute-name><a id=DOM-CSSKeyframeRule-style
  1430         name=DOM-CSSKeyframeRule-style>style</a></code> of type
  1431         <code>CSSStyleDeclaration</code>
  1433        <dd> This attribute represents the style associated with this
  1434         keyframe.<br>
  1435       </dl>
  1437      <dt> <b>No Methods</b>
  1438     </dl>
  1439   </dl>
  1441   <dl>
  1442    <dt> <b>Interface <i><a id=DOM-CSSKeyframesRule
  1443     name=DOM-CSSKeyframesRule>CSSKeyframesRule</a></i></b>
  1445    <dd>
  1446     <p> The <code>CSSKeyframesRule</code> interface represents a complete set
  1447      of keyframes for a single animation.</p>
  1449     <dl>
  1450      <dt> <br>
  1451       <b>IDL Definition</b>
  1453      <dd>
  1454       <div class=idl-code>
  1455        <pre>
  1456     interface CSSKeyframesRule : CSSRule {
  1457         attribute          DOMString   name;
  1458         readonly attribute CSSRuleList cssRules;
  1460         void               appendRule(in DOMString rule);
  1461         void               deleteRule(in DOMString key);
  1462         CSSKeyframeRule    findRule(in DOMString key);
  1463     };
  1464     </pre>
  1465       </div>
  1466       <br>
  1468      <dt> <b>Attributes</b>
  1470      <dd>
  1471       <dl>
  1472        <dt> <code class=attribute-name><a id=DOM-CSSKeyframesRule-name
  1473         name=DOM-CSSKeyframesRule-name>name</a></code> of type
  1474         <code>DOMString</code>
  1476        <dd> This attribute is the name of the keyframes, used by the <a
  1477         href="#animation-name"><code>animation-name</code></a> property.<br>
  1478       </dl>
  1480      <dd>
  1481       <dl>
  1482        <dt> <code class=attribute-name><a id=DOM-CSSKeyframeRules-cssRules
  1483         name=DOM-CSSKeyframeRules-cssRules>cssRules</a></code> of type
  1484         <code>CSSRuleList</code>
  1486        <dd> This attribute gives access to the keyframes in the list.<br>
  1487       </dl>
  1489      <dt> <b>Methods</b>
  1491      <dd>
  1492       <dl><!-- ======================================================================================================= -->
  1494        <dt> <code class=method-name><a id=DOM-CSSKeyframesRule-appendRule
  1495         name=DOM-CSSKeyframesRule-appendRule>appendRule</a></code>
  1497        <dd>
  1498         <div class=method> The <code>appendRule</code> method appends the
  1499          passed CSSKeyframeRule into the list at the passed key.
  1500          <div class=parameters> <b>Parameters</b>
  1501           <div class=paramtable>
  1502            <dl>
  1503             <dt> <code class=parameter-name>rule</code> of type
  1504              <code>DOMString</code>
  1506             <dd> The rule to be appended, expressed in the same syntax as one
  1507              entry in the <code>@keyframes</code> rule.
  1508            </dl>
  1509           </div>
  1510          </div>
  1511          <!-- parameters -->
  1512          <div class=return-value> <b>No Return Value</b></div>
  1514          <div> <b>No Exceptions</b></div>
  1515         </div>
  1516         <!-- ======================================================================================================= -->
  1519        <dt> <code class=method-name><a id=DOM-CSSKeyframesRule-deleteRule
  1520         name=DOM-CSSKeyframesRule-deleteRule>deleteRule</a></code>
  1522        <dd>
  1523         <div class=method> The <code>deleteRule</code> method deletes the
  1524          CSSKeyframeRule with the passed key. If a rule with this key does
  1525          not exist, the method does nothing.
  1526          <div class=parameters> <b>Parameters</b>
  1527           <div class=paramtable>
  1528            <dl>
  1529             <dt> <code class=parameter-name>key</code> of type
  1530              <code>DOMString</code>
  1532             <dd> The key which describes the rule to be deleted. The key must
  1533              resolve to a number between 0 and 1, or the rule is ignored.<br>
  1534            </dl>
  1535           </div>
  1536          </div>
  1537          <!-- parameters -->
  1538          <div class=return-value> <b>No Return Value</b></div>
  1540          <div> <b>No Exceptions</b></div>
  1541         </div>
  1542         <!-- ======================================================================================================= -->
  1545        <dt> <code class=method-name><a id=DOM-CSSKeyframesRule-findRule
  1546         name=DOM-CSSKeyframesRule-findRule>findRule</a></code>
  1548        <dd>
  1549         <div class=method> The <code>findRule</code> method returns the rule
  1550          with a key matching the passed key. If no such rule exists, a null
  1551          value is returned.
  1552          <div class=parameters> <b>Parameters</b>
  1553           <div class=paramtable>
  1554            <dl>
  1555             <dt> <code class=parameter-name>key</code> of type
  1556              <code>DOMString</code>
  1558             <dd> The key which described the rule to find. The key must
  1559              resolve to a number between 0 and 1, or the rule is ignored.<br>
  1560            </dl>
  1561           </div>
  1562          </div>
  1563          <!-- parameters -->
  1564          <div class=return-value> <b>Return Value</b>
  1565           <div class=returnvalue>
  1566            <dl>
  1567             <dt> <code>CSSKeyframeRule</code>
  1569             <dd> The found rule.<br>
  1570            </dl>
  1571           </div>
  1572          </div>
  1574          <div> <b>No Exceptions</b></div>
  1575         </div>
  1576         <!-- ======================================================================================================= -->
  1578       </dl>
  1579       <!-- method -->
  1580     </dl>
  1581   </dl>
  1583   <h2 id=acknowledgments><span class=secno>6. </span>Acknowledgments</h2>
  1585   <p>Thanks especially to the feedback from Estelle Weyl and all the rest of
  1586    the <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a>
  1587    community.
  1589   <h2 id=references><span class=secno>7. </span>References</h2>
  1591   <h3 class=no-num id=normative-references>Normative references</h3>
  1592   <!--begin-normative-->
  1593   <!-- Sorted by label -->
  1595   <dl class=bibliography>
  1596    <dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
  1597     <!---->
  1599    <dt id=CSS3-TRANSITIONS>[CSS3-TRANSITIONS]
  1601    <dd>Dean Jackson; et al. <a
  1602     href="http://www.w3.org/TR/2009/WD-css3-transitions-20091201"><cite>CSS
  1603     Transitions Module Level 3.</cite></a> 1 December 2009. W3C Working
  1604     Draft. (Work in progress.) URL: <a
  1605     href="http://www.w3.org/TR/2009/WD-css3-transitions-20091201">http://www.w3.org/TR/2009/WD-css3-transitions-20091201</a>
  1606     </dd>
  1607    <!---->
  1608   </dl>
  1609   <!--end-normative-->
  1611   <h3 class=no-num id=other-references>Other references</h3>
  1612   <!--begin-informative-->
  1613   <!-- Sorted by label -->
  1615   <dl class=bibliography>
  1616    <dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
  1617     <!---->
  1618   </dl>
  1619   <!--end-informative-->
  1621   <h2 class=no-num id=property-index>Property index</h2>
  1622   <!--begin-properties-->
  1624   <table class=proptable>
  1625    <thead>
  1626     <tr>
  1627      <th>Property
  1629      <th>Values
  1631      <th>Initial
  1633      <th>Applies&nbsp;to
  1635      <th>Inh.
  1637      <th>Percentages
  1639      <th>Media
  1641    <tbody>
  1642     <tr>
  1643      <th><a class=property href="#animation">animation</a>
  1645      <td>[&lt;animation-name&gt; || &lt;animation-duration&gt; ||
  1646       &lt;animation-timing-function&gt; || &lt;animation-delay&gt; ||
  1647       &lt;animation-iteration-count&gt; || &lt;animation-direction&gt; ||
  1648       &lt;animation-fill-mode&gt;] [, [&lt;animation-name&gt; ||
  1649       &lt;animation-duration&gt; || &lt;animation-timing-function&gt; ||
  1650       &lt;animation-delay&gt; || &lt;animation-iteration-count&gt; ||
  1651       &lt;animation-direction&gt; || &lt;animation-fill-mode&gt;] ]*
  1653      <td>see individual properties
  1655      <td>all elements, :before and :after pseudo elements
  1657      <td>no
  1659      <td>N/A
  1661      <td>visual
  1663     <tr>
  1664      <th><a class=property href="#animation-delay">animation-delay</a>
  1666      <td>&lt;time&gt; [, &lt;time&gt;]*
  1668      <td>0s
  1670      <td>all elements, :before and :after pseudo elements
  1672      <td>no
  1674      <td>N/A
  1676      <td>visual
  1678     <tr>
  1679      <th><a class=property
  1680       href="#animation-direction">animation-direction</a>
  1682      <td>normal | reverse | alternate | alternate-reverse [, [ normal |
  1683       reverse | alternate | alternate-reverse ] ]*
  1685      <td>normal
  1687      <td>all elements, :before and :after pseudo elements
  1689      <td>no
  1691      <td>N/A
  1693      <td>visual
  1695     <tr>
  1696      <th><a class=property href="#animation-duration">animation-duration</a>
  1698      <td>&lt;time&gt; [, &lt;time&gt;]*
  1700      <td>0s
  1702      <td>all elements, :before and :after pseudo elements
  1704      <td>no
  1706      <td>N/A
  1708      <td>visual
  1710     <tr>
  1711      <th><a class=property
  1712       href="#animation-fill-mode">animation-fill-mode</a>
  1714      <td>none | forwards | backwards | both [, [ none | forwards | backwards
  1715       | both ] ]*
  1717      <td>none
  1719      <td>all elements, :before and :after pseudo elements
  1721      <td>no
  1723      <td>N/A
  1725      <td>visual
  1727     <tr>
  1728      <th><a class=property
  1729       href="#animation-iteration-count">animation-iteration-count</a>
  1731      <td>infinite | &lt;number&gt; [, [ infinite | &lt;number&gt; ] ]*
  1733      <td>1
  1735      <td>all elements, :before and :after pseudo elements
  1737      <td>no
  1739      <td>N/A
  1741      <td>visual
  1743     <tr>
  1744      <th><a class=property href="#animation-name">animation-name</a>
  1746      <td>none | IDENT [, [ none | IDENT ] ]*
  1748      <td>none
  1750      <td>all elements, :before and :after pseudo elements
  1752      <td>no
  1754      <td>N/A
  1756      <td>visual
  1758     <tr>
  1759      <th><a class=property
  1760       href="#animation-play-state">animation-play-state</a>
  1762      <td>running | paused [, [ running | paused ] ]*
  1764      <td>running
  1766      <td>all elements, :before and :after pseudo elements
  1768      <td>no
  1770      <td>N/A
  1772      <td>visual
  1774     <tr>
  1775      <th><a class=property
  1776       href="#animation-timing-function">animation-timing-function</a>
  1778      <td>ease | linear | ease-in | ease-out | ease-in-out | step-start |
  1779       step-end | steps(&lt;number&gt;[, [ start | end ] ]?) |
  1780       cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
  1781       &lt;number&gt;) [, [ ease | linear | ease-in | ease-out | ease-in-out |
  1782       step-start | step-end | steps(&lt;number&gt;[, [ start | end ] ]?) |
  1783       cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
  1784       &lt;number&gt;)] ]*
  1786      <td>ease
  1788      <td>all elements, :before and :after pseudo elements
  1790      <td>no
  1792      <td>N/A
  1794      <td>visual
  1795   </table>
  1796   <!--end-properties-->
  1798   <h2 class=no-num id=index>Index</h2>
  1799   <!--begin-index-->
  1801   <ul class=indexlist>
  1802    <li>animation, <a href="#animation"
  1803     title=animation><strong>3.10.</strong></a>
  1805    <li>animation-delay, <a href="#animation-delay"
  1806     title=animation-delay><strong>3.8.</strong></a>
  1808    <li>animation-direction, <a href="#animation-direction"
  1809     title=animation-direction><strong>3.6.</strong></a>
  1811    <li>animation-duration, <a href="#animation-duration"
  1812     title=animation-duration><strong>3.3.</strong></a>
  1814    <li>animation-fill-mode, <a href="#animation-fill-mode"
  1815     title=animation-fill-mode><strong>3.9.</strong></a>
  1817    <li>animation-iteration-count, <a href="#animation-iteration-count"
  1818     title=animation-iteration-count><strong>3.5.</strong></a>
  1820    <li>animation-name, <a href="#animation-name"
  1821     title=animation-name><strong>3.2.</strong></a>
  1823    <li>animation-play-state, <a href="#animation-play-state"
  1824     title=animation-play-state><strong>3.7.</strong></a>
  1826    <li>animation-timing-function, <a href="#animation-timing-function"
  1827     title=animation-timing-function><strong>3.4.</strong></a>
  1828   </ul>
  1829   <!--end-index-->
  1830 </html>
  1831 <!-- Keep this comment at the end of the file
  1832 Local variables:
  1833 mode: sgml
  1834 sgml-default-doctype-name:"html"
  1835 sgml-minimize-attributes:t
  1836 End:
  1837 -->

mercurial