8000 csswg-drafts/css3-transitions/Overview.html at 2e65a75ab22b2f14d0d73fcbb5806a48c6fa7241 · xfq/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1649 lines (1214 loc) · 53.3 KB

File metadata and controls

1649 lines (1214 loc) · 53.3 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang=en>
<head>
<title>CSS Transitions</title>
<link href="../default.css" rel=stylesheet type="text/css">
<style type="text/css">
table.animatable-properties {
border-collapse: collapse;
}
table.animatable-properties td {
padding: 0.2em 1em;
border: 1px solid black;
}
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Transitions</h1>
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 22 February
2012</h2>
<dl>
<dt>This version:
<dd> <a href="http://www.w3.org/TR/2012/ED-css3-transitions-20120222/">
http://dev.w3.org/csswg/css3-transitions/</a>
<!--http://www.w3.org/TR/2012/WD-css3-transitions-20120222-->
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-transitions">
http://www.w3.org/TR/css3-transitions/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-transitions/">http://dev.w3.org/csswg/css3-transitions/</a>
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2009/WD-css3-transitions-20090320/">
http://www.w3.org/TR/2009/WD-css3-transitions-20090320/</a>
<dt id=editors-list>Editors:
<dd><a href="mailto:dino@apple.com">Dean Jackson</a> (<a
href="http://www.apple.com/">Apple Inc</a>)
<dd><a href="mailto:hyatt@apple.com">David Hyatt</a> (<a
href="http://www.apple.com/">Apple Inc</a>)
<dd><a href="mailto:cmarrin@apple.com">Chris Marrin</a> (<a
href="http://www.apple.com/">Apple Inc</a>)
<dd class=vcard><a class=fn href="http://dbaron.org/">L. David Baron</a>
(<a class=org href="http://www.mozilla.com/">Mozilla</a>)
<dt>Issues list:
<dd><a
href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&amp;product=CSS&amp;component=Transitions&amp;resolution=---&amp;cmdtype=doit">in
Bugzilla</a>
<dt>Test suite:
<dd>none yet
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> &copy; 2012 <a
href="http://www.w3.org/"><acronym
title="World Wide Web Consortium">W3C</acronym></a><sup>&reg;</sup> (<a
href="http://www.csail.mit.edu/"><acronym
title="Massachusetts Institute of Technology">MIT</acronym></a>, <a
href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>CSS Transitions allows property changes in CSS values to occur smoothly
over a specified duration.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-transitions%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
&#8220;css3-transitions&#8221; in the subject, preferably like this:
&#8220;[<!---->css3-transitions<!---->] <em>&hellip;summary of
comment&hellip;</em>&#8221;
<p>This document was produced by the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a href="/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
W3C Patent Policy</a>.</p>
<!--end-status-->
<p> The <a href=ChangeLog>list of changes made to this specification</a> is
available.
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
<li><a href="#transitions"><span class=secno>2. </span>Transitions</a>
<ul class=toc>
<li><a href="#the-transition-property-property-"><span class=secno>2.1.
</span> The <code class=property>'transition-property'</code> Property
</a>
<li><a href="#the-transition-duration-property-"><span class=secno>2.2.
</span> The <code class=property>'transition-duration'</code> Property
</a>
<li><a href="#transition-timing-function_tag"><span class=secno>2.3.
</span> The <code class=property>'transition-timing-function'</code>
Property </a>
<li><a href="#the-transition-delay-property-"><span class=secno>2.4.
</span> The <code class=property>'transition-delay'</code> Property
</a>
<li><a href="#the-transition-shorthand-property-"><span class=secno>2.5.
</span> The <code class=property>'transition'</code> Shorthand Property
</a>
</ul>
<li><a href="#starting"><span class=secno>3. </span> Starting of
transitions </a>
<li><a href="#reversing"><span class=secno>4. </span> Automatically
reversing transitions </a>
<li><a href="#transition-events-"><span class=secno>5. </span> Transition
Events </a>
<li><a href="#animation-of-property-types-"><span class=secno>6. </span>
Animation of property types </a>
<li><a href="#animatable-properties-"><span class=secno>7. </span>
Animatable properties </a>
<ul class=toc>
<li><a href="#properties-from-css-"><span class=secno>7.1. </span>
Properties from CSS </a>
<li><a href="#properties-from-svg-"><span class=secno>7.2. </span>
Properties from SVG </a>
</ul>
<li><a href="#references"><span class=secno>8. </span>References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references">Normative
references</a>
<li class=no-num><a href="#other-references">Other references</a>
</ul>
<li class=no-num><a href="#property-index">Property index</a>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<h2 id=introduction><span class=secno>1. </span>Introduction</h2>
<p><em>This section is not normative.</em>
<p> 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.
<h2 id=transitions><span class=secno>2. </span>Transitions</h2>
<p> 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.
<p> For example, suppose that transitions of one second have been defined
on the <code class=property>'left'</code> and <code
class=property>'background-color'</code> 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.
<div class=figure> <img alt="" src=transition1.png></div>
<p class=caption> Transitions of <code class=property>'left'</code> and
<code class=property>'background-color'</code>
<p> Transitions are a presentational effect. The computed value of a
property transitions over time from the old value to the new value.
Therefore if a script queries the computed style of a property as it is
transitioning, it will see an intermediate value that represents the
current animated value of the property.
<p> Only animatable CSS properties can be transitioned. See the table at
the end of this document for a list of properties that are animatable.
<p> The transition for a property is defined using a number of new
properties. For example:
<div class=example>
<p style="display:none"> Example(s):</p>
<pre>
div {
transition-property: opacity;
transition-duration: 2s;
}
</pre>
The above example defines a transition on the <code
class=property>'opacity'</code> 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.</div>
<p> 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:
<div class=example>
<p style="display:none"> Example(s):</p>
<pre>
div {
transition-property: opacity, left;
transition-duration: 2s, 4s;
}
</pre>
This will cause the <code class=property>'opacity'</code> property to
transition over a period of two seconds and the left property to
transition over a period of four seconds.</div>
<p> In the case where the list of values in transition properties do not
have the same length, the list is repeated as a whole in order to provide
necessary values.
<p class=issue> Issue: Are the lists repeated to all be the length of the
longest list, or are they repeated or truncated to match the length of the
&lsquo;<a href="#transition-property"><code
class=property>transition-property</code></a>&rsquo; list?
<div class=example>
<p style="display:none"> Example(s):</p>
<pre>
div {
transition-property: opacity, left, top, width;
transition-duration: 2s, 1s;
}
</pre>
The above example defines a transition on the <code
class=property>'opacity'</code> property of 2 seconds duration, a
transition on the <code class=property>'left'</code> property of 1 second
duration, a transition on the <code class=property>'top'</code> property
of 2 seconds duration and a transition on the <code
class=property>'width'</code> property of 1 second duration.</div>
<!-- ======================================================================================================= -->
<h3 id=the-transition-property-property-><span class=secno>2.1. </span> The
<a href="#transition-property"><code
class=property>'transition-property'</code></a> Property</h3>
<p> The <a href="#transition-property"><code
class=property>'transition-property'</code></a> property specifies the
name of the CSS property to which the transition is applied.
<div class=issue> We may ultimately want to support a keypath syntax for
this property. A keypath syntax would enable different transitions to be
specified for components of a property. For example the blur of a shadow
could have a different transition than the color of a shadow.</div>
<table class=propdef>
<tbody>
<tr>
<td> <em>Name:</em>
<td> <dfn id=transition-property>transition-property</dfn>
<tr>
<td> <em>Value:</em>
<td> none | [ all | &lt;IDENT&gt; ] [ &lsquo;<code
class=css>,</code>&rsquo; all | &lt;IDENT&gt; ]*
<tr>
<td> <em>Initial:</em>
<td> all
<tr>
<td> <em>Applies&nbsp;to:</em>
<td> all elements, :before and :after pseudo elements
<tr>
<td> <em>Inherited:</em>
<td> no
<tr>
<td> <em>Percentages:</em>
<td> N/A
<tr>
<td> <em>Media:</em>
<td> visual
<tr>
<td> <em>Computed value:</em>
<td> Same as specified value.
</table>
<p> A value of &lsquo;<code class=property>none</code>&rsquo; means that no
property will transition. Otherwise, a list of properties to be
transitioned, or the keyword &lsquo;<code class=property>all</code>&rsquo;
which indicates that all properties are to be transitioned, is given.
<p> If one of the identifiers listed is not a recognized property name or
is not an animatable property, the implementation must still start
transitions on the animatable properties in the list using the duration,
delay, and timing function at their respective indices in the lists for
&lsquo;<a href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo;, &lsquo;<a
href="#transition-delay"><code
class=property>transition-delay</code></a>&rsquo;, and &lsquo;<a
href="#transition-timing-function"><code
class=property>transition-timing-function</code></a>&rsquo;. In other
words, unrecognized or non-animatable properties must be kept in the list
to preserve the matching of indices.
<p class=issue> Are &lsquo;<code class=property>none</code>&rsquo;,
&lsquo;<code class=property>inherit</code>&rsquo;, and &lsquo;<code
class=property>initial</code>&rsquo; allowed as items in a list of
identifiers (of length greater than one)?
<p> For the keyword &lsquo;<code class=property>all</code>&rsquo;, or if
one of the identifiers listed is a shorthand property, implementations
must start transitions for any of its longhand sub-properties that are
animatable (or, for &lsquo;<code class=property>all</code>&rsquo;, all
animatable properties), using the duration, delay, and timing function at
the index corresponding to the shorthand.
<p> If a property is specified multiple times in the value of &lsquo;<a
href="#transition-property"><code
class=property>transition-property</code></a>&rsquo; (either on its own,
via a shorthand that contains it, or via the &lsquo;<code
class=property>all</code>&rsquo; value), then the transition that starts
uses the duration, delay, and timing function at the index corresponding
to the <em>last</em> item in the value of &lsquo;<a
href="#transition-property"><code
class=property>transition-property</code></a>&rsquo; that calls for
animating that property.
<p class=note> Note: The <code class=property>all</code> value and
shorthand properties work in similar ways, so the <code
class=property>all</code> value is just like a shorthand that covers all
properties.</p>
<!-- ======================================================================================================= -->
<h3 id=the-transition-duration-property-><span class=secno>2.2. </span> The
<a href="#transition-duration"><code
class=property>'transition-duration'</code></a> Property</h3>
<p> The <a href="#transition-duration"><code
class=property>'transition-duration'</code></a> property defines the
length of time that a transition takes.
<table class=propdef>
<tbody>
<tr>
<td> <em>Name:</em>
<td> <dfn id=transition-duration>transition-duration</dfn>
<tr>
<td> <em>Value:</em>
<td> &lt;time&gt; [, &lt;time&gt;]*
<tr>
<td> <em>Initial:</em>
<td> 0s
<tr>
<td> <em>Applies&nbsp;to:</em>
<td> all elements, :before and :after pseudo elements
<tr>
<td> <em>Inherited:</em>
<td> no
<tr>
<td> <em>Percentages:</em>
<td> N/A
<tr>
<td> <em>Media:</em>
<td> interactive
<tr>
<td> <em>Computed value:</em>
<td> Same as specified value.
</table>
<p> This property specifies how long the transition from the old value to
the new value should take. By default the value is &lsquo;<code
class=css>0s</code>&rsquo;, meaning that the transition is immediate (i.e.
there will be no animation). A negative value for <a
href="#transition-duration"><code
class=property>transition-duration</code></a> is treated as &lsquo;<code
class=css>0s</code>&rsquo;.</p>
<!-- =======================================================================================================
-->
<h3 id="transition-timing-function_tag"><span class=secno>2.3. </span> The
<a href="#transition-timing-function"><code
class=property>'transition-timing-function'</code></a> Property</h3>
<p> The <a href="#transition-timing-function"><code
class=property>'transition-timing-function'</code></a> property describes
how the intermediate values used during a transition will be calculated.
It allows for a transition to change speed over its duration. These
effects are commonly called <em>easing</em> functions. In either case, a
mathematical function that provides a smooth curve is used.
<p> Timing functions are either defined as a stepping function or a <a
href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
B&eacute;zier curve</a>. The timing function takes as its input the
current elapsed percentage of the transition duration and outputs a
percentage that determines how close the transition is to its goal state.
<p> A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a>
function is defined by a number that divides the domain of operation into
equally sized intervals. Each subsequent interval is a equal step closer
to the goal state. The function also specifies whether the change in
output percentage happens at the start or end of the interval (in other
words, if 0% on the input percentage is the point of initial change).
<div class=figure> <img
alt="The step timing function splits the function domain into a number of disjoint straight line segments. steps(1, start) is a function whose output value is 1 for all input values. steps(1, end) is a function whose output value is 0 for all input values less than 1, and output is 1 for the input value of 1. steps(3, start) is a function that divides the input domain into three segments, each 1/3 in length, and 1/3 above the previous segment, with the first segment starting at 1/3. steps(3, end) is a function that divides the input domain into three segments, each 1/3 in length, and 1/3 above the previous segment, with the first segment starting at 0."
src=step.png></div>
<p class=caption> Step timing functions
<p> A <a
href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
B&eacute;zier curve</a> is defined by four control points, P<sub>0</sub>
through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub> are
always set to (0,0) and (1,1). The <a
href="#transition-timing-function"><code
class=property>'transition-timing-function'</code></a> property is used to
specify the values for points P<sub>1</sub> and P<sub>2</sub>. These can
be set to preset values using the keywords listed below, or can be set to
specific values using the <code class=css>'cubic-bezier'</code> function.
In the <code class=css>'cubic-bezier'</code> function, P<sub>1</sub> and
P<sub>2</sub> are each specified by both an X and Y value.
<div class=figure> <img
alt="The B&eacute;zier timing function is a smooth curve from point P0 = (0,0) to point P3 = (1,1). The length and orientation of the line segment P0-P1 determines the tangent and the curvature of the curve at P0 and the line segment P2-P3 does the same at P3."
src=TimingFunction.png></div>
<p class=caption> B&eacute;zier Timing Function Control Points
<table class=propdef>
<tbody>
<tr>
<td> <em>Name:</em>
<td> <dfn id=transition-timing-function>transition-timing-function</dfn>
<tr>
<td> <em>Value:</em>
<td> ease | linear | ease-in | ease-out | ease-in-out | step-start |
step-end | steps(&lt;integer&gt;[, start | end ]) |
cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
&lt;number&gt;) [, ease | linear | ease-in | ease-out | ease-in-out |
step-start | step-end | steps(&lt;number&gt;[, start | end ]) |
cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;,
&lt;number&gt;)]*
<tr>
<td> <em>Initial:</em>
<td> ease
<tr>
<td> <em>Applies&nbsp;to:</em>
<td> all elements, :before and :after pseudo elements
<tr>
<td> <em>Inherited:</em>
<td> no
<tr>
<td> <em>Percentages:</em>
<td> N/A
<tr>
<td> <em>Media:</em>
<td> interactive
<tr>
<td> <em>Computed value:</em>
<td> Same as specified value.
</table>
<p> The timing functions have the following definitions.
<dl>
<dt> ease
<dd> The ease function is equivalent to cubic-bezier(0.25, 0.1, 0.25,
1.0).
<dt> linear
<dd> The linear function is equivalent to cubic-bezier(0.0, 0.0, 1.0,
1.0).
<dt> ease-in
<dd> The ease-in function is equivalent to cubic-bezier(0.42, 0, 1.0,
1.0).
<dt> ease-out
<dd> The ease-out function is equivalent to cubic-bezier(0, 0, 0.58, 1.0).
<dt> ease-in-out
<dd> The ease-in-out function is equivalent to cubic-bezier(0.42, 0, 0.58,
1.0)
<dt> step-start
<dd> The step-start function is equivalent to steps(1, start).
<dt> step-end
<dd> The step-end function is equivalent to steps(1, end).
<dt> steps
<dd> Specifies a stepping function, described above, taking two
parameters. The first parameter specifies the number of intervals in the
function. It must be a positive integer (greater than 0). The second
parameter, which is optional, is either the value &lsquo;<code
class=property>start</code>&rsquo; or &lsquo;<code
class=property>end</code>&rsquo;, and specifies the point at which the
change of values occur within the interval. If the second parameter is
omitted, it is given the value &lsquo;<code
class=property>end</code>&rsquo;.
<dt> cubic-bezier
<dd> Specifies a <a
href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier
curve</a>. The four values specify points P<sub>1</sub> and P<sub>2</sub>
of the curve as (x1, y1, x2, y2). Both x values must be in the range [0,
1] or the definition is invalid. The y values can exceed this range.
</dl>
<!-- ======================================================================================================= -->
<h3 id=the-transition-delay-property-><span class=secno>2.4. </span> The <a
href="#transition-delay"><code
class=property>'transition-delay'</code></a> Property</h3>
<p> The <a href="#transition-delay"><code
class=property>'transition-delay'</code></a> 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 <a
href="#transition-delay"><code
class=property>'transition-delay'</code></a> value of &lsquo;<code
class=css>0s</code>&rsquo; 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.
<p> If the value for <a href="#transition-delay"><code
class=property>'transition-delay'</code></a> 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 <a
href="#transition-delay"><code
class=property>'transition-delay'</code></a>, the starting values are
taken from the moment the property is changed.
<table class=propdef>
<tbody>
<tr>
<td> <em>Name:</em>
<td> <dfn id=transition-delay>transition-delay</dfn>
<tr>
<td> <em>Value:</em>
<td> &lt;time&gt; [, &lt;time&gt;]*
<tr>
<td> <em>Initial:</em>
<td> 0s
<tr>
<td> <em>Applies&nbsp;to:</em>
<td> all elements, :before and :after pseudo elements
<tr>
<td> <em>Inherited:</em>
<td> no
<tr>
<td> <em>Percentages:</em>
<td> N/A
<tr>
<td> <em>Media:</em>
<td> interactive
<tr>
<td> <em>Computed value:</em>
<td> Same as specified value.
</table>
<!-- ======================================================================================================= -->
<h3 id=the-transition-shorthand-property-><span class=secno>2.5. </span>
The <a href="#transition"><code class=property>'transition'</code></a>
Shorthand Property</h3>
<p> The <a href="#transition"><code class=property>'transition'</code></a>
shorthand property combines the four properties described above into a
single property.
<p> Note that order is important in this property. The first value that can
be parsed as a time is assigned to the transition-duration. The second
value that can be parsed as a time is assigned to transition-delay.
<p class=issue> An alternative proposal is to accept the font shorthand
approach of using a "/" character between the values of the same type.
e.g. 2s/4s would mean a duration of 2 seconds and a delay of 4 seconds.
<table class=propdef>
<tbody>
<tr>
<td> <em>Name:</em>
<td> <dfn id=transition>transition</dfn>
<tr>
<td> <em>Value:</em>
<td> [&lt;&lsquo;<a href="#transition-property"><code
class=property>transition-property</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-timing-function"><code
class=property>transition-timing-function</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-delay"><code
class=property>transition-delay</code></a>&rsquo;&gt; [, [&lt;&lsquo;<a
href="#transition-property"><code
class=property>transition-property</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-timing-function"><code
class=property>transition-timing-function</code></a>&rsquo;&gt; ||
&lt;&lsquo;<a href="#transition-delay"><code
67F6 class=property>transition-delay</code></a>&rsquo;&gt;]]*
<tr>
<td> <em>Initial:</em>
<td> see individual properties
<tr>
<td> <em>Applies&nbsp;to:</em>
<td> all elements, :before and :after pseudo elements
<tr>
<td> <em>Inherited:</em>
<td> no
<tr>
<td> <em>Percentages:</em>
<td> N/A
<tr>
<td> <em>Media:</em>
<td> interactive
<tr>
<td> <em>Computed value:</em>
<td> Same as specified value.
</table>
<h2 id=starting><span class=secno>3. </span> Starting of transitions</h2>
<p> When the computed value of an animatable property changes,
implementations must decide what transitions to start based on the values
of the &lsquo;<a href="#transition-property"><code
class=property>transition-property</code></a>&rsquo;, &lsquo;<a
href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo;, &lsquo;<a
href="#transition-timing-function"><code
class=property>transition-timing-function</code></a>&rsquo;, and &lsquo;<a
href="#transition-delay"><code
class=property>transition-delay</code></a>&rsquo; properties at the time
the animatable property would first have its new computed value.
<div class=example>
<p style="display:none"> Example(s):</p>
<pre>li { transition: background-color linear 1s; background: blue; }
li:hover { transition-duration: 2s; background-color: green; }</pre>
<p> When a list item with these style rules enters the :hover state, the
computed &lsquo;<a href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo; at the time that
&lsquo;<code class=property>background-color</code>&rsquo; would have its
new value (&lsquo;<code class=property>green</code>&rsquo;) is
&lsquo;<code class=css>2s</code>&rsquo;, so the transition from
&lsquo;<code class=property>blue</code>&rsquo; to &lsquo;<code
class=property>green</code>&rsquo; takes 2 seconds. However, when the
list item leaves the :hover state, the transition from &lsquo;<code
class=property>green</code>&rsquo; to &lsquo;<code
class=property>blue</code>&rsquo; takes 1 second.</p>
</div>
<p> Since this specification does not define when computed values change,
and thus what changes to computed values are considered simultaneous,
authors should be aware that changing any of the transition properties a
small amount of time after making a change that might transition can
result in behavior that varies between implementations, since the changes
might be considered simultaneous in some implementations but not others.
<p class=note>Say something about simultaneity
<p> Once the transition of a property has started, it must continue running
based on the original timing function, duration, and delay, even if the
&lsquo;<a href="#transition-timing-function"><code
class=property>transition-timing-function</code></a>&rsquo;, &lsquo;<a
href="#transition-duration"><code
class=property>transition-duration</code></a>&rsquo;, or &lsquo;<a
href="#transition-delay"><code
class=property>transition-delay</code></a>&rsquo; property changes before
the transition is complete. However, if the &lsquo;<a
href="#transition-property"><code
class=property>transition-property</code></a>&rsquo; property changes such
that the transition would not have started, the transition must stop (and
the property must immediately change to its final value).
<p> Implementations must not start a transition when the computed value of
a property changes as a result of declarative animation (as opposed to
scripted animation).
<p> Implementations also must not start a transition when the computed
value changes because it is inherited (directly or indirectly) from
another element that is transitioning the same property.
<h2 id=reversing><span class=secno>4. </span> Automatically reversing
transitions</h2>
<p> A common type of transition effect is when a running transition is
interrupted and the property is reset to its original value. An example is
a hover effect on an element, where the pointer enters and exits the
element before the effect has completed. If the outgoing and incoming
transitions are executed using their specified durations and timing
functions, the resulting effect can be distractingly asymmetric. Instead,
the expected behavior is that the new transition should be the reverse of
what has already executed.
<p> If a running transition with duration T, executing so far for duration
TE, from state A, to state B, is interrupted by a property change that
would start a new transition back to state A, and all the transition
attributes are the same (duration, delay and timing function), then the
new transition must reverse the effect. The new transition must:
<ol>
<li> Use the B and A states as its "from" and "to" states respectively. It
does not use the current value as its from state, due to the rules below.
<li> Execute with the same duration T, but starting as if the transition
had already begun, without any transition delay, at the moment which
would cause the new transition to finish in TE from the moment of
interruption. In other words, the new transition will execute as if it
started T-TE in the past.
<li> Use a timing function that is the portion of the curve traversed up
to the moment of interruption, followed in the opposite direction
(towards the starting point). This will make the transition appear as if
it is playing backwards.
<li> Ignore any transition delay.
</ol>
<p> For example, suppose there is a transition with a duration of two
seconds. If this transition is interrupted after 0.5 seconds and the
property value assigned to the original value, then the new transition
effect will be the reverse of the original, as if it had begun 1.5 seconds
in the past.
<p> Note that by using the defined from and to states for the reversing
transition, it is also possible that it may reverse again, if interrupted;
for example, if the transition reversing to state A was again interrupted
by a property change to state B.
<p class=issue>Issue: This introduces the concept of reversing a timing
function, which the spec has otherwise resisted doing, and also introduces
a discontinuity between transitions that have almost completed (which get
automatically reversed and thus have their timing function reversed) and
transitions that have fully completed (where the reversal doesn't lead to
the timing function being reversed). An alternative proposal that avoids
this is to follow the normal timing function algorithm, except multiply
the duration (and also shorten any negative delay) by the (output) value
of the transition timing function of the incomplete transition at the time
it was interrupted, and, to account for multiple reverses in sequence, to
divide by the shortening applied to the transition being interrupted. For
more details see this thread: <a
href="http://lists.w3.org/Archives/Public/www-style/2009Nov/thread.html#msg302">November
2009 part</a>, <a
href="http://lists.w3.org/Archives/Public/www-style/2009Dec/thread.html#msg319">December
2009 part</a>, <a
href="http://lists.w3.org/Archives/Public/www-style/2010Jan/thread.html#msg136">January
2010 part</a>.
<h2 id=transition-events-><span class=secno>5. </span> Transition Events</h2>
<p> 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>.
An event is fired for each property that undergoes a transition. This
allows a content developer to perform actions that synchronize with the
completion of a transition.
<p> Each event provides the name of the property the transition is
associated with as well as the duration of the transition.
<dl>
<dt> <b>Interface <i><a id=Events-TransitionEvent
name=Events-TransitionEvent>TransitionEvent</a></i></b>
<dd>
<p> The <code>TransitionEvent</code> interface provides specific
contextual information associated with transitions.</p>
<dl>
<dt> <b>IDL Definition</b>
<dd>
<div class=idl-code>
<pre>
interface TransitionEvent : Event {
readonly attribute DOMString propertyName;
readonly attribute float elapsedTime;
void initTransitionEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in DOMString propertyNameArg,
in float elapsedTimeArg);
};
</pre>
</div>
<dt> <b>Attributes</b>
<dd>
<dl>
<dt> <code class=attribute-name><a
id=Events-TransitionEvent-propertyName
name=Events-TransitionEvent-propertyName>propertyName</a></code> of
type <code>DOMString</code>, readonly
<dd> The name of the CSS property associated with the transition.
</dl>
<dl>
<dt> <code class=attribute-name><a
id=Events-TransitionEvent-elapsedTime
name=Events-TransitionEvent-elapsedTime>elapsedTime</a></code> of
type <code>float</code>, readonly
<dd> 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 <a href="#transition-delay"><code
class=property>transition-delay</code></a>.
</dl>
<dt> <b>Methods</b>
<dd>
<dl>
<dt> <code class=method-name><a
id=Events-TransitionEvent-initTransitionEvent
name=Events-TransitionEvent-initTransitionEvent>initTransitionEvent</a></code>
<dd>
<div class=method> The <code>initTransitionEvent</code> method is
used to initialize the value of a <code>TransitionEvent</code>
created through the <a
href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent"><code>DocumentEvent</code></a>
interface. This method may only be called before the
<code>TransitionEvent</code> has been dispatched via the
<code>dispatchEvent</code> method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
<div class=parameters> <b>Parameters</b>
<div class=paramtable>
<dl>
<dt> <code class=parameter-name>typeArg</code> of type
<code>DOMString</code>
<dd> Specifies the event type.<br>
<dt> <code class=parameter-name>ca 39BE nBubbleArg</code> of type
<code>boolean</code>
<dd> Specifies whether or not the event can bubble.<br>
<dt> <code class=parameter-name>cancelableArg</code> of type
<code>boolean</code>
<dd> Specifies whether or not the event's default action can be
prevented. Since a TransitionEvent is purely for notification,
there is no default action.<br>