Sun, 31 Jan 2016 16:19:13 -0800
change w3.org/TR/ urls to https
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: https://drafts.csswg.org/css-transitions/
19 Shortname: css-transitions
20 Group: csswg
21 Level: 1
22 TR: https://www.w3.org/TR/css3-transitions/
23 Previous version: https://www.w3.org/TR/2013/WD-css3-transitions-20131119/
24 ED: https://drafts.csswg.org/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&product=CSS&component=Transitions&resolution=---&status_whiteboard=defer%20to%20level%202&status_whiteboard_type=notregexp
30 Issue Tracking: Bugzilla bugs for all levels https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transitions&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: https://drafts.csswg.org/css-backgrounds-3/#shadow-inset; type: value; for: shadow; text: inset;
92 url: https://www.w3.org/TR/CSS21/visufx.html#propdef-visibility; type: value; for: visibility; text: visible;
93 urlPrefix: https://drafts.csswg.org/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="https://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"><single-transition-property></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é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é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é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é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"><single-transition-timing-function></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"><single-transition></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 “forward”
944 and “reverse” transitions,
945 when the transitions are between two states
946 (but see <a
947 href="#reversing">below</a> for special reversing behavior when
948 an <em>incomplete</em> transition is interrupted). Authors can
949 specify the value of 'transition-duration',
950 'transition-timing-function', or 'transition-delay' in the same
951 rule where they specify the value that triggers the transition,
952 or can change these properties at the same time as they change
953 the property that triggers the transition. Since it's the new
954 values of these 'transition-*' properties that affect the
955 transition, these values will be used for the transitions
956 <em>to</em> the associated transitioning values. For example:
957 </p>
958 <pre>
959 li {
960 transition: background-color linear 1s;
961 background: blue;
962 }
963 li:hover {
964 background-color: green;
965 transition-duration: 2s; /* applies to the transition *to* the :hover state */
966 }</pre>
967 <p>
968 When a list item with these style rules enters the :hover
969 state, the computed 'transition-duration' at the time that
970 'background-color' would have its new value (''green'') is ''2s'',
971 so the transition from ''blue'' to ''green'' takes 2 seconds.
972 However, when the list item leaves the :hover state, the
973 transition from ''green'' to ''blue'' takes 1 second.
974 </p>
975 </div>
976 </div>
978 <p class="note">
979 Note that once the transition of a property has started
980 (including being in its delay phase),
981 it continues running based on
982 the original timing function, duration, and
983 delay, even if the 'transition-timing-function',
984 'transition-duration', or 'transition-delay' property changes
985 before the transition is complete. However, if the
986 'transition-property' property changes such that the transition
987 would not have started, the transition stops (and the
988 property immediately changes to its final value).
989 </p>
991 <p class="note">
992 Note that above rules mean that
993 transitions do not start when the computed
994 value of a property changes as a result of declarative animation
995 (as opposed to scripted animation).
996 This happens because the before-change style includes up-to-date
997 style for declarative animations.
998 </p>
1000 <h3 id="reversing">
1001 Faster reversing of interrupted transitions
1002 </h3>
1003 <div class="note">
1005 <p>
1006 Many common transitions effects involve transitions between two states,
1007 such as the transition that occurs when the mouse pointer moves
1008 over a user interface element, and then later moves out of that element.
1009 With these effects, it is common for a running transition
1010 to be interrupted before it completes,
1011 and the property reset to the starting value of that transition.
1012 An example is a hover effect on an element,
1013 where a transition starts when the pointer enters the element,
1014 and then the pointer exits the element before the effect has completed.
1015 If the outgoing and incoming transitions
1016 are executed using their specified durations and timing functions,
1017 the resulting effect can be distractingly asymmetric
1018 because the second transition
1019 takes the full specified time to move a shortened distance.
1020 Instead, this specification makes second transition shorter.
1021 </p>
1023 <p>
1024 The mechanism the above rules use to cause this involves the
1025 <a>reversing shortening factor</a> and the
1026 <a>reversing-adjusted start value</a>.
1027 In particular, the reversing behavior is present whenever
1028 the <a>reversing shortening factor</a> is less than 1.
1029 </p>
1031 <p class="note">
1032 Note that these rules do not fully address the problem for
1033 transition patterns that involve more than two states.
1034 </p>
1036 <p class="note">
1037 Note that these rules lead to the entire timing function of the
1038 new transition being used, rather than jumping into the middle
1039 of a timing function, which can create a jarring effect.
1040 </p>
1042 <p class="note">
1043 This was one of several possibilities that was considered by the
1044 working group. See the
1045 <a href="transition-reversing-demo">reversing demo</a>
1046 demonstrating a number of them, leading to a working group
1047 resolution made on 2013-06-07 and edits made on 2013-11-11.
1048 </p>
1050 </div>
1052 <h2 id="application">
1053 Application of transitions
1054 </h2>
1056 <p>
1057 When a property on an element is undergoing a transition
1058 (that is, when or after the transition has started and before the
1059 <a>end time</a> of the transition)
1060 the transition adds a style called the <dfn export>current value</dfn>
1061 to the CSS cascade
1062 at the level defined for CSS Transitions in [[!CSS3CASCADE]].
1063 </p>
1065 <p class="note">
1066 Note that this means that computed values
1067 resulting from CSS transitions
1068 can inherit to descendants just like
1069 any other computed values.
1070 In the normal case, this means that
1071 a transition of an inherited property
1072 applies to descendant elements
1073 just as an author would expect.
1074 </p>
1076 <p>
1077 Implementations must add this value to the cascade
1078 if and only if
1079 that property is not currently
1080 undergoing a CSS Animation ([[!CSS3-ANIMATIONS]]) on the same element.
1081 </p>
1083 <p class="note">
1084 Note that this behavior of transitions not applying to the cascade
1085 when an animation on the same element and property is running
1086 does not affect whether the transition has started or ended.
1087 APIs that detect whether transitions are running
1088 (such as <a href="#transition-events">transition events</a>)
1089 still report that a transition is running.
1090 </p>
1092 <p>
1093 If the current time is at or before the
1094 <a>start time</a> of the transition
1095 (that is, during the delay phase of the transition),
1096 the <a>current value</a> is a specified style that will compute
1097 to the <a>start value</a> of the transition.
1098 </p>
1100 <p>
1101 If the current time is after the
1102 <a>start time</a> of the transition
1103 (that is, during the duration phase of the transition),
1104 the <a>current value</a> is a specified style that will compute
1105 to the <a href="#animatable-types">result of interpolating the property</a>
1106 using the <a>start value</a> of the transition as
1107 <var>V</var><sub>start</sub>,
1108 using the <a>end value</a> of the transition as
1109 <var>V</var><sub>end</sub>,
1110 and using (current time - start time) / (end time - start time)
1111 as the input to the timing function.
1112 </p>
1114 <h2 id="complete">Completion of transitions</h2>
1116 <p>
1117 <a>Running transitions</a>
1118 <dfn export for="transition" id="dfn-complete">complete</dfn>
1119 at a time that equal to or after their end time,
1120 but prior to to the first <a>style change event</a>
1121 whose time is equal to or after their <a>end time</a>.
1122 When a transition completes,
1123 implementations must move
1124 all transitions that complete at that time
1125 from the set of <a>running transitions</a>
1126 to the set of <a>completed transitions</a>
1127 and then fire the <a href="#transition-events">events</a>
1128 for those completions.
1129 <span class="note">(Note that doing otherwise, that is,
1130 firing some of the events before doing all of the moving
1131 from <a>running transitions</a> to <a>completed transitions</a>,
1132 could allow
1133 a style change event to happen
1134 without the necessary transitions completing,
1135 since firing the event could cause a style change event,
1136 if an event handler requests up-to-date computed style or
1137 layout data.)</span>
1138 </p>
1140 <h2 id="transition-events"><span id="transition-events-">
1141 Transition Events
1142 </span></h2>
1143 <p>
1144 The completion of a CSS Transition generates a corresponding <a href="https://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM Event</a>.
1145 An event is <a>dispatched</a> to the element
1146 for each property that undergoes a transition on that element.
1147 This allows a content developer to perform actions that synchronize
1148 with the completion of a transition.
1149 </p>
1150 <p>
1151 Each event provides the name of the property the transition is
1152 associated with as well as the duration of the transition.
1153 </p>
1154 <dl>
1155 <dt>
1156 <b>Interface <dfn interface id="Events-TransitionEvent">TransitionEvent</dfn></b>
1157 </dt>
1158 <dd>
1159 <p>
1160 The {{TransitionEvent}} interface provides specific contextual information associated with transitions.
1161 </p>
1162 <dl>
1163 <dt>
1164 <b>IDL Definition</b>
1165 </dt>
1166 <dd>
1167 <div class='idl-code'>
1168 <pre class='idl'>
1169 [Constructor(DOMString type, optional TransitionEventInit transitionEventInitDict)]
1170 interface TransitionEvent : Event {
1171 readonly attribute DOMString propertyName;
1172 readonly attribute float elapsedTime;
1173 readonly attribute DOMString pseudoElement;
1174 };
1176 dictionary TransitionEventInit : EventInit {
1177 DOMString propertyName = "";
1178 float elapsedTime = 0.0;
1179 DOMString pseudoElement = "";
1180 };
1181 </pre>
1182 </div>
1183 </dd>
1184 <dt>
1185 <b>Attributes</b>
1186 </dt>
1187 <dd>
1188 <dl>
1189 <dt>
1190 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-propertyName">propertyName</dfn></code> of type <code>DOMString</code>, readonly
1191 </dt>
1192 <dd>
1193 The name of the CSS property associated with the transition.
1194 </dd>
1195 </dl>
1196 <dl>
1197 <dt>
1198 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-elapsedTime">elapsedTime</dfn></code> of type <code>float</code>, readonly
1199 </dt>
1200 <dd>
1201 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>.
1202 </dd>
1203 </dl>
1204 <dl>
1205 <dt>
1206 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-pseudoElement">pseudoElement</dfn></code> of type <code>DOMString</code>, readonly
1207 </dt>
1208 <dd>
1209 The name (beginning with two colons) of the CSS
1210 pseudo-element on which the transition occurred (in
1211 which case the target of the event is that
1212 pseudo-element's corresponding element), or the empty
1213 string if the transition occurred on an element (which
1214 means the target of the event is that element).
1215 </dd>
1216 </dl>
1217 </dd>
1218 </dl>
1219 <p>
1220 <code id="TransitionEvent-constructor">TransitionEvent(type, transitionEventInitDict)</code>
1221 is an <a>event constructor</a>.
1222 </p>
1223 </dd>
1224 </dl>
1225 <p>
1226 There is one type of transition event available.
1227 </p>
1228 <dl>
1229 <dt>
1230 <b><dfn event for="Element" id="transitionend">transitionend</dfn></b>
1231 </dt>
1232 <dd>
1233 The {{transitionend}} event occurs at the completion of the transition. In the
1234 case where a transition is removed before completion, such as if the
1235 transition-property is removed, then the event will not fire.
1236 <ul>
1237 <li>Bubbles: Yes
1238 </li>
1239 <li>Cancelable: No
1240 </li>
1241 <li>Context Info: propertyName, elapsedTime, pseudoElement
1242 </li>
1243 </ul>
1244 </dd>
1245 </dl>
1247 <h2 id="animatable-types"><span id="animation-of-property-types-">
1248 Animation of property types
1249 </span></h2>
1251 <p>
1252 Some property types can be interpolated,
1253 which means they can animate smoothly from one value to another.
1254 Other property types cannot, and thus animate only in a single
1255 step from one value to the other.
1256 </p>
1258 <h3 id="interpolated-types">Animation of interpolated property types</h3>
1260 <p>
1261 When interpolating between two values,
1262 <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
1263 interpolation is done using the output <var>p</var> of the timing function,
1264 which gives the portion of the value space
1265 that the interpolation has crossed.
1266 Thus the result of the interpolation is
1267 <var>V</var><sub>res</sub> =
1268 (1 - <var>p</var>) ⋅ <var>V</var><sub>start</sub> +
1269 <var>p</var> ⋅ <var>V</var><sub>end</sub>.
1270 </p>
1272 <p>
1273 However, if this value (<var>V</var><sub>res</sub>)
1274 is outside the allowed range of values for the property,
1275 then it is clamped to that range.
1276 This can occur if <var>p</var> is outside of the range 0 to 1,
1277 which can occur if a timing function is specified
1278 with a <var>y1</var> or <var>y2</var> that is outside the range 0 to 1.
1279 </p>
1281 <p>
1282 The following describes how each property type undergoes transition or
1283 animation.
1284 </p>
1286 <ul>
1287 <li id="animtype-color">
1288 <strong>color</strong>: interpolated via red, green, blue and alpha
1289 components (treating each as a number, see below).
1290 The interpolation is done between premultiplied colors
1291 (that is, colors for which the red, green, and blue components
1292 specified have been multiplied by the alpha).
1293 </li>
1294 <li id="animtype-length">
1295 <strong>length</strong>: interpolated as real numbers.
1296 </li>
1297 <li id="animtype-percentage">
1298 <strong>percentage</strong>: interpolated as real numbers.
1299 </li>
1300 <li id="animtype-lpcalc">
1301 <strong>length, percentage, or calc</strong>: when both values
1302 are lengths, interpolated as lengths; when both values are
1303 percentages, interpolated as percentages; otherwise, both
1304 values are converted into a ''calc()'' function that is the
1305 sum of a length and a percentage (each possibly zero), and
1306 these ''calc()'' functions have each half interpolated as real
1307 numbers.
1308 </li>
1309 <li id="animtype-integer">
1310 <strong>integer</strong>: interpolated via discrete steps (whole
1311 numbers). The interpolation happens in real number space and is
1312 converted to an integer by rounding to the nearest integer, with
1313 values halfway between a pair of integers rounded towards
1314 positive infinity.
1315 </li>
1316 <li id="animtype-font-weight">
1317 <strong>font weight</strong>: interpolated via discrete steps
1318 (multiples of 100). The interpolation happens in real number
1319 space and is converted to an integer by rounding to the
1320 nearest multiple of 100, with values halfway between multiples
1321 of 100 rounded towards positive infinity.
1322 </li>
1323 <li id="animtype-number">
1324 <strong>number</strong>: interpolated as real (floating point)
1325 numbers.
1326 </li>
1327 <li id="animtype-rect">
1328 <strong>rectangle</strong>: interpolated via the x, y,
1329 width and height components (treating each as a number).
1330 </li>
1331 <li id="animtype-visibility">
1332 <strong>visibility</strong>: if one of the values is
1333 ''visibility/visible'', interpolated as a discrete step where values of the
1334 timing function between 0 and 1 map to ''visibility/visible'' and other
1335 values of the timing function (which occur only at the
1336 start/end of the transition or as a result of ''cubic-bezier()''
1337 functions with Y values outside of [0, 1]) map to the closer
1338 endpoint; if neither value is ''visibility/visible'' then not interpolable.
1339 </li>
1340 <li id="animtype-shadow-list">
1341 <strong>shadow list</strong>: Each shadow in the list
1342 (treating ''shadow/none'' as a 0-length list)
1343 is interpolated via the
1344 color (as <a href="#animtype-color">color</a>) component,
1345 and x, y, blur, and (when appropriate) spread
1346 (as <a href="#animtype-length">length</a>) components.
1347 For each shadow, if both input shadows are ''shadow/inset''
1348 or both input shadows are not ''shadow/inset'',
1349 then the interpolated shadow must match the input shadows in that regard.
1350 If any pair of input shadows has one ''shadow/inset'' and the other not ''shadow/inset'',
1351 the entire <a href="#animtype-shadow-list">shadow-list</a> is uninterpolable.
1352 If the lists of shadows have different lengths,
1353 then the shorter list is padded at the end
1354 with shadows whose color is ''transparent'',
1355 all lengths are ''0'',
1356 and whose ''shadow/inset'' (or not) matches the longer list.
1357 </li>
1358 <li id="animtype-gradient">
1359 <strong>gradient</strong>: interpolated via the
1360 positions and colors of each stop. They must have the same type
1361 (radial or linear) and same number of stops in order to be animated.
1362 <span class="note">Note: [[CSS3-IMAGES]] may extend this
1363 definition.</span>
1364 </li>
1365 <li id="animtype-paintserver">
1366 <strong>paint server</strong> (SVG): interpolation is only supported
1367 between: gradient to gradient and color to color. They then
1368 work as above.
1369 </li>
1370 <li id="animtype-simple-list">
1371 <strong>simple list</strong> of other types:
1372 If the lists have the same number of items,
1373 and each pair of values can be interpolated,
1374 each item in the list is interpolated using
1375 the rules given for those types.
1376 Otherwise the values are not interpolable.
1377 </li>
1378 <li id="animtype-repeatable-list">
1379 <strong>repeatable list</strong> of other types:
1380 The result list has a length that is the least common multiple
1381 of the lengths of the input lists.
1382 Each item in the result is the interpolation of the value
1383 from each input list repeated to the length of the result list.
1384 If a pair of values cannot be interpolated, then the lists
1385 are not interpolable.
1386 <span class="note">
1387 The repeatable list concept ensures that a list that is
1388 conceptually repeated to a certain length (as
1389 'background-origin' is repeated to the length of the
1390 'background-image' list) or repeated infinitely will
1391 smoothly transition between any values, and so that the
1392 computed value will properly represent the result (and
1393 potentially be inherited correctly).
1394 </span>
1395 </li>
1396 </ul>
1398 <p>Future specifications may define additional types that can
1399 be animated.</p>
1401 <p>See the definition of 'transition-property' for how animation
1402 of shorthand properties and the ''all'' value is applied to any
1403 properties (in the shorthand) that can be animated.</p>
1405 <h3 id="step-types">Animation in steps of other property types</h3>
1407 <p>
1408 When interpolating between two values that cannot be interpolated,
1409 <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
1410 interpolation is done using the output <var>p</var> of the timing function.
1411 If <var>p</var> is less than 0.5, then the
1412 result of the interpolation is
1413 <var>V</var><sub>start</sub>;
1414 if <var>p</var> is greater than or equal to 0.5, then the
1415 result of the interpolation is
1416 <var>V</var><sub>end</sub>.
1417 </p>
1419 <p class="note" id="discrete-interpolation-at-risk">
1420 This is a recent change to which implementations have
1421 not yet updated. (Prior to the change CSS Transitions
1422 and CSS Animations did not run on such changes.) It's
1423 possible that it won't be compatible with existing Web content.
1424 If that is the case, the problem may be mitigated by restricting
1425 this behavior only to CSS Animations (and not to CSS Transitions),
1426 and/or restricting it to step timing functions.
1427 </p>
1429 <h2 id="animatable-properties"><span id="animatable-properties-">
1430 Animatable properties
1431 </span></h2>
1433 <!--
1434 As resolved in
1435 http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html
1436 -->
1438 <p>The definition of each CSS property defines
1439 when the values of that property can be interpolated
1440 by referring to the definitions of property types
1441 in the <a href="#animatable-types">previous section</a>.
1442 The animated value is interpolated from the from and to values when
1443 both the from and the to values of the property have the type described.
1444 (When a composite type such as "length, percentage, or calc" is listed,
1445 this means that both values must fit into that composite type.)
1446 When multiple types are listed in the form "either A or B",
1447 both values must be of the same type to be interpolable.</p>
1449 <p>Otherwise, since the from and to values cannot be interpolated,
1450 the animation is done <a href="#step-types">in a single step</a>.</p>
1452 <p>The 'transition-*' properties defined in this specification do
1453 not undergo transitions.</p>
1455 <p>For properties that exist at the time this specification was
1456 developed, this specification defines how they are
1457 animated. However, future CSS specifications may define
1458 additional properties, additional values for existing properties,
1459 or additional animation behavior of existing values. In order to
1460 describe new animation behaviors and to have the definition of
1461 animation behavior in a more appropriate location, future CSS
1462 specifications should include an "Animatable:" line in the summary
1463 of the property's definition (in addition to the other lines
1464 described in [[CSS21]], <a
1465 href="https://www.w3.org/TR/CSS21/about.html#property-defs">section
1466 1.4.2</a>). This line should say "no" to indicate that a property
1467 cannot be animated or should reference an animation behavior
1468 (which may be one of the behaviors in the <a
1469 href="#animation-of-property-types-">Animation of property
1470 types</a> section above, or may be a new behavior) to define how
1471 the property animates. Such definitions override those given in
1472 this specification.</p>
1474 <p class="issue">
1475 It no longer makes sense for this line to be called
1476 "Animatable". It should probably be renamed to "Interpolation",
1477 and the "no" value renamed to "discrete" or "in steps".
1478 </p>
1480 <h3 id="animatable-css"><span id="properties-from-css-">
1481 Properties from CSS
1482 </span></h3>
1484 <p>
1485 The following definitions define the animation behavior for
1486 properties in CSS Level 2 Revision 1 ([[CSS21]]) and in Level 3 of
1487 the CSS Color Module ([[CSS3COLOR]]).
1488 </p>
1490 <table class="animatable-properties">
1491 <tr>
1492 <th>Property Name</th>
1493 <th>Type</th>
1494 </tr>
1495 <tr>
1496 <td>'background-color'</td><td>as <a href="#animtype-color">color</a></tr>
1497 <tr>
1498 <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>
1499 </tr>
1500 <tr>
1501 <td>'border-bottom-color'</td><td>as <a href="#animtype-color">color</a></td>
1502 </tr>
1503 <tr>
1504 <td>'border-bottom-width'</td><td>as <a href="#animtype-length">length</a></td>
1505 </tr>
1506 <tr>
1507 <td>'border-left-color'</td><td>as <a href="#animtype-color">color</a></td>
1508 </tr>
1509 <tr>
1510 <td>'border-left-width'</td><td>as <a href="#animtype-length">length</a></td>
1511 </tr>
1512 <tr>
1513 <td>'border-right-color'</td><td>as <a href="#animtype-color">color</a></td>
1514 </tr>
1515 <tr>
1516 <td>'border-right-width'</td><td>as <a href="#animtype-length">length</a></td>
1517 </tr>
1518 <tr>
1519 <td>'border-spacing'</td><td>as <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-length">length</a></td>
1520 </tr>
1521 <tr>
1522 <td>'border-top-color'</td><td>as <a href="#animtype-color">color</a></td>
1523 </tr>
1524 <tr>
1525 <td>'border-top-width'</td><td>as <a href="#animtype-length">length</a></td>
1526 </tr>
1527 <tr>
1528 <td>'bottom'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1529 </tr>
1530 <tr>
1531 <td>'clip'</td><td>as <a href="#animtype-rect">rectangle</a></td>
1532 </tr>
1533 <tr>
1534 <td>'color'</td><td>as <a href="#animtype-color">color</a></td>
1535 </tr>
1536 <tr>
1537 <td>'font-size'</td><td>as <a href="#animtype-length">length</a></td>
1538 </tr>
1539 <tr>
1540 <td>'font-weight!!property'</td><td>as <a href="#animtype-font-weight">font weight</a></td>
1541 </tr>
1542 <tr>
1543 <td>'height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1544 </tr>
1545 <tr>
1546 <td>'left'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1547 </tr>
1548 <tr>
1549 <td>'letter-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1550 </tr>
1551 <tr>
1552 <td>'line-height'</td><td>as either <a href="#animtype-number">number</a> or <a href="#animtype-length">length</a></td>
1553 </tr>
1554 <tr>
1555 <td>'margin-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1556 </tr>
1557 <tr>
1558 <td>'margin-left'</td><td>as <a href="#animtype-length">length</a></td>
1559 </tr>
1560 <tr>
1561 <td>'margin-right'</td><td>as <a href="#animtype-length">length</a></td>
1562 </tr>
1563 <tr>
1564 <td>'margin-top'</td><td>as <a href="#animtype-length">length</a></td>
1565 </tr>
1566 <tr>
1567 <td>'max-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1568 </tr>
1569 <tr>
1570 <td>'max-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1571 </tr>
1572 <tr>
1573 <td>'min-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1574 </tr>
1575 <tr>
1576 <td>'min-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1577 </tr>
1578 <tr>
1579 <td>'opacity'</td><td>as <a href="#animtype-number">number</a></td>
1580 </tr>
1581 <tr>
1582 <td>'outline-color'</td><td>as <a href="#animtype-color">color</a></td>
1583 </tr>
1584 <tr>
1585 <td>'outline-width'</td><td>as <a href="#animtype-length">length</a></td>
1586 </tr>
1587 <tr>
1588 <td>'padding-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1589 </tr>
1590 <tr>
1591 <td>'padding-left'</td><td>as <a href="#animtype-length">length</a></td>
1592 </tr>
1593 <tr>
1594 <td>'padding-right'</td><td>as <a href="#animtype-length">length</a></td>
1595 </tr>
1596 <tr>
1597 <td>'padding-top'</td><td>as <a href="#animtype-length">length</a></td>
1598 </tr>
1599 <tr>
1600 <td>'right'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1601 </tr>
1602 <tr>
1603 <td>'text-indent'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1604 </tr>
1605 <tr>
1606 <td>'text-shadow'</td><td>as <a href="#animtype-shadow-list">shadow list</a></td>
1607 </tr>
1608 <tr>
1609 <td>'top'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1610 </tr>
1611 <tr>
1612 <td>'vertical-align'</td><td>as <a href="#animtype-length">length</a></td>
1613 </tr>
1614 <tr>
1615 <td>'visibility'</td><td>as <a href="#animtype-visibility">visibility</a></td>
1616 </tr>
1617 <tr>
1618 <td>'width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1619 </tr>
1620 <tr>
1621 <td>'word-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1622 </tr>
1623 <tr>
1624 <td>'z-index'</td><td>as <a href="#animtype-integer">integer</a></td>
1625 </tr>
1626 </table>
1628 <h3 id="animatable-svg"><span id="properties-from-svg-">
1629 Properties from SVG
1630 </span></h3>
1632 <p>
1633 All properties defined as animatable in the SVG specification, provided
1634 they are one of the property types listed above.
1635 </p>
1637 <!-- <table>
1638 <tr>
1639 <th>Property Name</th><th>Type</th>
1640 </tr>
1641 <tr>
1642 <td>stop-color</td><td>as <a href="#animtype-color">color</a></td>
1643 </tr>
1644 <tr>
1645 <td>stop-opacity</td><td>as <a href="#animtype-number">number</a></td>
1646 </tr>
1647 <tr>
1648 <td>fill</td><td>as <a href="#animtype-paintserver">paint server</a></td>
1649 </tr>
1650 <tr>
1651 <td>fill-opacity</td><td>as <a href="#animtype-number">number</a></td>
1652 </tr>
1653 <tr>
1654 <td>stroke</td><td>as <a href="#animtype-paintserver">paint server</a></td>
1655 </tr>
1656 <tr>
1657 <td>stroke-dasharray</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-number">number</a></td>
1658 </tr>
1659 <tr>
1660 <td>stroke-dashoffset</td><td>as <a href="#animtype-number">number</a></td>
1661 </tr>
1662 <tr>
1663 <td>stroke-miterlimit</td><td>as <a href="#animtype-number">number</a></td>
1664 </tr>
1665 <tr>
1666 <td>stroke-opacity</td><td>as <a href="#animtype-number">number</a></td>
1667 </tr>
1668 <tr>
1669 <td>stroke-width</td><td>as <a href="#animtype-number">number</a></td>
1670 </tr>
1671 <tr>
1672 <td>viewport-fill</td><td>as <a href="#animtype-color">color</a></td>
1673 </tr>
1674 <tr>
1675 <td>viewport-fill-opacity</td><td>as <a href="#animtype-color">color</a></td>
1676 </tr>
1677 </table> -->
1679 <h2 id="changes">Changes since Working Draft of 19 November 2013</h2>
1681 <p>The following are the substantive changes made since the
1682 <a href="https://www.w3.org/TR/2013/WD-css3-transitions-20131119/">Working Draft
1683 dated 19 November 2013</a>:</p>
1685 <ul>
1686 <li>Values that cannot be interpolated are transitioned when the timing function crosses its midpoint, instead of not running transitions and changing immediately.</li>
1687 <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>
1688 <li>Completion of transitions is defined somewhat more precisely.</li>
1689 <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>
1690 <li>The interpolation of ''shadow/inset'' values on shadow lists is no longer backwards.</li>
1691 <li>A [[#conformance]] section and [[#idl-index]] have been added</li>
1692 <li>The identifiers accepted by 'transition-property' are defined in terms of <<custom-ident>>.</li>
1693 <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>
1694 </ul>
1696 <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>
1698 <p>For changes in earlier working drafts:</p>
1700 <ol>
1701 <li>see the <a href="https://www.w3.org/TR/2013/WD-css3-transitions-20131119/#changes">changes section in the 19 November 2013 Working Draft</a>
1702 <li>see the <a href="https://www.w3.org/TR/2013/WD-css3-transitions-20130212/ChangeLog">the ChangeLog</a> for changes in previous working drafts
1703 <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>.
1704 </ol>
1706 <h2 id="acknowledgments">Acknowledgments</h2>
1708 <p>Thanks especially to the feedback from
1709 Tab Atkins,
1710 Carine Bournez,
1711 Aryeh Gregor,
1712 Vincent Hardy,
1713 Anne van Kesteren,
1714 Cameron McCormack,
1715 Alex Mogilevsky,
1716 Jasper St. Pierre,
1717 Estelle Weyl,
1718 and all the rest of the
1719 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>