Thu, 18 Feb 2016 18:26:23 -0800
[css-transitions] Link issue to relevant mailing list messages.
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 Shortname: css-transitions
19 Group: csswg
20 Level: 1
21 TR: https://www.w3.org/TR/css3-transitions/
22 Previous version: https://www.w3.org/TR/2013/WD-css3-transitions-20131119/
23 ED: https://drafts.csswg.org/css-transitions/
24 Editor: L. David Baron, Mozilla https://www.mozilla.org/, http://dbaron.org/
25 Editor: Dean Jackson, Apple Inc https://www.apple.com/, dino@apple.com
26 Editor: David Hyatt, Apple Inc https://www.apple.com/, hyatt@apple.com
27 Editor: Chris Marrin, Apple Inc https://www.apple.com/, cmarrin@apple.com
28 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
29 Issue Tracking: Bugzilla bugs for all levels https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transitions&resolution=---
30 Abstract: CSS Transitions allows property changes in CSS values to occur smoothly over a specified duration.
31 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>
32 Ignored Terms: float
33 Ignored Vars: x1, x2, y1, y2
34 Link Defaults: css-transforms (property) transform
35 </pre>
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://www.w3.org/TR/css3-background/#shadow-inset; type: value; for: shadow; text: inset;
92 url: https://www.w3.org/TR/css3-background/#box-shadow-none; type: value; for: shadow; text: none;
93 url: https://www.w3.org/TR/CSS21/visufx.html#propdef-visibility; type: value; for: visibility; text: visible;
94 urlPrefix: https://www.w3.org/TR/css3-color/; type: value;
95 text: transparent
96 text: blue
97 text: green
98 url: http://w3c.github.io/dom/#constructing-events; type: dfn; text: event constructor;
99 url: https://html.spec.whatwg.org/multipage/infrastructure.html#concept-event-dispatch; type: dfn; text: dispatch;
100 </pre>
101 </dl>
103 Introduction {#introduction}
104 ============================
106 <p><em>This section is not normative.</em>
107 <p>
108 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.
109 </p>
111 <span id="transitions-">Transitions</span> {#transitions}
112 =========================================================
114 <p>
115 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.
116 </p>
117 <p>
118 For example, suppose that transitions of one second have been defined on the 'left' and
119 '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.
120 </p>
121 <div class="figure">
122 <img src="transition1.png" alt="">
123 </div>
124 <p class="caption">
125 Transitions of 'left' and 'background-color'
126 </p>
127 <p>
128 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.
129 </p>
130 <p>
131 Only animatable CSS properties can be transitioned. See the table at the end of this document for a list
132 of properties that are animatable.
133 </p>
134 <p>
135 The transition for a property is defined using a number of new properties. For example:
136 </p>
137 <div class="example">
138 <p style="display:none">
139 Example(s):
140 </p>
141 <pre>
142 div {
143 transition-property: opacity;
144 transition-duration: 2s;
145 }
146 </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.
147 </div>
148 <p>
149 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:
150 </p>
151 <div class="example">
152 <p style="display:none">
153 Example(s):
154 </p>
155 <pre>
156 div {
157 transition-property: opacity, left;
158 transition-duration: 2s, 4s;
159 }
161 </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.
162 </div>
164 <p id="list-matching">
165 In the case where the lists of values in transition properties
166 do not have the same length, the length of the
167 'transition-property' list determines the number of items in
168 each list examined when starting transitions. The lists are
169 matched up from the first value: excess values at the end are
170 not used. If one of the other properties doesn't have enough
171 comma-separated values to match the number of values of
172 'transition-property', the UA must calculate its used value by
173 repeating the list of values until there are enough. This
174 truncation or repetition does not affect the computed value.
175 <span class="note">
176 Note: This is analogous to the behavior of the 'background-*'
177 properties, with 'background-image' analogous to
178 'transition-property'.
179 </span>
180 </p>
182 <div class="example">
183 <p style="display:none">
184 Example(s):
185 </p>
186 <pre>
187 div {
188 transition-property: opacity, left, top, width;
189 transition-duration: 2s, 1s;
190 }
191 </pre>The above example defines a transition on the 'opacity' property of 2 seconds duration, a
192 transition on the 'left' property of 1
193 second duration, a transition on the 'top' property of 2 seconds duration and a
194 transition on the 'width' property of 1
195 second duration.
197 </div>
199 <p>
200 While authors can use transitions to create dynamically changing content,
201 dynamically changing content can lead to seizures in some users.
202 For information on how to avoid content that can lead to seizures, see
203 <a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3:
204 Seizures:
205 Do not design content in a way that is known to cause seizures</a>
206 ([[WCAG20]]).
207 </p>
209 <span id="the-transition-property-property-">The 'transition-property' Property</span> {#transition-property-property}
210 ----------------------------------------------------------------------------------------------------------------------
212 <p>
213 The 'transition-property' property specifies the name of the CSS property to which the transition is applied.
214 </p>
215 <pre class="propdef">
216 Name: transition-property
217 Value: ''transition-property/none'' | <<single-transition-property>>#
218 Initial: ''transition-property/all''
219 Applies to: all elements, ::before and ::after pseudo elements
220 Inherited: no
221 Animatable: no
222 Percentages: N/A
223 Media: visual
224 Computed value: Same as specified value.
225 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
226 </pre>
228 <div class="prod">
229 <dfn type id="single-transition-property"><single-transition-property></dfn> = ''transition-property/all'' | <<custom-ident>>;
230 </div>
232 <p>
233 A value of
234 <dfn value for="transition-property">none</dfn>
235 means that no property will transition.
236 Otherwise, a list of properties to be transitioned, or the
237 keyword <dfn value for="transition-property">all</dfn>
238 which indicates that all properties are to be
239 transitioned, is given.
240 </p>
242 <p>
243 If one of the identifiers listed is not a recognized property
244 name or is not an animatable property, the implementation must
245 still start transitions on the animatable properties in the
246 list using the duration, delay, and timing function at their
247 respective indices in the lists for 'transition-duration',
248 'transition-delay', and 'transition-timing-function'. In other
249 words, unrecognized or non-animatable properties must be kept in
250 the list to preserve the matching of indices.
251 </p>
253 <p>
254 The <<custom-ident>> production in <<single-transition-property>>
255 also excludes the keyword ''transition-property/none'',
256 in addition to the keywords always excluded from <<custom-ident>>.
257 This means that
258 ''transition-property/none'', ''inherit'', and ''initial'' are not
259 permitted as items within a list of more that one identifier;
260 any list that uses them is syntactically invalid.
261 </p>
263 <p>
264 For the keyword ''transition-property/all'',
265 or if one of the identifiers listed is a
266 shorthand property, implementations must start transitions for
267 any of its longhand sub-properties that are animatable (or, for
268 ''transition-property/all'', all animatable properties), using the duration, delay,
269 and timing function at the index corresponding to the shorthand.
270 </p>
271 <p>
272 If a property is specified multiple times in the value of
273 'transition-property' (either on its own, via a shorthand that
274 contains it, or via the ''transition-property/all'' value), then the transition that
275 starts uses the duration, delay, and timing function at the
276 index corresponding to the <em>last</em> item in the value of
277 'transition-property' that calls for animating that property.
278 </p>
279 <p class="note">
280 Note: The ''transition-property/all'' value and 'all' shorthand
281 property work in similar ways, so the
282 ''transition-property/all'' value is just like a shorthand that
283 covers all properties.
284 </p>
286 <span id="the-transition-duration-property-">The 'transition-duration' Property</span> {#transition-duration-property}
287 ----------------------------------------------------------------------------------------------------------------------
289 <p>
290 The 'transition-duration' property defines the length of time that a transition takes.
291 </p>
292 <pre class="propdef">
293 Name: transition-duration
294 Value: <<time>>#
295 Initial: ''0s''
296 Applies to: all elements, ::before and ::after pseudo elements
297 Inherited: no
298 Animatable: no
299 Percentages: N/A
300 Media: interactive
301 Computed value: Same as specified value.
302 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
303 </pre>
304 <p>
305 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.
306 </p>
308 <span id="transition-timing-function_tag">The 'transition-timing-function' Property</span> {#transition-timing-function-property}
309 ---------------------------------------------------------------------------------------------------------------------------------
311 <p>
312 The 'transition-timing-function' property
313 describes how the intermediate values used during a transition will be
314 calculated. It allows for a transition to change speed over its
315 duration. These effects are commonly called <em>easing</em> functions.
316 In either case, a mathematical function that provides a smooth curve is
317 used.
318 </p>
319 <p>
320 Timing functions are either defined as a stepping function or
321 a <a
322 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
323 Bézier curve</a>.
324 The timing function takes as its input
325 the current elapsed percentage of the transition duration
326 and outputs the percentage of the way the transition is
327 from its start value to its end value.
328 How this output is used is defined by
329 the <a href="#animatable-types">interpolation rules</a>
330 for the value type.
331 </p>
332 <p>
333 A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a>
334 function is defined by a number that divides the domain of operation
335 into equally sized intervals. Each subsequent interval is a equal step
336 closer to the goal state. The function also specifies whether the
337 change in output percentage happens at the start or end of the
338 interval (in other words, if 0% on the input percentage is the point
339 of initial change).
340 </p>
341 <div class="figure">
342 <img src="step.png" alt="The step timing function splits
343 the function domain into a number of disjoint straight line
344 segments. steps(1, start) is a function whose
345 output value is 1 for all input values. steps(1, end) is a function whose
346 output value is 0 for all input values less than 1, and output
347 is 1 for the input value of 1. steps(3, start) is a function that
348 divides the input domain into three segments, each 1/3 in length,
349 and 1/3 above the previous segment, with the first segment starting
350 at 1/3. steps(3, end) is a function that
351 divides the input domain into three segments, each 1/3 in length,
352 and 1/3 above the previous segment, with the first segment starting
353 at 0.">
354 </div>
355 <p class="caption">
356 Step timing functions
357 </p>
358 <p>
359 A <a
360 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
361 Bézier curve</a> is defined by four control points, P<sub>0</sub>
362 through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub>
363 are always set to (0,0) and (1,1). The 'transition-timing-function' property is used
364 to specify the values for points P<sub>1</sub> and P<sub>2</sub>. These
365 can be set to preset values using the keywords listed below, or can be
366 set to specific values using the ''cubic-bezier()'' function.
367 In the ''cubic-bezier()'' function, P<sub>1</sub> and
368 P<sub>2</sub> are each specified by both an X and Y value.
369 </p>
370 <div class="figure">
371 <img src="TimingFunction.png" alt="The Bézier timing function is a
372 smooth curve from point P0 = (0,0) to point P3 = (1,1). The
373 length and orientation of the line segment P0-P1 determines
374 the tangent and the curvature of the curve at P0 and the
375 line segment P2-P3 does the same at P3.">
376 </div>
377 <p class="caption">
378 Bézier Timing Function Control Points
379 </p>
380 <pre class="propdef">
381 Name: transition-timing-function
382 Value: <<single-transition-timing-function>>#
383 Initial: ''transition-timing-function/ease''
384 Applies to: all elements, ::before and ::after pseudo elements
385 Inherited: no
386 Animatable: no
387 Percentages: N/A
388 Media: interactive
389 Computed value: Same as specified value.
390 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
391 </pre>
392 <div class="prod">
393 <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>>)
394 </div>
395 <p>
396 The timing functions have the following definitions.
397 </p>
398 <dl dfn-type="value" dfn-for="transition-timing-function, <single-transition-timing-function>">
399 <dt><dfn>ease</dfn></dt>
400 <dd>
401 The ease function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.25, 0.1, 0.25, 1)</a>.
402 </dd>
403 <dt><dfn>linear</dfn></dt>
404 <dd>
405 The linear function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0, 0, 1, 1)</a>.
406 </dd>
407 <dt><dfn>ease-in</dfn></dt>
408 <dd>
409 The ease-in function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.42, 0, 1, 1)</a>.
410 </dd>
411 <dt><dfn>ease-out</dfn></dt>
412 <dd>
413 The ease-out function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0, 0, 0.58, 1)</a>.
414 </dd>
415 <dt><dfn>ease-in-out</dfn></dt>
416 <dd>
417 The ease-in-out function is equivalent to <a lt="cubic-bezier()" function>cubic-bezier(0.42, 0, 0.58, 1)</a>.
418 </dd>
419 <dt><dfn>step-start</dfn></dt>
420 <dd>
421 The step-start function is equivalent to <a lt="steps()" function>steps(1, start)</a>.
422 </dd>
423 <dt><dfn>step-end</dfn></dt>
424 <dd>
425 The step-end function is equivalent to <a lt="steps()" function>steps(1, end)</a>.
426 </dd>
427 <dt><dfn function lt="steps()">steps(<<integer>>[, [ start | end ] ]?)</dfn></dt>
428 <dd>
429 Specifies a stepping function, described above, taking two
430 parameters. The first parameter specifies the number of intervals
431 in the function. It must be a positive integer (greater than 0).
432 The second parameter, which is optional, is
433 either the value <dfn value for="steps()">start</dfn> or <dfn value for="steps()">end</dfn>, and specifies the point
434 at which the change of values occur within the interval.
435 If the second parameter is omitted, it is given the value ''end''.
436 </dd>
437 <dt><dfn function lt="cubic-bezier()">cubic-bezier(<<number>>, <<number>>, <<number>>, <<number>>)</dfn></dt>
438 <dd>
439 Specifies a <a
440 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier
441 curve</a>. The four values specify points P<sub>1</sub> and
442 P<sub>2</sub> of the curve as (<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>). Both x values must be
443 in the range [0, 1] or the definition is invalid. The y values can
444 exceed this range.
445 </dd>
446 </dl>
448 <span id="the-transition-delay-property-">The 'transition-delay' Property</span> {#transition-delay-property}
449 -------------------------------------------------------------------------------------------------------------
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>
470 <span id="the-transition-shorthand-property-">The 'transition' Shorthand Property</span> {#transition-shorthand-property}
471 -------------------------------------------------------------------------------------------------------------------------
473 <p>
474 The 'transition' shorthand property combines the four properties described above into a single property.
475 </p>
476 <pre class="propdef">
477 Name: transition
478 Value: <<single-transition>>#
479 Initial: see individual properties
480 Applies to: all elements, ::before and ::after pseudo elements
481 Inherited: no
482 Animatable: no
483 Percentages: N/A
484 Media: interactive
485 Computed value: see individual properties
486 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
487 </pre>
489 <div class="prod">
490 <dfn type id="single-transition"><single-transition></dfn> = [ ''transition-property/none'' | <<single-transition-property>> ] || <<time>> || <<single-transition-timing-function>> || <<time>>
491 </div>
493 <p>
494 Note that order is important within the items in this property:
495 the first value that can be parsed as a time is assigned to the
496 transition-duration,
497 and the second value that can be parsed as a time is assigned to
498 transition-delay.
499 </p>
501 <p>
502 If there is more than one <<single-transition>> in the shorthand,
503 and any of the transitions has
504 ''transition-property/none'' as the <<single-transition-property>>,
505 then the declaration is invalid.
506 </p>
508 Starting of transitions {#starting}
509 ===================================
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 Faster reversing of interrupted transitions {#reversing}
1001 --------------------------------------------------------
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 Application of transitions {#application}
1053 =========================================
1055 <p>
1056 When a property on an element is undergoing a transition
1057 (that is, when or after the transition has started and before the
1058 <a>end time</a> of the transition)
1059 the transition adds a style called the <dfn export>current value</dfn>
1060 to the CSS cascade
1061 at the level defined for CSS Transitions in [[!CSS3CASCADE]].
1062 </p>
1064 <p class="note">
1065 Note that this means that computed values
1066 resulting from CSS transitions
1067 can inherit to descendants just like
1068 any other computed values.
1069 In the normal case, this means that
1070 a transition of an inherited property
1071 applies to descendant elements
1072 just as an author would expect.
1073 </p>
1075 <p>
1076 Implementations must add this value to the cascade
1077 if and only if
1078 that property is not currently
1079 undergoing a CSS Animation ([[!CSS3-ANIMATIONS]]) on the same element.
1080 </p>
1082 <p class="note">
1083 Note that this behavior of transitions not applying to the cascade
1084 when an animation on the same element and property is running
1085 does not affect whether the transition has started or ended.
1086 APIs that detect whether transitions are running
1087 (such as <a href="#transition-events">transition events</a>)
1088 still report that a transition is running.
1089 </p>
1091 <p>
1092 If the current time is at or before the
1093 <a>start time</a> of the transition
1094 (that is, during the delay phase of the transition),
1095 the <a>current value</a> is a specified style that will compute
1096 to the <a>start value</a> of the transition.
1097 </p>
1099 <p>
1100 If the current time is after the
1101 <a>start time</a> of the transition
1102 (that is, during the duration phase of the transition),
1103 the <a>current value</a> is a specified style that will compute
1104 to the <a href="#animatable-types">result of interpolating the property</a>
1105 using the <a>start value</a> of the transition as
1106 <var>V</var><sub>start</sub>,
1107 using the <a>end value</a> of the transition as
1108 <var>V</var><sub>end</sub>,
1109 and using (current time - start time) / (end time - start time)
1110 as the input to the timing function.
1111 </p>
1113 Completion of transitions {#complete}
1114 =====================================
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 <span id="transition-events-">Transition Events</span> {#transition-events}
1141 ===========================================================================
1142 <p>
1143 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>.
1144 An event is <a>dispatched</a> to the element
1145 for each property that undergoes a transition on that element.
1146 This allows a content developer to perform actions that synchronize
1147 with the completion of a transition.
1148 </p>
1149 <p>
1150 Each event provides the name of the property the transition is
1151 associated with as well as the duration of the transition.
1152 </p>
1153 <dl>
1154 <dt>
1155 <b>Interface <dfn interface id="Events-TransitionEvent">TransitionEvent</dfn></b>
1156 </dt>
1157 <dd>
1158 <p>
1159 The {{TransitionEvent}} interface provides specific contextual information associated with transitions.
1160 </p>
1161 <dl>
1162 <dt>
1163 <b>IDL Definition</b>
1164 </dt>
1165 <dd>
1166 <div class='idl-code'>
1167 <pre class='idl'>
1168 [Constructor(DOMString type, optional TransitionEventInit transitionEventInitDict)]
1169 interface TransitionEvent : Event {
1170 readonly attribute DOMString propertyName;
1171 readonly attribute float elapsedTime;
1172 readonly attribute DOMString pseudoElement;
1173 };
1175 dictionary TransitionEventInit : EventInit {
1176 DOMString propertyName = "";
1177 float elapsedTime = 0.0;
1178 DOMString pseudoElement = "";
1179 };
1180 </pre>
1181 </div>
1182 </dd>
1183 <dt>
1184 <b>Attributes</b>
1185 </dt>
1186 <dd>
1187 <dl>
1188 <dt>
1189 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-propertyName">propertyName</dfn></code> of type <code>DOMString</code>, readonly
1190 </dt>
1191 <dd>
1192 The name of the CSS property associated with the transition.
1193 </dd>
1194 </dl>
1195 <dl>
1196 <dt>
1197 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-elapsedTime">elapsedTime</dfn></code> of type <code>float</code>, readonly
1198 </dt>
1199 <dd>
1200 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>.
1201 </dd>
1202 </dl>
1203 <dl>
1204 <dt>
1205 <code class='attribute-name'><dfn attribute for="TransitionEvent" id="Events-TransitionEvent-pseudoElement">pseudoElement</dfn></code> of type <code>DOMString</code>, readonly
1206 </dt>
1207 <dd>
1208 The name (beginning with two colons) of the CSS
1209 pseudo-element on which the transition occurred (in
1210 which case the target of the event is that
1211 pseudo-element's corresponding element), or the empty
1212 string if the transition occurred on an element (which
1213 means the target of the event is that element).
1214 </dd>
1215 </dl>
1216 </dd>
1217 </dl>
1218 <p>
1219 <code id="TransitionEvent-constructor">TransitionEvent(type, transitionEventInitDict)</code>
1220 is an <a>event constructor</a>.
1221 </p>
1222 </dd>
1223 </dl>
1224 <p>
1225 There is one type of transition event available.
1226 </p>
1227 <dl>
1228 <dt>
1229 <b><dfn event for="Element" id="transitionend">transitionend</dfn></b>
1230 </dt>
1231 <dd>
1232 The {{transitionend}} event occurs at the completion of the transition. In the
1233 case where a transition is removed before completion, such as if the
1234 transition-property is removed, then the event will not fire.
1235 <ul>
1236 <li>Bubbles: Yes
1237 </li>
1238 <li>Cancelable: No
1239 </li>
1240 <li>Context Info: propertyName, elapsedTime, pseudoElement
1241 </li>
1242 </ul>
1243 </dd>
1244 </dl>
1246 <span id="animation-of-property-types-">Animation of property types</span> {#animatable-types}
1247 ==============================================================================================
1249 <p>
1250 Some property types can be interpolated,
1251 which means they can animate smoothly from one value to another.
1252 Other property types cannot, and thus animate only in a single
1253 step from one value to the other.
1254 </p>
1256 Animation of interpolated property types {#interpolated-types}
1257 --------------------------------------------------------------
1259 <p>
1260 When interpolating between two values,
1261 <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
1262 interpolation is done using the output <var>p</var> of the timing function,
1263 which gives the portion of the value space
1264 that the interpolation has crossed.
1265 Thus the result of the interpolation is
1266 <var>V</var><sub>res</sub> =
1267 (1 - <var>p</var>) ⋅ <var>V</var><sub>start</sub> +
1268 <var>p</var> ⋅ <var>V</var><sub>end</sub>.
1269 </p>
1271 <p>
1272 However, if this value (<var>V</var><sub>res</sub>)
1273 is outside the allowed range of values for the property,
1274 then it is clamped to that range.
1275 This can occur if <var>p</var> is outside of the range 0 to 1,
1276 which can occur if a timing function is specified
1277 with a <var>y1</var> or <var>y2</var> that is outside the range 0 to 1.
1278 </p>
1280 <p>
1281 The following describes how each property type undergoes transition or
1282 animation.
1283 </p>
1285 <ul>
1286 <li id="animtype-color">
1287 <strong>color</strong>: interpolated via red, green, blue and alpha
1288 components (treating each as a number, see below).
1289 The interpolation is done between premultiplied colors
1290 (that is, colors for which the red, green, and blue components
1291 specified have been multiplied by the alpha).
1292 </li>
1293 <li id="animtype-length">
1294 <strong>length</strong>: interpolated as real numbers.
1295 </li>
1296 <li id="animtype-percentage">
1297 <strong>percentage</strong>: interpolated as real numbers.
1298 </li>
1299 <li id="animtype-lpcalc">
1300 <strong>length, percentage, or calc</strong>: when both values
1301 are lengths, interpolated as lengths; when both values are
1302 percentages, interpolated as percentages; otherwise, both
1303 values are converted into a ''calc()'' function that is the
1304 sum of a length and a percentage (each possibly zero), and
1305 these ''calc()'' functions have each half interpolated as real
1306 numbers.
1307 </li>
1308 <li id="animtype-integer">
1309 <strong>integer</strong>: interpolated via discrete steps (whole
1310 numbers). The interpolation happens in real number space and is
1311 converted to an integer by rounding to the nearest integer, with
1312 values halfway between a pair of integers rounded towards
1313 positive infinity.
1314 </li>
1315 <li id="animtype-font-weight">
1316 <strong>font weight</strong>: interpolated via discrete steps
1317 (multiples of 100). The interpolation happens in real number
1318 space and is converted to an integer by rounding to the
1319 nearest multiple of 100, with values halfway between multiples
1320 of 100 rounded towards positive infinity.
1321 </li>
1322 <li id="animtype-number">
1323 <strong>number</strong>: interpolated as real (floating point)
1324 numbers.
1325 </li>
1326 <li id="animtype-rect">
1327 <strong>rectangle</strong>: interpolated via the x, y,
1328 width and height components (treating each as a number).
1329 </li>
1330 <li id="animtype-visibility">
1331 <strong>visibility</strong>: if one of the values is
1332 ''visibility/visible'', interpolated as a discrete step where values of the
1333 timing function between 0 and 1 map to ''visibility/visible'' and other
1334 values of the timing function (which occur only at the
1335 start/end of the transition or as a result of ''cubic-bezier()''
1336 functions with Y values outside of [0, 1]) map to the closer
1337 endpoint; if neither value is ''visibility/visible'' then not interpolable.
1338 </li>
1339 <li id="animtype-shadow-list">
1340 <strong>shadow list</strong>: Each shadow in the list
1341 (treating ''shadow/none'' as a 0-length list)
1342 is interpolated via the
1343 color (as <a href="#animtype-color">color</a>) component,
1344 and x, y, blur, and (when appropriate) spread
1345 (as <a href="#animtype-length">length</a>) components.
1346 For each shadow, if both input shadows are ''shadow/inset''
1347 or both input shadows are not ''shadow/inset'',
1348 then the interpolated shadow must match the input shadows in that regard.
1349 If any pair of input shadows has one ''shadow/inset'' and the other not ''shadow/inset'',
1350 the entire <a href="#animtype-shadow-list">shadow-list</a> is uninterpolable.
1351 If the lists of shadows have different lengths,
1352 then the shorter list is padded at the end
1353 with shadows whose color is ''transparent'',
1354 all lengths are ''0'',
1355 and whose ''shadow/inset'' (or not) matches the longer list.
1356 </li>
1357 <li id="animtype-gradient">
1358 <strong>gradient</strong>: interpolated via the
1359 positions and colors of each stop. They must have the same type
1360 (radial or linear) and same number of stops in order to be animated.
1361 <span class="note">Note: [[CSS3-IMAGES]] may extend this
1362 definition.</span>
1363 </li>
1364 <li id="animtype-paintserver">
1365 <strong>paint server</strong> (SVG): interpolation is only supported
1366 between: gradient to gradient and color to color. They then
1367 work as above.
1368 </li>
1369 <li id="animtype-simple-list">
1370 <strong>simple list</strong> of other types:
1371 If the lists have the same number of items,
1372 and each pair of values can be interpolated,
1373 each item in the list is interpolated using
1374 the rules given for those types.
1375 Otherwise the values are not interpolable.
1376 </li>
1377 <li id="animtype-repeatable-list">
1378 <strong>repeatable list</strong> of other types:
1379 The result list has a length that is the least common multiple
1380 of the lengths of the input lists.
1381 Each item in the result is the interpolation of the value
1382 from each input list repeated to the length of the result list.
1383 If a pair of values cannot be interpolated, then the lists
1384 are not interpolable.
1385 <span class="note">
1386 The repeatable list concept ensures that a list that is
1387 conceptually repeated to a certain length (as
1388 'background-origin' is repeated to the length of the
1389 'background-image' list) or repeated infinitely will
1390 smoothly transition between any values, and so that the
1391 computed value will properly represent the result (and
1392 potentially be inherited correctly).
1393 </span>
1394 </li>
1395 </ul>
1397 <p>Future specifications may define additional types that can
1398 be animated.</p>
1400 <p>See the definition of 'transition-property' for how animation
1401 of shorthand properties and the ''all'' value is applied to any
1402 properties (in the shorthand) that can be animated.</p>
1404 Animation in steps of other property types {#step-types}
1405 --------------------------------------------------------
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 <span id="animatable-properties-">Animatable properties</span> {#animatable-properties}
1430 =======================================================================================
1432 <!--
1433 As resolved in
1434 http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html
1435 -->
1437 <p>The definition of each CSS property defines
1438 when the values of that property can be interpolated
1439 by referring to the definitions of property types
1440 in the <a href="#animatable-types">previous section</a>.
1441 The animated value is interpolated from the from and to values when
1442 both the from and the to values of the property have the type described.
1443 (When a composite type such as "length, percentage, or calc" is listed,
1444 this means that both values must fit into that composite type.)
1445 When multiple types are listed in the form "either A or B",
1446 both values must be of the same type to be interpolable.</p>
1448 <p>Otherwise, since the from and to values cannot be interpolated,
1449 the animation is done <a href="#step-types">in a single step</a>.</p>
1451 <p>The 'transition-*' properties defined in this specification do
1452 not undergo transitions.</p>
1454 <p>For properties that exist at the time this specification was
1455 developed, this specification defines how they are
1456 animated. However, future CSS specifications may define
1457 additional properties, additional values for existing properties,
1458 or additional animation behavior of existing values. In order to
1459 describe new animation behaviors and to have the definition of
1460 animation behavior in a more appropriate location, future CSS
1461 specifications should include an "Animatable:" line in the summary
1462 of the property's definition (in addition to the other lines
1463 described in [[CSS21]], <a
1464 href="https://www.w3.org/TR/CSS21/about.html#property-defs">section
1465 1.4.2</a>). This line should say "no" to indicate that a property
1466 cannot be animated or should reference an animation behavior
1467 (which may be one of the behaviors in the <a
1468 href="#animation-of-property-types-">Animation of property
1469 types</a> section above, or may be a new behavior) to define how
1470 the property animates. Such definitions override those given in
1471 this specification.</p>
1473 <p class="issue" id="issue-animatable-name">
1474 It no longer makes sense for this line to be called
1475 "Animatable". It should probably be renamed to "Interpolation",
1476 and the "no" value renamed to "discrete" or "in steps".
1477 See mailing list thread:
1478 <a href="https://lists.w3.org/Archives/Public/www-style/2015May/0256.html">message 1</a>,
1479 <a href="https://lists.w3.org/Archives/Public/www-style/2015May/0257.html">message 2</a>
1480 </p>
1482 <span id="properties-from-css-">Properties from CSS</span> {#animatable-css}
1483 ----------------------------------------------------------------------------
1485 <p>
1486 The following definitions define the animation behavior for
1487 properties in CSS Level 2 Revision 1 ([[CSS21]]) and in Level 3 of
1488 the CSS Color Module ([[CSS3COLOR]]).
1489 </p>
1491 <table class="animatable-properties">
1492 <tr>
1493 <th>Property Name</th>
1494 <th>Type</th>
1495 </tr>
1496 <tr>
1497 <td>'background-color'</td><td>as <a href="#animtype-color">color</a></tr>
1498 <tr>
1499 <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>
1500 </tr>
1501 <tr>
1502 <td>'border-bottom-color'</td><td>as <a href="#animtype-color">color</a></td>
1503 </tr>
1504 <tr>
1505 <td>'border-bottom-width'</td><td>as <a href="#animtype-length">length</a></td>
1506 </tr>
1507 <tr>
1508 <td>'border-left-color'</td><td>as <a href="#animtype-color">color</a></td>
1509 </tr>
1510 <tr>
1511 <td>'border-left-width'</td><td>as <a href="#animtype-length">length</a></td>
1512 </tr>
1513 <tr>
1514 <td>'border-right-color'</td><td>as <a href="#animtype-color">color</a></td>
1515 </tr>
1516 <tr>
1517 <td>'border-right-width'</td><td>as <a href="#animtype-length">length</a></td>
1518 </tr>
1519 <tr>
1520 <td>'border-spacing'</td><td>as <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-length">length</a></td>
1521 </tr>
1522 <tr>
1523 <td>'border-top-color'</td><td>as <a href="#animtype-color">color</a></td>
1524 </tr>
1525 <tr>
1526 <td>'border-top-width'</td><td>as <a href="#animtype-length">length</a></td>
1527 </tr>
1528 <tr>
1529 <td>'bottom'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1530 </tr>
1531 <tr>
1532 <td>'clip'</td><td>as <a href="#animtype-rect">rectangle</a></td>
1533 </tr>
1534 <tr>
1535 <td>'color'</td><td>as <a href="#animtype-color">color</a></td>
1536 </tr>
1537 <tr>
1538 <td>'font-size'</td><td>as <a href="#animtype-length">length</a></td>
1539 </tr>
1540 <tr>
1541 <td>'font-weight!!property'</td><td>as <a href="#animtype-font-weight">font weight</a></td>
1542 </tr>
1543 <tr>
1544 <td>'height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1545 </tr>
1546 <tr>
1547 <td>'left'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1548 </tr>
1549 <tr>
1550 <td>'letter-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1551 </tr>
1552 <tr>
1553 <td>'line-height'</td><td>as either <a href="#animtype-number">number</a> or <a href="#animtype-length">length</a></td>
1554 </tr>
1555 <tr>
1556 <td>'margin-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1557 </tr>
1558 <tr>
1559 <td>'margin-left'</td><td>as <a href="#animtype-length">length</a></td>
1560 </tr>
1561 <tr>
1562 <td>'margin-right'</td><td>as <a href="#animtype-length">length</a></td>
1563 </tr>
1564 <tr>
1565 <td>'margin-top'</td><td>as <a href="#animtype-length">length</a></td>
1566 </tr>
1567 <tr>
1568 <td>'max-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1569 </tr>
1570 <tr>
1571 <td>'max-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1572 </tr>
1573 <tr>
1574 <td>'min-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1575 </tr>
1576 <tr>
1577 <td>'min-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1578 </tr>
1579 <tr>
1580 <td>'opacity'</td><td>as <a href="#animtype-number">number</a></td>
1581 </tr>
1582 <tr>
1583 <td>'outline-color'</td><td>as <a href="#animtype-color">color</a></td>
1584 </tr>
1585 <tr>
1586 <td>'outline-width'</td><td>as <a href="#animtype-length">length</a></td>
1587 </tr>
1588 <tr>
1589 <td>'padding-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1590 </tr>
1591 <tr>
1592 <td>'padding-left'</td><td>as <a href="#animtype-length">length</a></td>
1593 </tr>
1594 <tr>
1595 <td>'padding-right'</td><td>as <a href="#animtype-length">length</a></td>
1596 </tr>
1597 <tr>
1598 <td>'padding-top'</td><td>as <a href="#animtype-length">length</a></td>
1599 </tr>
1600 <tr>
1601 <td>'right'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1602 </tr>
1603 <tr>
1604 <td>'text-indent'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1605 </tr>
1606 <tr>
1607 <td>'text-shadow'</td><td>as <a href="#animtype-shadow-list">shadow list</a></td>
1608 </tr>
1609 <tr>
1610 <td>'top'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1611 </tr>
1612 <tr>
1613 <td>'vertical-align'</td><td>as <a href="#animtype-length">length</a></td>
1614 </tr>
1615 <tr>
1616 <td>'visibility'</td><td>as <a href="#animtype-visibility">visibility</a></td>
1617 </tr>
1618 <tr>
1619 <td>'width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1620 </tr>
1621 <tr>
1622 <td>'word-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1623 </tr>
1624 <tr>
1625 <td>'z-index'</td><td>as <a href="#animtype-integer">integer</a></td>
1626 </tr>
1627 </table>
1629 <span id="properties-from-svg-">Properties from SVG</span> {#animatable-svg}
1630 ----------------------------------------------------------------------------
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 Security Considerations {#security}
1680 ===================================
1682 <em>This section is not normative.</em>
1684 The security implications of this specification are limited
1685 because it doesn't allow Web content to do things
1686 that it could not do before.
1687 Rather, it allows things that could previously be done with script
1688 to be done declaratively,
1689 and it ways that implementations can optimize (for frame rate and
1690 CPU usage).
1692 One of the major categories of optimizations
1693 that implementations can make is implementing animation
1694 of certain high-value properties (such as 'transform' and 'opacity')
1695 run on a browser's compositor thread or process
1696 without updating style or layout on the main Web content thread
1697 unless up-to-date style data are needed.
1698 This optimization often requires allocations of graphics memory
1699 to display the contents of the element being animated.
1700 Implementations should take care to ensure that Web content
1701 cannot trigger unsafe out-of-memory handling
1702 by using large numbers of animations
1703 or animations on elements covering large areas
1704 (where large may be defined in terms of pre-transform or post-transform size).
1706 Privacy Considerations {#privacy}
1707 =================================
1709 <em>This section is not normative.</em>
1711 As for security, the privacy considerations of this specification are limited
1712 because it does not allow Web content to do things that it could not do before.
1714 This specification may provide additional mechanisms that help to determine
1715 characteristics of the user's hardware or software.
1716 However, ability to determine performance characteristics of the user's
1717 hardware or software is common to many Web technologies,
1718 and this specification does not introduce new capabilities.
1720 As described in [[#accessibility]],
1721 implementations may provide mitigations to help users with disabilities.
1722 These mitigations are likely to be detectable by Web content,
1723 which means that users who would benefit from these mitigations
1724 may face a tradeoff between keeping their disability private from
1725 the Web content or benefiting from the mitigation.
1727 Accessibility Considerations {#accessibility}
1728 =============================================
1730 <em>This section is not normative.</em>
1732 Motion {#accessibility-motion}
1733 ------------------------------
1735 This specification provides declarative mechanisms for animations
1736 that previously needed to be done using script.
1737 Providing a declarative mechanism has multiple effects:
1738 it makes such animations easier to make and thus likely to be more common,
1739 but it also makes it easier for user agents to modify those animations
1740 if such modifications are needed to meet a user's accessibility needs.
1742 Thus, users who are sensitive to movement,
1743 or who require additional time to read or understand content,
1744 may benefit from user agent features that allow
1745 animations to be disabled or slowed down.
1746 (But see [[#privacy]] for information on the privacy implications
1747 of such mitigations.)
1749 User agent implementors should be aware that Web content
1750 may depend on the firing of <a href="#transition-events">transition events</a>,
1751 so implementations of such mitigations may wish to fire transition events
1752 even if the transitions were not run as continuous animations.
1753 However, it is probably poor practice for Web content to depend on
1754 such events to function correctly.
1756 Cascade {#accessibility-cascade}
1757 --------------------------------
1759 The CSS <a>cascade</a> is a general mechanism in CSS
1760 that allows user needs to interact with author styles.
1761 This specification interacts with the cascade,
1762 but since it only allows animation between values
1763 that result from the existing cascade rules,
1764 it does not interfere with the user's ability to force
1765 CSS properties to have particular values.
1767 The cascade also allows users to disable transitions entirely
1768 by overriding the transition properties.
1771 Changes since Working Draft of 19 November 2013 {#changes}
1772 ==========================================================
1774 <p>The following are the substantive changes made since the
1775 <a href="https://www.w3.org/TR/2013/WD-css3-transitions-20131119/">Working Draft
1776 dated 19 November 2013</a>:</p>
1778 <ul>
1779 <li>Values that cannot be interpolated are transitioned when the timing function crosses its midpoint, instead of not running transitions and changing immediately.</li>
1780 <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>
1781 <li>Completion of transitions is defined somewhat more precisely.</li>
1782 <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>
1783 <li>The interpolation of ''shadow/inset'' values on shadow lists is no longer backwards.</li>
1784 <li>A [[#conformance]] section, [[#security]] section, [[#privacy]] section, [[#accessibility]] section, and [[#idl-index]] have been added</li>
1785 <li>The identifiers accepted by 'transition-property' are defined in terms of <<custom-ident>>.</li>
1786 <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>
1787 </ul>
1789 <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>
1791 <p>For changes in earlier working drafts:</p>
1793 <ol>
1794 <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>
1795 <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
1796 <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>.
1797 </ol>
1799 Acknowledgments {#acknowledgments}
1800 ==================================
1802 <p>Thanks especially to the feedback from
1803 Tab Atkins,
1804 Carine Bournez,
1805 Aryeh Gregor,
1806 Vincent Hardy,
1807 Anne van Kesteren,
1808 Cameron McCormack,
1809 Alex Mogilevsky,
1810 Jasper St. Pierre,
1811 Estelle Weyl,
1812 and all the rest of the
1813 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>