css-transitions/Overview.bs

Fri, 29 May 2015 16:46:19 -0700

author
Tab Atkins <jackalmage@gmail.com>
date
Fri, 29 May 2015 16:46:19 -0700
changeset 15674
0f4bf02e8b70
parent 15658
077f1626ecc1
child 16002
bec42e8ed638
permissions
-rw-r--r--

Add 'Work Status' metadata to all Bikeshed source files. Some files also accidentally got whitespace fixes, whoops.

     1 <h1>CSS Transitions</h1>
     3   <style type="text/css">
     4     table.animatable-properties {
     5       border-collapse: collapse;
     6     }
     7     table.animatable-properties td {
     8       padding: 0.2em 1em;
     9       border: 1px solid black;
    10     }
    11     div.prod { margin: 1em 2em; }
    12   </style>
    15 <pre class="metadata">
    16 Status: ED
    17 Work Status: Refining
    18 ED: http://dev.w3.org/csswg/css-transitions/
    19 Shortname: css-transitions
    20 Group: csswg
    21 Level: 1
    22 TR: http://www.w3.org/TR/css3-transitions/
    23 Previous version: http://www.w3.org/TR/2013/WD-css3-transitions-20131119/
    24 ED: http://dev.w3.org/csswg/css-transitions/
    25 Editor: L. David Baron, Mozilla, http://dbaron.org/
    26 Editor: Dean Jackson, Apple Inc, dino@apple.com
    27 Editor: David Hyatt, Apple Inc, hyatt@apple.com
    28 Editor: Chris Marrin, Apple Inc, cmarrin@apple.com
    29 Issue Tracking: Bugzilla bugs for this level https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&amp;product=CSS&amp;component=Transitions&amp;resolution=---&amp;status_whiteboard=defer%20to%20level%202&amp;status_whiteboard_type=notregexp
    30 Issue Tracking: Bugzilla bugs for all levels https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&amp;product=CSS&amp;component=Transitions&amp;resolution=---
    31 Abstract: CSS Transitions allows property changes in CSS values to occur smoothly over a specified duration.
    32 Status Text: <strong>This document</strong> is expected to be relatively close to last call.  While some issues raised have yet to be addressed, new features are extremely unlikely to be considered for this level. <p>The following behaviors are at risk: <ul><li><a href="#discrete-interpolation-at-risk">Interpolation in steps of property types that cannot be interpolated</a></li></ul>
    33 Ignored Terms: float
    34 </pre>
    35 <!-- FIXME: font-size and font-weight link defaults don't work -->
    36 <pre class="link-defaults">
    37 spec:css21; type:property;
    38     text:top
    39     text:right
    40     text:bottom
    41     text:left
    42     text:margin-top
    43     text:margin-right
    44     text:margin-bottom
    45     text:margin-left
    46     text:padding-top
    47     text:padding-right
    48     text:padding-bottom
    49     text:padding-left
    50     text:border-top-color
    51     text:border-right-color
    52     text:border-bottom-color
    53     text:border-left-color
    54     text:border-top-width
    55     text:border-right-width
    56     text:border-bottom-width
    57     text:border-left-width
    58     text:background-color
    59     text:background-position
    60     text:border-spacing
    61     text:width
    62     text:height
    63     text:min-width
    64     text:min-height
    65     text:max-width
    66     text:max-height
    67     text:clip
    68     text:letter-spacing
    69     text:line-height
    70     text:outline-color
    71     text:outline-width
    72     text:text-indent
    73     text:font-size
    74     text:font-weight
    75     text:vertical-align
    76     text:visibility
    77     text:word-spacing
    78     text:z-index
    79 spec:css-color-3;
    80     type:property;
    81         text:color
    82         text:opacity
    83     type:value
    84         text:green
    85         text:blue
    86         text:transparent
    87 spec:css-values-3; type:type; text:<time>
    88 </pre>
    89 <!-- FIXME: These overrides aren't great for dev/TR switching -->
    90 <pre class="anchors">
    91 url: http://dev.w3.org/csswg/css-backgrounds-3/#shadow-inset; type: value; for: shadow; text: inset;
    92 url: http://www.w3.org/TR/CSS21/visufx.html#propdef-visibility; type: value; for: visibility; text: visible;
    93 urlPrefix: http://dev.w3.org/csswg/css-color-3/; type: value;
    94     text: transparent
    95     text: blue
    96     text: green
    97 url: http://w3c.github.io/dom/#constructing-events; type: dfn; text: event constructor;
    98 url: https://html.spec.whatwg.org/multipage/infrastructure.html#concept-event-dispatch; type: dfn; text: dispatch;
    99 </pre>
   100 </dl>
   102 <h2 id="introduction">Introduction</h2>
   104       <p><em>This section is not normative.</em>
   105       <p>
   106         This document introduces new CSS features to enable <em>implicit transitions</em>, which describe how CSS properties can be made to change smoothly from one value to another over a given duration.
   107       </p>
   109 <h2 id="transitions"><span id="transitions-">Transitions</span></h2>
   110       <p>
   111         Normally when the value of a CSS property changes, the rendered result is instantly updated, with the affected elements immediately changing from the old property value to the new property value. This section describes a way to specify transitions using new CSS properties. These properties are used to animate smoothly from the old state to the new state over time.
   112       </p>
   113       <p>
   114         For example, suppose that transitions of one second have been defined on the 'left' and
   115         'background-color' properties. The following diagram illustrates the effect of updating those properties on an element, in this case moving it to the right and changing the background from red to blue. This assumes other transition parameters still have their default values.
   116       </p>
   117       <div class="figure">
   118         <img src="transition1.png" alt="">
   119       </div>
   120       <p class="caption">
   121         Transitions of 'left' and 'background-color'
   122       </p>
   123       <p>
   124         Transitions are a presentational effect. The <a>computed value</a> of a property transitions over time from the old value to the new value. Therefore if a script queries the <a>computed value</a> of a property (or other data depending on it) as it is transitioning, it will see an intermediate value that represents the current animated value of the property.
   125       </p>
   126       <p>
   127         Only animatable CSS properties can be transitioned. See the table at the end of this document for a list
   128         of properties that are animatable.
   129       </p>
   130       <p>
   131         The transition for a property is defined using a number of new properties. For example:
   132       </p>
   133       <div class="example">
   134         <p style="display:none">
   135           Example(s):
   136         </p>
   137         <pre>
   138   div {
   139     transition-property: opacity;
   140     transition-duration: 2s;
   141   }
   142   </pre>The above example defines a transition on the 'opacity' property that, when a new value is assigned to it, will cause a smooth change between the old value and the new value over a period of two seconds.
   143       </div>
   144       <p>
   145         Each of the transition properties accepts a comma-separated list, allowing multiple transitions to be defined, each acting on a different property. In this case, the individual transitions take their parameters from the same index in all the lists. For example:
   146       </p>
   147       <div class="example">
   148         <p style="display:none">
   149           Example(s):
   150         </p>
   151         <pre>
   152   div {
   153     transition-property: opacity, left;
   154     transition-duration: 2s, 4s;
   155   }
   157   </pre>This will cause the 'opacity' property to transition over a period of two seconds and the left property to transition over a period of four seconds.
   158       </div>
   160       <p id="list-matching">
   161         In the case where the lists of values in transition properties
   162         do not have the same length, the length of the
   163         'transition-property' list determines the number of items in
   164         each list examined when starting transitions.  The lists are
   165         matched up from the first value: excess values at the end are
   166         not used.  If one of the other properties doesn't have enough
   167         comma-separated values to match the number of values of
   168         'transition-property', the UA must calculate its used value by
   169         repeating the list of values until there are enough.  This
   170         truncation or repetition does not affect the computed value.
   171         <span class="note">
   172           Note: This is analogous to the behavior of the 'background-*'
   173           properties, with 'background-image' analogous to
   174           'transition-property'.
   175         </span>
   176       </p>
   178       <div class="example">
   179         <p style="display:none">
   180           Example(s):
   181         </p>
   182       <pre>
   183       div {
   184         transition-property: opacity, left, top, width;
   185         transition-duration: 2s, 1s;
   186       }
   187       </pre>The above example defines a transition on the 'opacity' property of 2 seconds duration, a
   188       transition on the 'left' property of 1
   189       second duration, a transition on the 'top' property of 2 seconds duration and a
   190       transition on the 'width' property of 1
   191       second duration.
   193       </div>
   195       <p>
   196         While authors can use transitions to create dynamically changing content,
   197         dynamically changing content can lead to seizures in some users.
   198         For information on how to avoid content that can lead to seizures, see
   199         <a href="http://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3:
   200         Seizures:
   201         Do not design content in a way that is known to cause seizures</a>
   202         ([[WCAG20]]).
   203       </p>
   205       <!-- ======================================================================================================= -->
   206       <h3 id="transition-property-property"><span id="the-transition-property-property-">
   207         The 'transition-property' Property
   208       </span></h3>
   209       <p>
   210         The 'transition-property' property specifies the name of the CSS property to which the transition is applied.
   211       </p>
   212       <pre class="propdef">
   213         Name: transition-property
   214         Value: ''transition-property/none'' | <<single-transition-property>>#
   215         Initial: ''transition-property/all''
   216         Applies to: all elements, ::before and ::after pseudo elements
   217         Inherited: no
   218         Animatable: no
   219         Percentages: N/A
   220         Media: visual
   221         Computed value: Same as specified value.
   222         Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
   223       </pre>
   225       <div class="prod">
   226         <dfn type id="single-transition-property">&lt;single-transition-property&gt;</dfn> = ''transition-property/all'' | <<custom-ident>>;
   227       </div>
   229       <p>
   230         A value of
   231         <dfn value for="transition-property">none</dfn>
   232         means that no property will transition.
   233         Otherwise, a list of properties to be transitioned, or the
   234         keyword <dfn value for="transition-property">all</dfn>
   235         which indicates that all properties are to be
   236         transitioned, is given.
   237       </p>
   239       <p>
   240         If one of the identifiers listed is not a recognized property
   241         name or is not an animatable property, the implementation must
   242         still start transitions on the animatable properties in the
   243         list using the duration, delay, and timing function at their
   244         respective indices in the lists for 'transition-duration',
   245         'transition-delay', and 'transition-timing-function'.  In other
   246         words, unrecognized or non-animatable properties must be kept in
   247         the list to preserve the matching of indices.
   248       </p>
   250       <p>
   251         The <<custom-ident>> production in <<single-transition-property>>
   252         also excludes the keyword ''transition-property/none'',
   253         in addition to the keywords always excluded from <<custom-ident>>.
   254         This means that
   255         ''transition-property/none'', ''inherit'', and ''initial'' are not
   256         permitted as items within a list of more that one identifier;
   257         any list that uses them is syntactically invalid.
   258       </p>
   260       <p>
   261         For the keyword ''transition-property/all'',
   262         or if one of the identifiers listed is a
   263         shorthand property, implementations must start transitions for
   264         any of its longhand sub-properties that are animatable (or, for
   265         ''transition-property/all'', all animatable properties), using the duration, delay,
   266         and timing function at the index corresponding to the shorthand.
   267       </p>
   268       <p>
   269         If a property is specified multiple times in the value of
   270         'transition-property' (either on its own, via a shorthand that
   271         contains it, or via the ''transition-property/all'' value), then the transition that
   272         starts uses the duration, delay, and timing function at the
   273         index corresponding to the <em>last</em> item in the value of
   274         'transition-property' that calls for animating that property.
   275       </p>
   276       <p class="note">
   277         Note:  The ''transition-property/all'' value and 'all' shorthand
   278         property work in similar ways, so the
   279         ''transition-property/all'' value is just like a shorthand that
   280         covers all properties.
   281       </p>
   283       <!-- ======================================================================================================= -->
   284       <h3 id="transition-duration-property"><span id="the-transition-duration-property-">
   285         The 'transition-duration' Property
   286       </span></h3>
   287       <p>
   288         The 'transition-duration' property defines the length of time that a transition takes.
   289       </p>
   290       <pre class="propdef">
   291         Name: transition-duration
   292         Value: <<time>>#
   293         Initial: ''0s''
   294         Applies to: all elements, ::before and ::after pseudo elements
   295         Inherited: no
   296         Animatable: no
   297         Percentages: N/A
   298         Media: interactive
   299         Computed value: Same as specified value.
   300         Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
   301       </pre>
   302       <p>
   303         This property specifies how long the transition from the old value to the new value should take. By default the value is ''0s'', meaning that the transition is immediate (i.e. there will be no animation). A negative value for 'transition-duration' renders the declaration invalid.
   304       </p>
   306       <!-- =======================================================================================================
   307         -->
   309       <h3 id="transition-timing-function-property"><span id="transition-timing-function_tag">
   310         The 'transition-timing-function' Property
   311       </span></h3>
   312       <p>
   313         The 'transition-timing-function' property
   314         describes how the intermediate values used during a transition will be
   315         calculated. It allows for a transition to change speed over its
   316         duration. These effects are commonly called <em>easing</em> functions.
   317         In either case, a mathematical function that provides a smooth curve is
   318         used.
   319       </p>
   320       <p>
   321         Timing functions are either defined as a stepping function or
   322         a <a
   323         href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
   324         B&eacute;zier curve</a>.
   325         The timing function takes as its input
   326         the current elapsed percentage of the transition duration
   327         and outputs the percentage of the way the transition is
   328         from its start value to its end value.
   329         How this output is used is defined by
   330         the <a href="#animatable-types">interpolation rules</a>
   331         for the value type.
   332       </p>
   333       <p>
   334         A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a>
   335         function is defined by a number that divides the domain of operation
   336         into equally sized intervals. Each subsequent interval is a equal step
   337         closer to the goal state. The function also specifies whether the
   338         change in output percentage happens at the start or end of the
   339         interval (in other words, if 0% on the input percentage is the point
   340         of initial change).
   341       </p>
   342       <div class="figure">
   343         <img src="step.png" alt="The step timing function splits
   344           the function domain into a number of disjoint straight line
   345           segments. steps(1, start) is a function whose
   346           output value is 1 for all input values. steps(1, end) is a function whose
   347           output value is 0 for all input values less than 1, and output
   348           is 1 for the input value of 1. steps(3, start) is a function that
   349           divides the input domain into three segments, each 1/3 in length,
   350           and 1/3 above the previous segment, with the first segment starting
   351           at 1/3. steps(3, end) is a function that
   352           divides the input domain into three segments, each 1/3 in length,
   353           and 1/3 above the previous segment, with the first segment starting
   354           at 0.">
   355       </div>
   356       <p class="caption">
   357         Step timing functions
   358       </p>
   359       <p>
   360         A <a
   361         href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
   362         B&eacute;zier curve</a> is defined by four control points, P<sub>0</sub>
   363         through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub>
   364         are always set to (0,0) and (1,1). The 'transition-timing-function' property is used
   365         to specify the values for points P<sub>1</sub> and P<sub>2</sub>. These
   366         can be set to preset values using the keywords listed below, or can be
   367         set to specific values using the ''cubic-bezier()'' function.
   368         In the ''cubic-bezier()'' function, P<sub>1</sub> and
   369         P<sub>2</sub> are each specified by both an X and Y value.
   370       </p>
   371       <div class="figure">
   372         <img src="TimingFunction.png" alt="The B&eacute;zier timing function is a
   373           smooth curve from point P0 = (0,0) to point P3 = (1,1). The
   374           length and orientation of the line segment P0-P1 determines
   375           the tangent and the curvature of the curve at P0 and the
   376           line segment P2-P3 does the same at P3.">
   377       </div>
   378       <p class="caption">
   379         B&eacute;zier Timing Function Control Points
   380       </p>
   381       <pre class="propdef">
   382         Name: transition-timing-function
   383         Value: <<single-transition-timing-function>>#
   384         Initial: ''transition-timing-function/ease''
   385         Applies to: all elements, ::before and ::after pseudo elements
   386         Inherited: no
   387         Animatable: no
   388         Percentages: N/A
   389         Media: interactive
   390         Computed value: Same as specified value.
   391         Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
   392       </pre>
   393       <div class="prod">
   394         <dfn type id="single-transition-timing-function">&lt;single-transition-timing-function&gt;</dfn> = ''ease'' | ''linear'' | ''ease-in'' | ''ease-out'' | ''ease-in-out'' | ''step-start'' | ''step-end'' | <a lt="steps()" function>steps</a>(<<integer>>[, [ ''start'' | ''end'' ] ]?) | <a lt="cubic-bezier()" function>cubic-bezier</a>(<<number>>, <<number>>, <<number>>, <<number>>)
   395       </div>
   396       <p>
   397         The timing functions have the following definitions.
   398       </p>
   399       <dl dfn-type="value" dfn-for="transition-timing-function, <single-transition-timing-function>">
   400         <dt><dfn>ease</dfn></dt>
   401         <dd>
   402           The ease function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.25, 0.1, 0.25, 1)</a>.
   403         </dd>
   404         <dt><dfn>linear</dfn></dt>
   405         <dd>
   406           The linear function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0, 0, 1, 1)</a>.
   407         </dd>
   408         <dt><dfn>ease-in</dfn></dt>
   409         <dd>
   410           The ease-in function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.42, 0, 1, 1)</a>.
   411         </dd>
   412         <dt><dfn>ease-out</dfn></dt>
   413         <dd>
   414           The ease-out function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0, 0, 0.58, 1)</a>.
   415         </dd>
   416         <dt><dfn>ease-in-out</dfn></dt>
   417         <dd>
   418           The ease-in-out function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.42, 0, 0.58, 1)</a>.
   419         </dd>
   420         <dt><dfn>step-start</dfn></dt>
   421         <dd>
   422           The step-start function is equivalent to <a lt="steps()" function>steps(1, start)</a>.
   423         </dd>
   424         <dt><dfn>step-end</dfn></dt>
   425         <dd>
   426           The step-end function is equivalent to <a lt="steps()" function>steps(1, end)</a>.
   427         </dd>
   428         <dt><dfn function lt="steps()">steps(<<integer>>[, [ start | end ] ]?)</dfn></dt>
   429         <dd>
   430           Specifies a stepping function, described above, taking two
   431           parameters. The first parameter specifies the number of intervals
   432           in the function. It must be a positive integer (greater than 0).
   433           The second parameter, which is optional, is
   434           either the value <dfn value for="steps()">start</dfn> or <dfn value for="steps()">end</dfn>, and specifies the point
   435           at which the change of values occur within the interval.
   436           If the second parameter is omitted, it is given the value ''end''.
   437         </dd>
   438         <dt><dfn function lt="cubic-bezier()">cubic-bezier(<<number>>, <<number>>, <<number>>, <<number>>)</dfn></dt>
   439         <dd>
   440           Specifies a <a
   441           href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier
   442           curve</a>. The four values specify points P<sub>1</sub> and
   443           P<sub>2</sub> of the curve as (x1, y1, x2, y2). Both x values must be
   444           in the range [0, 1] or the definition is invalid. The y values can
   445           exceed this range.
   446         </dd>
   447       </dl><!-- ======================================================================================================= -->
   448       <h3 id="transition-delay-property"><span id="the-transition-delay-property-">
   449         The 'transition-delay' Property
   450       </span></h3>
   451       <p>
   452         The 'transition-delay' property defines when the transition will start. It allows a transition to begin execution some some period of time from when it is applied. A 'transition-delay' value of ''0s'' means the transition will execute as soon as the property is changed. Otherwise, the value specifies an offset from the moment the property is changed, and the transition will delay execution by that offset.
   453       </p>
   454       <p>
   455         If the value for 'transition-delay' is a negative time offset then the transition will execute the moment the property is changed, but will appear to have begun execution at the specified offset. That is, the transition will appear to begin part-way through its play cycle. In the case where a transition has implied starting values and a negative 'transition-delay', the starting values are taken from the moment the property is changed.
   456       </p>
   457       <pre class="propdef">
   458         Name: transition-delay
   459         Value: <<time>>#
   460         Initial: ''0s''
   461         Applies to: all elements, ::before and ::after pseudo elements
   462         Inherited: no
   463         Animatable: no
   464         Percentages: N/A
   465         Media: interactive
   466         Computed value: Same as specified value.
   467         Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
   468       </pre><!-- ======================================================================================================= -->
   469       <h3 id="transition-shorthand-property"><span id="the-transition-shorthand-property-">
   470         The 'transition' Shorthand Property
   471       </span></h3>
   472       <p>
   473         The 'transition' shorthand property combines the four properties described above into a single property.
   474       </p>
   475       <pre class="propdef">
   476         Name: transition
   477         Value: <<single-transition>>#
   478         Initial: see individual properties
   479         Applies to: all elements, ::before and ::after pseudo elements
   480         Inherited: no
   481         Animatable: no
   482         Percentages: N/A
   483         Media: interactive
   484         Computed value: see individual properties
   485         Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
   486       </pre>
   488       <div class="prod">
   489         <dfn type id="single-transition">&lt;single-transition&gt;</dfn> = [ ''none'' | <<single-transition-property>> ] || <<time>> || <<single-transition-timing-function>> || <<time>>
   490       </div>
   492       <p>
   493         Note that order is important within the items in this property:
   494         the first value that can be parsed as a time is assigned to the
   495         transition-duration,
   496         and the second value that can be parsed as a time is assigned to
   497         transition-delay.
   498       </p>
   500       <p>
   501         If there is more than one <<single-transition>> in the shorthand,
   502         and any of the transitions has
   503         ''none'' as the <<single-transition-property>>,
   504         then the declaration is invalid.
   505       </p>
   507       <h2 id="starting">
   508         Starting of transitions
   509       </h2>
   511       <p>
   512         Implementations must maintain a set of
   513         <dfn export lt="running transition">running transitions</dfn>,
   514         each of which applies to a specific element and non-shorthand
   515         property.  Each of these transitions also has a
   516         <dfn export for="transition">start time</dfn>, <dfn export for="transition">end time</dfn>,
   517         <dfn export for="transition">start value</dfn>, <dfn export for="transition">end value</dfn>,
   518         <dfn export for="transition">reversing-adjusted start value</dfn>, and <dfn export for="transition">reversing shortening factor</dfn>.
   519         Transitions are added to this set as described in this section,
   520         and are removed from this set
   521         when they <a>complete</a>
   522         or when implementations are required to <dfn export for="transition">cancel</dfn> them.
   523         <span class="note">
   524           For the rationale behind the <a>reversing-adjusted start value</a>
   525           and <a>reversing shortening factor</a>, see [[#reversing]].
   526         </span>
   527       </p>
   529       <p>
   530         Implementations must also maintain a set of
   531         <dfn export lt="completed transition">completed transitions</dfn>,
   532         each of which
   533         (like <a>running transitions</a>)
   534         applies to a specific element and non-shorthand property.
   535         <span class="note">
   536           This specification maintains the invariant that
   537           there is never both a <a>running transition</a> and
   538           a <a>completed transition</a> for the same property and element.
   539         </span>
   540       </p>
   542       <p>
   543         If an element is no longer in the document,
   544         implementations must remove transitions on it
   545         from the <a>running transitions</a> and the
   546         <a>completed transitions</a>.
   547       </p>
   549       <div class="note">
   551         <p>
   552           This set of completed transitions
   553           needs to be maintained
   554           in order to prevent
   555           transitions from repeating themselves in certain cases,
   556           i.e., to maintain the invariant
   557           that this specification tries to maintain
   558           that unrelated style changes do not trigger transitions.
   559         </p>
   561         <p class="example">
   562           An example where maintaining the set of completed transitions
   563           is necessary would be a transition on
   564           an inherited property,
   565           where the parent specifies a transition of that property for
   566           a longer duration (say, ''transition: 4s text-indent'')
   567           and a child element that inherits the parent's value specifies
   568           a transition of the same property for a shorter duration
   569           (say, ''transition: 1s text-indent'').
   570           Without the maintenance of this set of completed transitions,
   571           implementations could start additional transitions on the child
   572           after the initial 1 second transition on the child completes.
   573         </p>
   575       </div>
   577       <p>
   578         Various things can cause the <a>computed values</a> of properties
   579         on an element to change.
   580         These include
   581         insertion and removal of elements from the document tree
   582         (which both changes whether those elements have <a>computed values</a> and
   583         can change the styles of other elements through selector matching),
   584         changes to the document tree that cause
   585         changes to which selectors match elements,
   586         changes to style sheets or style attributes,
   587         and other things.
   588         This specification does not define when <a>computed values</a> are updated,
   589         beyond saying that implementations must not
   590         use, present, or display something resulting from the CSS
   591         cascading, value computation, and inheritance process [[!CSS3CASCADE]]
   592         without updating the <a>computed value</a>
   593         (which means merely that implementations cannot avoid
   594         meeting requirements of this specification
   595         by claiming not to have updated the <a>computed value</a>
   596         as part of handling a style change).
   597         However,
   598         when an implementation updates the <a>computed value</a> of a
   599         property on an element
   600         to reflect one of these changes,
   601         or computes the <a>computed value</a> of a property on an element
   602         newly added to the document,
   603         it must update the <a>computed value</a>
   604         for all properties and elements to reflect all
   605         of these changes at the same time
   606         (or at least it must be undetectable that it was done at a
   607         different time).
   608         This processing of a set of simultaneous style changes is called a
   609         <dfn export>style change event</dfn>.
   610         (Implementations typically have a <a>style change event</a> to
   611         correspond with their desired screen refresh rate,
   612         and when up-to-date computed style or layout information is needed
   613         for a script API that depends on it.)
   614       </p>
   616       <p>
   617         Since this specification does not define
   618         when a <a>style change event</a> occurs,
   619         and thus what changes to computed values are considered simultaneous,
   620         authors should be aware that changing any of the transition
   621         properties a small amount of time after making a change that
   622         might transition can result in behavior that varies between
   623         implementations, since the changes might be considered
   624         simultaneous in some implementations but not others.
   625       </p>
   627       <p>
   628         When a <a>style change event</a> occurs,
   629         implementations must start transitions based on
   630         the <a>computed values</a> that changed in that event.
   631         If an element is not in the document during that
   632         style change even or was not in the document during
   633         the previous style change event,
   634         then transitions are not started for that element
   635         in that style change event.
   636         Otherwise,
   637         define the <dfn export>before-change style</dfn> as
   638         the <a>computed values</a> of all properties on the element as of
   639         the previous <a>style change event</a>,
   640         except with any styles derived from declarative
   641         animations such as CSS Transitions, CSS Animations
   642         ([[CSS3-ANIMATIONS]]),
   643         and SMIL Animations ([[SMIL-ANIMATION]], [[SVG11]])
   644         updated to the current time.
   645         Likewise, define the <dfn export>after-change style</dfn> as
   646         the <a>computed values</a> of all properties
   647         on the element based on the information
   648         known at the start of that <a>style change event</a>,
   649         but excluding any styles from CSS Transitions in the computation,
   650         and inheriting from
   651         the <a>after-change style</a> of the parent.
   652       </p>
   654       <div class="note">
   655         <p>
   656           Note that this definition of the <a>after-change style</a>
   657           means that a single change
   658           can start a transition on the same property
   659           on both an ancestor element and its descendant element.
   660           This can happen when a property change is inherited
   661           from one element with 'transition-*' properties
   662           that say to animate the changing property
   663           to another element with 'transition-*' properties
   664           that also say to animate the changing property.
   665         </p>
   667         <p>
   668           When this happens, both transitions will run,
   669           and the transition on the descendant will override
   670           the transition on the ancestor
   671           because of the normal
   672           CSS cascading and inheritance rules ([[CSS3CASCADE]]).
   673         </p>
   675         <p>
   676           If the transition on the descendant completes before
   677           the transition on the ancestor,
   678           the descendant will then resume inheriting
   679           the (still transitioning) value from its parent.
   680           This effect is likely not a desirable effect,
   681           but it is essentially doing what the author asked for.
   682         </p>
   683       </div>
   685       <p>
   686         For each element with a <a>before-change style</a> and
   687         an <a>after-change style</a>,
   688         and each property (other than shorthands),
   689         define the <dfn export>matching transition-property value</dfn> as
   690         the last value in the
   691         'transition-property' in the element's <a>after-change style</a>
   692         that matches the property,
   693         as described in
   694         [[#transition-property-property]].
   695         If there is such a value, then corresponding to it, there is
   696         a <dfn export>matching transition duration</dfn>,
   697         a <dfn export>matching transition delay</dfn>, and
   698         a <dfn export>matching transition timing function</dfn>
   699         in the values in the <a>after-change style</a> of
   700         'transition-duration', 'transition-delay', and 'transition-timing-function'
   701         (see <a href="#list-matching">the rules on matching lists</a>).
   702         Define the <dfn export for="transition">combined duration</dfn> of the transition
   703         as the sum of max(<a>matching transition duration</a>, ''0s'') and
   704         the <a>matching transition delay</a>.
   705         For each element and property, the implementation must act
   706         as follows:
   707       </p>
   709       <ol>
   710       <li>
   711         If all of the following are true:
   712         <ul>
   713           <li>
   714             the element does not have
   715             a <a>running transition</a> for the property,
   716           </li>
   717           <li>
   718             the <a>before-change style</a> is different from
   719             and can be interpolated with
   720             the <a>after-change style</a> for that property,
   721           </li>
   722           <li>
   723             the element does not have a <a>completed transition</a>
   724             for the property
   725             or the <a>end value</a> of the <a>completed transition</a>
   726             is different from the <a>after-change style</a> for the property,
   727           </li>
   728           <li>
   729             there is a <a>matching transition-property value</a>, and
   730           </li>
   731           <li>
   732             the <a>combined duration</a> is greater than ''0s'',
   733           </li>
   734         </ul>
   735         then implementations must
   736         remove the <a>completed transition</a> (if present) from the set
   737         of completed transitions and
   738         start a transition whose:
   739         <ul>
   740           <li>
   741             <a>start time</a> is
   742             the time of the <a>style change event</a> plus
   743             the <a>matching transition delay</a>,
   744           </li>
   745           <li>
   746             <a>end time</a> is
   747             the <a>start time</a> plus
   748             the <a>matching transition duration</a>,
   749           </li>
   750           <li>
   751             <a>start value</a> is
   752             the value of the transitioning property
   753             in the <a>before-change style</a>,
   754           </li>
   755           <li>
   756             <a>end value</a> is
   757             the value of the transitioning property
   758             in the <a>after-change style</a>,
   759           </li>
   760           <li>
   761             <a>reversing-adjusted start value</a> is the same as
   762             the <a>start value</a>, and
   763           <li>
   764             <a>reversing shortening factor</a> is 1.
   765           </li>
   766         </ul>
   767       </li>
   768       <li>
   769         Otherwise,
   770         if the element has a <a>completed transition</a> for the property
   771         and the <a>end value</a> of the <a>completed transition</a>
   772         is different from the <a>after-change style</a> for the property,
   773         then implementations must
   774         remove the <a>completed transition</a> from the set of
   775         <a>completed transitions</a>.
   776       </li>
   777       <li>
   778         If the element has a <a>running transition</a> or
   779         <a>completed transition</a> for the property,
   780         and there is <strong>not</strong>
   781         a <a>matching transition-property value</a>,
   782         then implementations must
   783         <a>cancel</a> the <a>running transition</a>
   784         or remove the <a>completed transition</a> from the set of
   785         <a>completed transitions</a>.
   786       </li>
   787       <li>
   788         If the element has a <a>running transition</a> for the property,
   789         there is a <a>matching transition-property value</a>,
   790         and the <a>end value</a> of the <a>running transition</a> is
   791         <strong>not</strong> equal to the value of the property in the
   792         <a>after-change style</a>, then:
   793         <ol>
   794           <li>
   795             If the <a>current value</a> of the property
   796             in the <a>running transition</a>
   797             is equal to
   798             the value of the property in the <a>after-change style</a>,
   799             or if these two values cannot be interpolated,
   800             then implementations must
   801             <a>cancel</a> the <a>running transition</a>.
   802           </li>
   803           <li>
   804             Otherwise, if the <a>combined duration</a> is
   805             less than or equal to ''0s'',
   806             or if the
   807             <a>current value</a> of the property in the <a>running transition</a>
   808             cannot be interpolated with
   809             the value of the property in the <a>after-change style</a>,
   810             then implementations must
   811             <a>cancel</a> the <a>running transition</a>.
   812           </li>
   813           <li>
   814             Otherwise, if the <a>reversing-adjusted start value</a>
   815             of the <a>running transition</a> is the same as the value of
   816             the property in the <a>after-change style</a>
   817             <span class="note">(see the
   818             <a href="#reversing">section on reversing of
   819             transitions</a> for why these case exists)</span>,
   820             implementations must
   821             <a>cancel</a> the <a>running transition</a> and
   822             start a new transition whose:
   823             <ul>
   824               <li>
   825                 <a>reversing-adjusted start value</a> is
   826                 the <a>end value</a> of the
   827                 <a>running transition</a>
   828                 <span class="note">(Note: This represents the logical start state of
   829                 the transition, and allows some calculations to ignore that
   830                 the transition started before that state was reached, which
   831                 in turn allows repeated reversals of the same transition to
   832                 work correctly),</span>
   833               <li>
   834                 <a>reversing shortening factor</a>
   835                 is the absolute value, clamped to the range [0, 1],
   836                 of the sum of:
   837                 <ol>
   838                   <li>the output of the timing function of the old transition
   839                   at the time of the <a>style change event</a>,
   840                   times the <a>reversing shortening factor</a> of the
   841                   old transition</li>
   842                   <li>1 minus the <a>reversing shortening factor</a> of
   843                   the old transition.</li>
   844                 </ol>
   845                 <span class="note">Note: This represents the portion of the
   846                 space between the <a>reversing-adjusted start value</a>
   847                 and the <a>end value</a> that the old transition has
   848                 traversed (in amounts of the value, not time), except with the
   849                 absolute value and clamping to handle timing functions that
   850                 have y1 or y2 outside the range [0, 1].</span>
   851               </li>
   852               <li>
   853                 <a>start time</a> is
   854                 the time of the <a>style change event</a> plus:
   855                 <ol>
   856                   <li>if the <a>matching transition delay</a>
   857                       is nonnegative,
   858                       the <a>matching transition delay</a>, or
   859                   <li>if the <a>matching transition delay</a>
   860                       is negative,
   861                       the product of
   862                       the new transition's
   863                       <a>reversing shortening factor</a> and
   864                       the <a>matching transition delay</a>,
   865                 </ol>
   866               </li>
   867               <li>
   868                 <a>end time</a> is
   869                 the <a>start time</a> plus the product of
   870                 the <a>matching transition duration</a> and
   871                 the new transition's <a>reversing shortening factor</a>,
   872               </li>
   873               <li>
   874                 <a>start value</a> is
   875                 the <a>current value</a> of the property
   876                 in the <a>running transition</a>,
   877               </li>
   878               <li>
   879                 <a>end value</a> is
   880                 the value of the property
   881                 in the <a>after-change style</a>,
   882               </li>
   883             </ul>
   884           </li>
   885           <li>
   886             Otherwise, implementations must
   887             <a>cancel</a> the <a>running transition</a>
   888             and start a new transition whose:
   889             <ul>
   890               <li>
   891                 <a>start time</a> is
   892                 the time of the <a>style change event</a> plus
   893                 the <a>matching transition delay</a>,
   894               </li>
   895               <li>
   896                 <a>end time</a> is
   897                 the <a>start time</a> plus
   898                 the <a>matching transition duration</a>,
   899               </li>
   900               <li>
   901                 <a>start value</a> is
   902                 the <a>current value</a> of the property
   903                 in the <a>running transition</a>,
   904               </li>
   905               <li>
   906                 <a>end value</a> is
   907                 the value of the property
   908                 in the <a>after-change style</a>,
   909               </li>
   910               <li>
   911                 <a>reversing-adjusted start value</a> is the same as
   912                 the <a>start value</a>, and
   913               <li>
   914                 <a>reversing shortening factor</a> is 1.
   915               </li>
   916             </ul>
   917           </li>
   918         </ol>
   919       </li>
   921       </ol>
   923       <div class="note">
   924         <p>
   925           Note that the above rules mean that
   926           when the computed value of an animatable property changes,
   927           the transitions that start are based on the
   928           values of the 'transition-property', 'transition-duration',
   929           'transition-timing-function', and 'transition-delay' properties
   930           at the time the animatable property would first have its new
   931           computed value.
   932           This means that when one of these 'transition-*' properties
   933           changes at the same time as
   934           a property whose change might transition,
   935           it is the <em>new</em> values of the 'transition-*' properties
   936           that control the transition.
   937         </p>
   938         <div class="example" id="manual-reversing-example">
   939           <p style="display:none">
   940             Example(s):
   941           </p>
   942           <p>This provides a way for authors to specify different values
   943           of the 'transition-*' properties for the &ldquo;forward&rdquo;
   944           and &ldquo;reverse&rdquo; transitions (but see <a
   945           href="#reversing">below</a> for special reversing behavior when
   946           an <em>incomplete</em> transition is interrupted).  Authors can
   947           specify the value of 'transition-duration',
   948           'transition-timing-function', or 'transition-delay' in the same
   949           rule where they specify the value that triggers the transition,
   950           or can change these properties at the same time as they change
   951           the property that triggers the transition.  Since it's the new
   952           values of these 'transition-*' properties that affect the
   953           transition, these values will be used for the transitions
   954           <em>to</em> the associated transitioning values.  For example:
   955            </p>
   956           <pre>
   957   li {
   958     transition: background-color linear 1s;
   959     background: blue;
   960   }
   961   li:hover {
   962     background-color: green;
   963     transition-duration: 2s; /* applies to the transition *to* the :hover state */
   964   }</pre>
   965           <p>
   966             When a list item with these style rules enters the :hover
   967             state, the computed 'transition-duration' at the time that
   968             'background-color' would have its new value (''green'') is ''2s'',
   969             so the transition from ''blue'' to ''green'' takes 2 seconds.
   970             However, when the list item leaves the :hover state, the
   971             transition from ''green'' to ''blue'' takes 1 second.
   972           </p>
   973         </div>
   974       </div>
   976       <p class="note">
   977         Note that once the transition of a property has started
   978         (including being in its delay phase),
   979         it continues running based on
   980         the original timing function, duration, and
   981         delay, even if the 'transition-timing-function',
   982         'transition-duration', or 'transition-delay' property changes
   983         before the transition is complete.  However, if the
   984         'transition-property' property changes such that the transition
   985         would not have started, the transition stops (and the
   986         property immediately changes to its final value).
   987       </p>
   989       <p class="note">
   990         Note that above rules mean that
   991         transitions do not start when the computed
   992         value of a property changes as a result of declarative animation
   993         (as opposed to scripted animation).
   994         This happens because the before-change style includes up-to-date
   995         style for declarative animations.
   996       </p>
   998       <h3 id="reversing">
   999         Faster reversing of interrupted transitions
  1000       </h3>
  1001       <div class="note">
  1003       <p>
  1004         Many common transitions effects involve transitions between two states,
  1005         such as the transition that occurs when the mouse pointer moves
  1006         over a user interface element, and then later moves out of that element.
  1007         With these effects, it is common for a running transition
  1008         to be interrupted before it completes,
  1009         and the property reset to the starting value of that transition.
  1010         An example is a hover effect on an element,
  1011         where a transition starts when the pointer enters the element,
  1012         and then the pointer exits the element before the effect has completed.
  1013         If the outgoing and incoming transitions
  1014         are executed using their specified durations and timing functions,
  1015         the resulting effect can be distractingly asymmetric
  1016         because the second transition
  1017         takes the full specified time to move a shortened distance.
  1018         Instead, this specification makes second transition shorter.
  1019       </p>
  1021       <p>
  1022         The mechanism the above rules use to cause this involves the
  1023         <a>reversing shortening factor</a> and the
  1024         <a>reversing-adjusted start value</a>.
  1025         In particular, the reversing behavior is present whenever
  1026         the <a>reversing shortening factor</a> is less than 1.
  1027       </p>
  1029       <p class="note">
  1030         Note that these rules do not fully address the problem for
  1031         transition patterns that involve more than two states.
  1032       </p>
  1034       <p class="note">
  1035         Note that these rules lead to the entire timing function of the
  1036         new transition being used, rather than jumping into the middle
  1037         of a timing function, which can create a jarring effect.
  1038       </p>
  1040       <p class="note">
  1041         This was one of several possibilities that was considered by the
  1042         working group.  See the
  1043         <a href="transition-reversing-demo">reversing demo</a>
  1044         demonstrating a number of them, leading to a working group
  1045         resolution made on 2013-06-07 and edits made on 2013-11-11.
  1046       </p>
  1048       </div>
  1050       <h2 id="application">
  1051         Application of transitions
  1052       </h2>
  1054       <p>
  1055         When a property on an element is undergoing a transition
  1056         (that is, when or after the transition has started and before the
  1057         <a>end time</a> of the transition)
  1058         the transition adds a style called the <dfn export>current value</dfn>
  1059         to the CSS cascade
  1060         at the level defined for CSS Transitions in [[!CSS3CASCADE]].
  1061       </p>
  1063       <p class="note">
  1064         Note that this means that computed values
  1065         resulting from CSS transitions
  1066         can inherit to descendants just like
  1067         any other computed values.
  1068         In the normal case, this means that
  1069         a transition of an inherited property
  1070         applies to descendant elements
  1071         just as an author would expect.
  1072       </p>
  1074       <p>
  1075         Implementations must add this value to the cascade
  1076         if and only if
  1077         that property is not currently
  1078         undergoing a CSS Animation ([[!CSS3-ANIMATIONS]]) on the same element.
  1079       </p>
  1081       <p class="note">
  1082         Note that this behavior of transitions not applying to the cascade
  1083         when an animation on the same element and property is running
  1084         does not affect whether the transition has started or ended.
  1085         APIs that detect whether transitions are running
  1086         (such as <a href="#transition-events">transition events</a>)
  1087         still report that a transition is running.
  1088       </p>
  1090       <p>
  1091         If the current time is at or before the
  1092         <a>start time</a> of the transition
  1093         (that is, during the delay phase of the transition),
  1094         the <a>current value</a> is a specified style that will compute
  1095         to the <a>start value</a> of the transition.
  1096       </p>
  1098       <p>
  1099         If the current time is after the
  1100         <a>start time</a> of the transition
  1101         (that is, during the duration phase of the transition),
  1102         the <a>current value</a> is a specified style that will compute
  1103         to the <a href="#animatable-types">result of interpolating the property</a>
  1104         using the <a>start value</a> of the transition as
  1105         <var>V</var><sub>start</sub>,
  1106         using the <a>end value</a> of the transition as
  1107         <var>V</var><sub>end</sub>,
  1108         and using (current time - start time) / (end time - start time)
  1109         as the input to the timing function.
  1110       </p>
  1112       <h2 id="complete">Completion of transitions</h2>
  1114       <p>
  1115         <a>Running transitions</a>
  1116         <dfn export for="transition" id="dfn-complete">complete</dfn>
  1117         at a time that equal to or after their end time,
  1118         but prior to to the first <a>style change event</a>
  1119         whose time is equal to or after their <a>end time</a>.
  1120         When a transition completes,
  1121         implementations must move
  1122         all transitions that complete at that time
  1123         from the set of <a>running transitions</a>
  1124         to the set of <a>completed transitions</a>
  1125         and then fire the <a href="#transition-events">events</a>
  1126         for those completions.
  1127         <span class="note">(Note that doing otherwise, that is,
  1128         firing some of the events before doing all of the moving
  1129         from <a>running transitions</a> to <a>completed transitions</a>,
  1130         could allow
  1131         a style change event to happen
  1132         without the necessary transitions completing,
  1133         since firing the event could cause a style change event,
  1134         if an event handler requests up-to-date computed style or
  1135         layout data.)</span>
  1136       </p>
  1138       <h2 id="transition-events"><span id="transition-events-">
  1139         Transition Events
  1140       </span></h2>
  1141       <p>
  1142         The completion of a CSS Transition generates a corresponding <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM Event</a>.
  1143         An event is <a>dispatched</a> to the element
  1144         for each property that undergoes a transition on that element.
  1145         This allows a content developer to perform actions that synchronize
  1146         with the completion of a transition.
  1147       </p>
  1148       <p>
  1149         Each event provides the name of the property the transition is
  1150         associated with as well as the duration of the transition.
  1151       </p>
  1152       <dl>
  1153         <dt>
  1154           <b>Interface <dfn interface id="Events-TransitionEvent">TransitionEvent</dfn></b>
  1155         </dt>
  1156         <dd>
  1157           <p>
  1158             The {{TransitionEvent}} interface provides specific contextual information associated with transitions.
  1159           </p>
  1160           <dl>
  1161             <dt>
  1162               <b>IDL Definition</b>
  1163             </dt>
  1164             <dd>
  1165               <div class='idl-code'>
  1166                 <pre class='idl'>
  1167   [Constructor(DOMString type, optional TransitionEventInit transitionEventInitDict)]
  1168   interface TransitionEvent : Event {
  1169     readonly attribute DOMString          propertyName;
  1170     readonly attribute float              elapsedTime;
  1171     readonly attribute DOMString          pseudoElement;
  1172   };
  1174   dictionary TransitionEventInit : EventInit {
  1175     DOMString propertyName = "";
  1176     float elapsedTime = 0.0;
  1177     DOMString pseudoElement = "";
  1178   };
  1179   </pre>
  1180               </div>
  1181             </dd>
  1182             <dt>
  1183               <b>Attributes</b>
  1184             </dt>
  1185             <dd>
  1186               <dl>
  1187                 <dt>
  1188                   <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-propertyName">propertyName</dfn></code> of type <code>DOMString</code>, readonly
  1189                 </dt>
  1190                 <dd>
  1191                   The name of the CSS property associated with the transition.
  1192                 </dd>
  1193               </dl>
  1194               <dl>
  1195                 <dt>
  1196                   <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-elapsedTime">elapsedTime</dfn></code> of type <code>float</code>, readonly
  1197                 </dt>
  1198                 <dd>
  1199                   The amount of time the transition has been running, in seconds, when this event fired. Note that this value is not affected by the value of <code class="property">transition-delay</code>.
  1200                 </dd>
  1201               </dl>
  1202               <dl>
  1203                 <dt>
  1204                   <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-pseudoElement">pseudoElement</dfn></code> of type <code>DOMString</code>, readonly
  1205                 </dt>
  1206                 <dd>
  1207                   The name (beginning with two colons) of the CSS
  1208                   pseudo-element on which the transition occurred (in
  1209                   which case the target of the event is that
  1210                   pseudo-element's corresponding element), or the empty
  1211                   string if the transition occurred on an element (which
  1212                   means the target of the event is that element).
  1213                 </dd>
  1214               </dl>
  1215             </dd>
  1216           </dl>
  1217           <p>
  1218             <code id="TransitionEvent-constructor">TransitionEvent(type, transitionEventInitDict)</code>
  1219             is an <a>event constructor</a>.
  1220           </p>
  1221         </dd>
  1222       </dl>
  1223       <p>
  1224         There is one type of transition event available.
  1225       </p>
  1226       <dl>
  1227         <dt>
  1228           <b><dfn event for="Element" id="transitionend">transitionend</dfn></b>
  1229         </dt>
  1230         <dd>
  1231           The {{transitionend}} event occurs at the completion of the transition. In the
  1232           case where a transition is removed before completion, such as if the
  1233           transition-property is removed, then the event will not fire.
  1234           <ul>
  1235             <li>Bubbles: Yes
  1236             </li>
  1237             <li>Cancelable: No
  1238             </li>
  1239             <li>Context Info: propertyName, elapsedTime, pseudoElement
  1240             </li>
  1241           </ul>
  1242         </dd>
  1243       </dl>
  1245       <h2 id="animatable-types"><span id="animation-of-property-types-">
  1246         Animation of property types
  1247       </span></h2>
  1249       <p>
  1250         Some property types can be interpolated,
  1251         which means they can animate smoothly from one value to another.
  1252         Other property types cannot, and thus animate only in a single
  1253         step from one value to the other.
  1254       </p>
  1256       <h3 id="interpolated-types">Animation of interpolated property types</h3>
  1258       <p>
  1259         When interpolating between two values,
  1260         <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
  1261         interpolation is done using the output <var>p</var> of the timing function,
  1262         which gives the portion of the value space
  1263         that the interpolation has crossed.
  1264         Thus the result of the interpolation is
  1265         <var>V</var><sub>res</sub> =
  1266           (1 - <var>p</var>) &sdot; <var>V</var><sub>start</sub> +
  1267           <var>p</var> &sdot; <var>V</var><sub>end</sub>.
  1268       </p>
  1270       <p>
  1271         However, if this value (<var>V</var><sub>res</sub>)
  1272         is outside the allowed range of values for the property,
  1273         then it is clamped to that range.
  1274         This can occur if <var>p</var> is outside of the range 0 to 1,
  1275         which can occur if a timing function is specified
  1276         with a <var>y1</var> or <var>y2</var> that is outside the range 0 to 1.
  1277       </p>
  1279       <p>
  1280         The following describes how each property type undergoes transition or
  1281         animation.
  1282       </p>
  1284       <ul>
  1285         <li id="animtype-color">
  1286           <strong>color</strong>: interpolated via red, green, blue and alpha
  1287           components (treating each as a number, see below).
  1288           The interpolation is done between premultiplied colors
  1289           (that is, colors for which the red, green, and blue components
  1290           specified have been multiplied by the alpha).
  1291         </li>
  1292         <li id="animtype-length">
  1293           <strong>length</strong>: interpolated as real numbers.
  1294         </li>
  1295         <li id="animtype-percentage">
  1296           <strong>percentage</strong>: interpolated as real numbers.
  1297         </li>
  1298         <li id="animtype-lpcalc">
  1299           <strong>length, percentage, or calc</strong>: when both values
  1300           are lengths, interpolated as lengths; when both values are
  1301           percentages, interpolated as percentages; otherwise, both
  1302           values are converted into a ''calc()'' function that is the
  1303           sum of a length and a percentage (each possibly zero), and
  1304           these ''calc()'' functions have each half interpolated as real
  1305           numbers.
  1306         </li>
  1307         <li id="animtype-integer">
  1308           <strong>integer</strong>: interpolated via discrete steps (whole
  1309           numbers). The interpolation happens in real number space and is
  1310           converted to an integer by rounding to the nearest integer, with
  1311           values halfway between a pair of integers rounded towards
  1312           positive infinity.
  1313         </li>
  1314         <li id="animtype-font-weight">
  1315           <strong>font weight</strong>: interpolated via discrete steps
  1316           (multiples of 100). The interpolation happens in real number
  1317           space and is converted to an integer by rounding to the
  1318           nearest multiple of 100, with values halfway between multiples
  1319           of 100 rounded towards positive infinity.
  1320         </li>
  1321         <li id="animtype-number">
  1322           <strong>number</strong>: interpolated as real (floating point)
  1323           numbers.
  1324         </li>
  1325         <li id="animtype-rect">
  1326           <strong>rectangle</strong>: interpolated via the x, y,
  1327           width and height components (treating each as a number).
  1328         </li>
  1329         <li id="animtype-visibility">
  1330           <strong>visibility</strong>: if one of the values is
  1331           ''visibility/visible'', interpolated as a discrete step where values of the
  1332           timing function between 0 and 1 map to ''visibility/visible'' and other
  1333           values of the timing function (which occur only at the
  1334           start/end of the transition or as a result of ''cubic-bezier()''
  1335           functions with Y values outside of [0, 1]) map to the closer
  1336           endpoint; if neither value is ''visibility/visible'' then not interpolable.
  1337         </li>
  1338         <li id="animtype-shadow-list">
  1339           <strong>shadow list</strong>: Each shadow in the list is
  1340           interpolated via the
  1341           color (as <a href="#animtype-color">color</a>) component,
  1342           and x, y, blur, and (when appropriate) spread
  1343           (as <a href="#animtype-length">length</a>) components.
  1344           For each shadow, if both input shadows are ''shadow/inset''
  1345           or both input shadows are not ''shadow/inset'',
  1346           then the interpolated shadow must match the input shadows in that regard.
  1347           If any pair of input shadows has one ''shadow/inset'' and the other not ''shadow/inset'',
  1348           the entire <a href="#animtype-shadow-list">shadow-list</a> is uninterpolable.
  1349           If the lists of shadows have different lengths,
  1350           then the shorter list is padded at the end
  1351           with shadows whose color is ''transparent'',
  1352           all lengths are ''0'',
  1353           and whose ''shadow/inset'' (or not) matches the longer list.
  1354         </li>
  1355         <li id="animtype-gradient">
  1356           <strong>gradient</strong>: interpolated via the
  1357           positions and colors of each stop. They must have the same type
  1358           (radial or linear) and same number of stops in order to be animated.
  1359           <span class="note">Note: [[CSS3-IMAGES]] may extend this
  1360           definition.</span>
  1361         </li>
  1362         <li id="animtype-paintserver">
  1363           <strong>paint server</strong> (SVG): interpolation is only supported
  1364           between: gradient to gradient and color to color. They then
  1365           work as above.
  1366         </li>
  1367         <li id="animtype-simple-list">
  1368           <strong>simple list</strong> of other types:
  1369           If the lists have the same number of items,
  1370           and each pair of values can be interpolated,
  1371           each item in the list is interpolated using
  1372           the rules given for those types.
  1373           Otherwise the values are not interpolable.
  1374         </li>
  1375         <li id="animtype-repeatable-list">
  1376           <strong>repeatable list</strong> of other types:
  1377           The result list has a length that is the least common multiple
  1378           of the lengths of the input lists.
  1379           Each item in the result is the interpolation of the value
  1380           from each input list repeated to the length of the result list.
  1381           If a pair of values cannot be interpolated, then the lists
  1382           are not interpolable.
  1383           <span class="note">
  1384             The repeatable list concept ensures that a list that is
  1385             conceptually repeated to a certain length (as
  1386             'background-origin' is repeated to the length of the
  1387             'background-image' list) or repeated infinitely will
  1388             smoothly transition between any values, and so that the
  1389             computed value will properly represent the result (and
  1390             potentially be inherited correctly).
  1391           </span>
  1392         </li>
  1393       </ul>
  1395       <p>Future specifications may define additional types that can
  1396       be animated.</p>
  1398       <p>See the definition of 'transition-property' for how animation
  1399       of shorthand properties and the ''all'' value is applied to any
  1400       properties (in the shorthand) that can be animated.</p>
  1402       <h3 id="step-types">Animation in steps of other property types</h3>
  1404       <p>
  1405         When interpolating between two values that cannot be interpolated,
  1406         <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
  1407         interpolation is done using the output <var>p</var> of the timing function.
  1408         If <var>p</var> is less than 0.5, then the
  1409         result of the interpolation is
  1410         <var>V</var><sub>start</sub>;
  1411         if <var>p</var> is greater than or equal to 0.5, then the
  1412         result of the interpolation is
  1413         <var>V</var><sub>end</sub>.
  1414       </p>
  1416       <p class="note" id="discrete-interpolation-at-risk">
  1417         This is a recent change to which implementations have
  1418         not yet updated.  (Prior to the change CSS Transitions
  1419         and CSS Animations did not run on such changes.)  It's
  1420         possible that it won't be compatible with existing Web content.
  1421         If that is the case, the problem may be mitigated by restricting
  1422         this behavior only to CSS Animations (and not to CSS Transitions),
  1423         and/or restricting it to step timing functions.
  1424       </p>
  1426       <h2 id="animatable-properties"><span id="animatable-properties-">
  1427         Animatable properties
  1428       </span></h2>
  1430       <!--
  1431       As resolved in
  1432       http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html
  1433       -->
  1435       <p>The definition of each CSS property defines
  1436       when the values of that property can be interpolated
  1437       by referring to the definitions of property types
  1438       in the <a href="#animatable-types">previous section</a>.
  1439       The animated value is interpolated from the from and to values when
  1440       both the from and the to values of the property have the type described.
  1441       (When a composite type such as "length, percentage, or calc" is listed,
  1442       this means that both values must fit into that composite type.)
  1443       When multiple types are listed in the form "either A or B",
  1444       both values must be of the same type to be interpolable.</p>
  1446       <p>Otherwise, since the from and to values cannot be interpolated,
  1447       the animation is done <a href="#step-types">in a single step</a>.</p>
  1449       <p>The 'transition-*' properties defined in this specification do
  1450       not undergo transitions.</p>
  1452       <p>For properties that exist at the time this specification was
  1453       developed, this specification defines how they are
  1454       animated.  However, future CSS specifications may define
  1455       additional properties, additional values for existing properties,
  1456       or additional animation behavior of existing values.  In order to
  1457       describe new animation behaviors and to have the definition of
  1458       animation behavior in a more appropriate location, future CSS
  1459       specifications should include an "Animatable:" line in the summary
  1460       of the property's definition (in addition to the other lines
  1461       described in [[CSS21]], <a
  1462       href="http://www.w3.org/TR/CSS21/about.html#property-defs">section
  1463       1.4.2</a>).  This line should say "no" to indicate that a property
  1464       cannot be animated or should reference an animation behavior
  1465       (which may be one of the behaviors in the <a
  1466       href="#animation-of-property-types-">Animation of property
  1467       types</a> section above, or may be a new behavior) to define how
  1468       the property animates.  Such definitions override those given in
  1469       this specification.</p>
  1471       <p class="issue">
  1472         It no longer makes sense for this line to be called
  1473         "Animatable".  It should probably be renamed to "Interpolation",
  1474         and the "no" value renamed to "discrete" or "in steps".
  1475       </p>
  1477       <h3 id="animatable-css"><span id="properties-from-css-">
  1478         Properties from CSS
  1479       </span></h3>
  1481       <p>
  1482       The following definitions define the animation behavior for
  1483       properties in CSS Level 2 Revision 1 ([[CSS21]]) and in Level 3 of
  1484       the CSS Color Module ([[CSS3COLOR]]).
  1485       </p>
  1487      <table class="animatable-properties">
  1488        <tr>
  1489          <th>Property Name</th>
  1490          <th>Type</th>
  1491        </tr>
  1492        <tr>
  1493          <td>'background-color'</td><td>as <a href="#animtype-color">color</a></tr>
  1494        <tr>
  1495          <td>'background-position'</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1496        </tr>
  1497        <tr>
  1498          <td>'border-bottom-color'</td><td>as <a href="#animtype-color">color</a></td>
  1499        </tr>
  1500        <tr>
  1501          <td>'border-bottom-width'</td><td>as <a href="#animtype-length">length</a></td>
  1502        </tr>
  1503        <tr>
  1504          <td>'border-left-color'</td><td>as <a href="#animtype-color">color</a></td>
  1505        </tr>
  1506        <tr>
  1507          <td>'border-left-width'</td><td>as <a href="#animtype-length">length</a></td>
  1508        </tr>
  1509        <tr>
  1510          <td>'border-right-color'</td><td>as <a href="#animtype-color">color</a></td>
  1511        </tr>
  1512        <tr>
  1513          <td>'border-right-width'</td><td>as <a href="#animtype-length">length</a></td>
  1514        </tr>
  1515        <tr>
  1516          <td>'border-spacing'</td><td>as <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-length">length</a></td>
  1517        </tr>
  1518        <tr>
  1519          <td>'border-top-color'</td><td>as <a href="#animtype-color">color</a></td>
  1520        </tr>
  1521        <tr>
  1522          <td>'border-top-width'</td><td>as <a href="#animtype-length">length</a></td>
  1523        </tr>
  1524        <tr>
  1525          <td>'bottom'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1526        </tr>
  1527        <tr>
  1528          <td>'clip'</td><td>as <a href="#animtype-rect">rectangle</a></td>
  1529        </tr>
  1530        <tr>
  1531          <td>'color'</td><td>as <a href="#animtype-color">color</a></td>
  1532        </tr>
  1533        <tr>
  1534          <td>'font-size'</td><td>as <a href="#animtype-length">length</a></td>
  1535        </tr>
  1536        <tr>
  1537          <td>'font-weight!!property'</td><td>as <a href="#animtype-font-weight">font weight</a></td>
  1538        </tr>
  1539        <tr>
  1540          <td>'height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1541        </tr>
  1542        <tr>
  1543          <td>'left'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1544        </tr>
  1545        <tr>
  1546          <td>'letter-spacing'</td><td>as <a href="#animtype-length">length</a></td>
  1547        </tr>
  1548        <tr>
  1549          <td>'line-height'</td><td>as either <a href="#animtype-number">number</a> or <a href="#animtype-length">length</a></td>
  1550        </tr>
  1551        <tr>
  1552          <td>'margin-bottom'</td><td>as <a href="#animtype-length">length</a></td>
  1553        </tr>
  1554        <tr>
  1555          <td>'margin-left'</td><td>as <a href="#animtype-length">length</a></td>
  1556        </tr>
  1557        <tr>
  1558          <td>'margin-right'</td><td>as <a href="#animtype-length">length</a></td>
  1559        </tr>
  1560        <tr>
  1561          <td>'margin-top'</td><td>as <a href="#animtype-length">length</a></td>
  1562        </tr>
  1563        <tr>
  1564          <td>'max-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1565        </tr>
  1566        <tr>
  1567          <td>'max-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1568        </tr>
  1569        <tr>
  1570          <td>'min-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1571        </tr>
  1572        <tr>
  1573          <td>'min-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1574        </tr>
  1575        <tr>
  1576          <td>'opacity'</td><td>as <a href="#animtype-number">number</a></td>
  1577        </tr>
  1578        <tr>
  1579          <td>'outline-color'</td><td>as <a href="#animtype-color">color</a></td>
  1580        </tr>
  1581        <tr>
  1582          <td>'outline-width'</td><td>as <a href="#animtype-length">length</a></td>
  1583        </tr>
  1584        <tr>
  1585          <td>'padding-bottom'</td><td>as <a href="#animtype-length">length</a></td>
  1586        </tr>
  1587        <tr>
  1588          <td>'padding-left'</td><td>as <a href="#animtype-length">length</a></td>
  1589        </tr>
  1590        <tr>
  1591          <td>'padding-right'</td><td>as <a href="#animtype-length">length</a></td>
  1592        </tr>
  1593        <tr>
  1594          <td>'padding-top'</td><td>as <a href="#animtype-length">length</a></td>
  1595        </tr>
  1596        <tr>
  1597          <td>'right'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1598        </tr>
  1599        <tr>
  1600          <td>'text-indent'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1601        </tr>
  1602        <tr>
  1603          <td>'text-shadow'</td><td>as <a href="#animtype-shadow-list">shadow list</a></td>
  1604        </tr>
  1605        <tr>
  1606          <td>'top'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1607        </tr>
  1608        <tr>
  1609          <td>'vertical-align'</td><td>as <a href="#animtype-length">length</a></td>
  1610        </tr>
  1611        <tr>
  1612          <td>'visibility'</td><td>as <a href="#animtype-visibility">visibility</a></td>
  1613        </tr>
  1614        <tr>
  1615          <td>'width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
  1616        </tr>
  1617        <tr>
  1618          <td>'word-spacing'</td><td>as <a href="#animtype-length">length</a></td>
  1619        </tr>
  1620        <tr>
  1621          <td>'z-index'</td><td>as <a href="#animtype-integer">integer</a></td>
  1622        </tr>
  1623      </table>
  1625      <h3 id="animatable-svg"><span id="properties-from-svg-">
  1626        Properties from SVG
  1627      </span></h3>
  1629      <p>
  1630        All properties defined as animatable in the SVG specification, provided
  1631        they are one of the property types listed above.
  1632       </p>
  1634      <!-- <table>
  1635        <tr>
  1636          <th>Property Name</th><th>Type</th>
  1637        </tr>
  1638        <tr>
  1639          <td>stop-color</td><td>as <a href="#animtype-color">color</a></td>
  1640        </tr>
  1641        <tr>
  1642          <td>stop-opacity</td><td>as <a href="#animtype-number">number</a></td>
  1643        </tr>
  1644        <tr>
  1645          <td>fill</td><td>as <a href="#animtype-paintserver">paint server</a></td>
  1646        </tr>
  1647        <tr>
  1648          <td>fill-opacity</td><td>as <a href="#animtype-number">number</a></td>
  1649        </tr>
  1650        <tr>
  1651          <td>stroke</td><td>as <a href="#animtype-paintserver">paint server</a></td>
  1652        </tr>
  1653        <tr>
  1654          <td>stroke-dasharray</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-number">number</a></td>
  1655        </tr>
  1656        <tr>
  1657          <td>stroke-dashoffset</td><td>as <a href="#animtype-number">number</a></td>
  1658        </tr>
  1659        <tr>
  1660          <td>stroke-miterlimit</td><td>as <a href="#animtype-number">number</a></td>
  1661        </tr>
  1662        <tr>
  1663          <td>stroke-opacity</td><td>as <a href="#animtype-number">number</a></td>
  1664        </tr>
  1665        <tr>
  1666          <td>stroke-width</td><td>as <a href="#animtype-number">number</a></td>
  1667        </tr>
  1668        <tr>
  1669          <td>viewport-fill</td><td>as <a href="#animtype-color">color</a></td>
  1670        </tr>
  1671        <tr>
  1672          <td>viewport-fill-opacity</td><td>as <a href="#animtype-color">color</a></td>
  1673        </tr>
  1674       </table> -->
  1676 <h2 id="changes">Changes since Working Draft of 19 November 2013</h2>
  1678 <p>The following are the substantive changes made since the
  1679 <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20131119/">Working Draft
  1680 dated 19 November 2013</a>:</p>
  1682 <ul>
  1683   <li>Values that cannot be interpolated are transitioned when the timing function crosses its midpoint, instead of not running transitions and changing immediately.</li>
  1684   <li>Canceling and interrupting of running transitions is defined much more precisely.  This includes the after-change style no longer including styles from CSS Transitions.</li>
  1685   <li>Completion of transitions is defined somewhat more precisely.</li>
  1686   <li>The transitionend event is no longer cancelable.  This is since it has no default action, so canceling it would have no meaning.  It also matches the animation events.</li>
  1687   <li>The interpolation of ''shadow/inset'' values on shadow lists is no longer backwards.</li>
  1688   <li>A [[#conformance]] section and [[#idl-index]] have been added</li>
  1689   <li>The identifiers accepted by 'transition-property' are defined in terms of <<custom-ident>>.</li>
  1690   <li>Define a little bit more about when changes to computed values happen, by saying at least that implementations must not update the effects of computed values without actually updating computed values.</li>
  1691 </ul>
  1693 <p>For more details on these changes, see the version control <a href="https://hg.csswg.org/drafts/log/tip/css-transitions/Overview.bs">change log since 2015 January 26</a> and the <a href="https://hg.csswg.org/drafts/log/tip/css-transitions/Overview.src.html">change log from 2013 March 28 to 2015 January 26</a>.</p>
  1695 <p>For changes in earlier working drafts:</p>
  1697 <ol>
  1698   <li>see the <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20131119/#changes">changes section in the 19 November 2013 Working Draft</a>
  1699   <li>see the <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20130212/ChangeLog">the ChangeLog</a> for changes in previous working drafts
  1700   <li>For more details on these changes, see the version control change logs, which are split in three parts because of file renaming: <a href="https://hg.csswg.org/drafts/log/tip/css-transitions/Overview.bs">change log since 2015 January 26</a>, <a href="https://hg.csswg.org/drafts/log/tip/css-transitions/Overview.src.html">change log from 2013 March 28 to 2015 January 26</a>, <a href="https://hg.csswg.org/drafts/log/tip/css3-transitions/Overview.src.html">change log before 2013 March 28</a>.
  1701 </ol>
  1703 <h2 id="acknowledgments">Acknowledgments</h2>
  1705 <p>Thanks especially to the feedback from
  1706 Tab Atkins,
  1707 Carine Bournez,
  1708 Aryeh Gregor,
  1709 Vincent Hardy,
  1710 Anne van Kesteren,
  1711 Cameron McCormack,
  1712 Alex Mogilevsky,
  1713 Jasper St. Pierre,
  1714 Estelle Weyl,
  1715 and all the rest of the
  1716 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>

mercurial