Wed, 03 Feb 2016 16:54:05 +1100
[css-transitions] Use bikeshed markdown heading syntax.
The changes to the generated file are whitespace only (presumably all
whitespace removal, although I didn't check).
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 Ignored Vars: x1, x2, y1, y2
35 Link Defaults: css-transforms (property) transform
36 </pre>
37 <!-- FIXME: font-size and font-weight link defaults don't work -->
38 <pre class="link-defaults">
39 spec:css21; type:property;
40 text:top
41 text:right
42 text:bottom
43 text:left
44 text:margin-top
45 text:margin-right
46 text:margin-bottom
47 text:margin-left
48 text:padding-top
49 text:padding-right
50 text:padding-bottom
51 text:padding-left
52 text:border-top-color
53 text:border-right-color
54 text:border-bottom-color
55 text:border-left-color
56 text:border-top-width
57 text:border-right-width
58 text:border-bottom-width
59 text:border-left-width
60 text:background-color
61 text:background-position
62 text:border-spacing
63 text:width
64 text:height
65 text:min-width
66 text:min-height
67 text:max-width
68 text:max-height
69 text:clip
70 text:letter-spacing
71 text:line-height
72 text:outline-color
73 text:outline-width
74 text:text-indent
75 text:font-size
76 text:font-weight
77 text:vertical-align
78 text:visibility
79 text:word-spacing
80 text:z-index
81 spec:css-color-3;
82 type:property;
83 text:color
84 text:opacity
85 type:value
86 text:green
87 text:blue
88 text:transparent
89 spec:css-values-3; type:type; text:<time>
90 </pre>
91 <!-- FIXME: These overrides aren't great for dev/TR switching -->
92 <pre class="anchors">
93 url: https://drafts.csswg.org/css-backgrounds-3/#shadow-inset; type: value; for: shadow; text: inset;
94 url: https://www.w3.org/TR/CSS21/visufx.html#propdef-visibility; type: value; for: visibility; text: visible;
95 urlPrefix: https://drafts.csswg.org/css-color-3/; type: value;
96 text: transparent
97 text: blue
98 text: green
99 url: http://w3c.github.io/dom/#constructing-events; type: dfn; text: event constructor;
100 url: https://html.spec.whatwg.org/multipage/infrastructure.html#concept-event-dispatch; type: dfn; text: dispatch;
101 </pre>
102 </dl>
104 Introduction {#introduction}
105 ============================
107 <p><em>This section is not normative.</em>
108 <p>
109 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.
110 </p>
112 <span id="transitions-">Transitions</span> {#transitions}
113 =========================================================
115 <p>
116 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.
117 </p>
118 <p>
119 For example, suppose that transitions of one second have been defined on the 'left' and
120 '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.
121 </p>
122 <div class="figure">
123 <img src="transition1.png" alt="">
124 </div>
125 <p class="caption">
126 Transitions of 'left' and 'background-color'
127 </p>
128 <p>
129 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.
130 </p>
131 <p>
132 Only animatable CSS properties can be transitioned. See the table at the end of this document for a list
133 of properties that are animatable.
134 </p>
135 <p>
136 The transition for a property is defined using a number of new properties. For example:
137 </p>
138 <div class="example">
139 <p style="display:none">
140 Example(s):
141 </p>
142 <pre>
143 div {
144 transition-property: opacity;
145 transition-duration: 2s;
146 }
147 </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.
148 </div>
149 <p>
150 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:
151 </p>
152 <div class="example">
153 <p style="display:none">
154 Example(s):
155 </p>
156 <pre>
157 div {
158 transition-property: opacity, left;
159 transition-duration: 2s, 4s;
160 }
162 </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.
163 </div>
165 <p id="list-matching">
166 In the case where the lists of values in transition properties
167 do not have the same length, the length of the
168 'transition-property' list determines the number of items in
169 each list examined when starting transitions. The lists are
170 matched up from the first value: excess values at the end are
171 not used. If one of the other properties doesn't have enough
172 comma-separated values to match the number of values of
173 'transition-property', the UA must calculate its used value by
174 repeating the list of values until there are enough. This
175 truncation or repetition does not affect the computed value.
176 <span class="note">
177 Note: This is analogous to the behavior of the 'background-*'
178 properties, with 'background-image' analogous to
179 'transition-property'.
180 </span>
181 </p>
183 <div class="example">
184 <p style="display:none">
185 Example(s):
186 </p>
187 <pre>
188 div {
189 transition-property: opacity, left, top, width;
190 transition-duration: 2s, 1s;
191 }
192 </pre>The above example defines a transition on the 'opacity' property of 2 seconds duration, a
193 transition on the 'left' property of 1
194 second duration, a transition on the 'top' property of 2 seconds duration and a
195 transition on the 'width' property of 1
196 second duration.
198 </div>
200 <p>
201 While authors can use transitions to create dynamically changing content,
202 dynamically changing content can lead to seizures in some users.
203 For information on how to avoid content that can lead to seizures, see
204 <a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3:
205 Seizures:
206 Do not design content in a way that is known to cause seizures</a>
207 ([[WCAG20]]).
208 </p>
210 <span id="the-transition-property-property-">The 'transition-property' Property</span> {#transition-property-property}
211 ----------------------------------------------------------------------------------------------------------------------
213 <p>
214 The 'transition-property' property specifies the name of the CSS property to which the transition is applied.
215 </p>
216 <pre class="propdef">
217 Name: transition-property
218 Value: ''transition-property/none'' | <<single-transition-property>>#
219 Initial: ''transition-property/all''
220 Applies to: all elements, ::before and ::after pseudo elements
221 Inherited: no
222 Animatable: no
223 Percentages: N/A
224 Media: visual
225 Computed value: Same as specified value.
226 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
227 </pre>
229 <div class="prod">
230 <dfn type id="single-transition-property"><single-transition-property></dfn> = ''transition-property/all'' | <<custom-ident>>;
231 </div>
233 <p>
234 A value of
235 <dfn value for="transition-property">none</dfn>
236 means that no property will transition.
237 Otherwise, a list of properties to be transitioned, or the
238 keyword <dfn value for="transition-property">all</dfn>
239 which indicates that all properties are to be
240 transitioned, is given.
241 </p>
243 <p>
244 If one of the identifiers listed is not a recognized property
245 name or is not an animatable property, the implementation must
246 still start transitions on the animatable properties in the
247 list using the duration, delay, and timing function at their
248 respective indices in the lists for 'transition-duration',
249 'transition-delay', and 'transition-timing-function'. In other
250 words, unrecognized or non-animatable properties must be kept in
251 the list to preserve the matching of indices.
252 </p>
254 <p>
255 The <<custom-ident>> production in <<single-transition-property>>
256 also excludes the keyword ''transition-property/none'',
257 in addition to the keywords always excluded from <<custom-ident>>.
258 This means that
259 ''transition-property/none'', ''inherit'', and ''initial'' are not
260 permitted as items within a list of more that one identifier;
261 any list that uses them is syntactically invalid.
262 </p>
264 <p>
265 For the keyword ''transition-property/all'',
266 or if one of the identifiers listed is a
267 shorthand property, implementations must start transitions for
268 any of its longhand sub-properties that are animatable (or, for
269 ''transition-property/all'', all animatable properties), using the duration, delay,
270 and timing function at the index corresponding to the shorthand.
271 </p>
272 <p>
273 If a property is specified multiple times in the value of
274 'transition-property' (either on its own, via a shorthand that
275 contains it, or via the ''transition-property/all'' value), then the transition that
276 starts uses the duration, delay, and timing function at the
277 index corresponding to the <em>last</em> item in the value of
278 'transition-property' that calls for animating that property.
279 </p>
280 <p class="note">
281 Note: The ''transition-property/all'' value and 'all' shorthand
282 property work in similar ways, so the
283 ''transition-property/all'' value is just like a shorthand that
284 covers all properties.
285 </p>
287 <span id="the-transition-duration-property-">The 'transition-duration' Property</span> {#transition-duration-property}
288 ----------------------------------------------------------------------------------------------------------------------
290 <p>
291 The 'transition-duration' property defines the length of time that a transition takes.
292 </p>
293 <pre class="propdef">
294 Name: transition-duration
295 Value: <<time>>#
296 Initial: ''0s''
297 Applies to: all elements, ::before and ::after pseudo elements
298 Inherited: no
299 Animatable: no
300 Percentages: N/A
301 Media: interactive
302 Computed value: Same as specified value.
303 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
304 </pre>
305 <p>
306 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.
307 </p>
309 <span id="transition-timing-function_tag">The 'transition-timing-function' Property</span> {#transition-timing-function-property}
310 ---------------------------------------------------------------------------------------------------------------------------------
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 (<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>). 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>
449 <span id="the-transition-delay-property-">The 'transition-delay' Property</span> {#transition-delay-property}
450 -------------------------------------------------------------------------------------------------------------
452 <p>
453 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.
454 </p>
455 <p>
456 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.
457 </p>
458 <pre class="propdef">
459 Name: transition-delay
460 Value: <<time>>#
461 Initial: ''0s''
462 Applies to: all elements, ::before and ::after pseudo elements
463 Inherited: no
464 Animatable: no
465 Percentages: N/A
466 Media: interactive
467 Computed value: Same as specified value.
468 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
469 </pre>
471 <span id="the-transition-shorthand-property-">The 'transition' Shorthand Property</span> {#transition-shorthand-property}
472 -------------------------------------------------------------------------------------------------------------------------
474 <p>
475 The 'transition' shorthand property combines the four properties described above into a single property.
476 </p>
477 <pre class="propdef">
478 Name: transition
479 Value: <<single-transition>>#
480 Initial: see individual properties
481 Applies to: all elements, ::before and ::after pseudo elements
482 Inherited: no
483 Animatable: no
484 Percentages: N/A
485 Media: interactive
486 Computed value: see individual properties
487 Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
488 </pre>
490 <div class="prod">
491 <dfn type id="single-transition"><single-transition></dfn> = [ ''none'' | <<single-transition-property>> ] || <<time>> || <<single-transition-timing-function>> || <<time>>
492 </div>
494 <p>
495 Note that order is important within the items in this property:
496 the first value that can be parsed as a time is assigned to the
497 transition-duration,
498 and the second value that can be parsed as a time is assigned to
499 transition-delay.
500 </p>
502 <p>
503 If there is more than one <<single-transition>> in the shorthand,
504 and any of the transitions has
505 ''none'' as the <<single-transition-property>>,
506 then the declaration is invalid.
507 </p>
509 Starting of transitions {#starting}
510 ===================================
512 <p>
513 Implementations must maintain a set of
514 <dfn export lt="running transition">running transitions</dfn>,
515 each of which applies to a specific element and non-shorthand
516 property. Each of these transitions also has a
517 <dfn export for="transition">start time</dfn>, <dfn export for="transition">end time</dfn>,
518 <dfn export for="transition">start value</dfn>, <dfn export for="transition">end value</dfn>,
519 <dfn export for="transition">reversing-adjusted start value</dfn>, and <dfn export for="transition">reversing shortening factor</dfn>.
520 Transitions are added to this set as described in this section,
521 and are removed from this set
522 when they <a>complete</a>
523 or when implementations are required to <dfn export for="transition">cancel</dfn> them.
524 <span class="note">
525 For the rationale behind the <a>reversing-adjusted start value</a>
526 and <a>reversing shortening factor</a>, see [[#reversing]].
527 </span>
528 </p>
530 <p>
531 Implementations must also maintain a set of
532 <dfn export lt="completed transition">completed transitions</dfn>,
533 each of which
534 (like <a>running transitions</a>)
535 applies to a specific element and non-shorthand property.
536 <span class="note">
537 This specification maintains the invariant that
538 there is never both a <a>running transition</a> and
539 a <a>completed transition</a> for the same property and element.
540 </span>
541 </p>
543 <p>
544 If an element is no longer in the document,
545 implementations must remove transitions on it
546 from the <a>running transitions</a> and the
547 <a>completed transitions</a>.
548 </p>
550 <div class="note">
552 <p>
553 This set of completed transitions
554 needs to be maintained
555 in order to prevent
556 transitions from repeating themselves in certain cases,
557 i.e., to maintain the invariant
558 that this specification tries to maintain
559 that unrelated style changes do not trigger transitions.
560 </p>
562 <p class="example">
563 An example where maintaining the set of completed transitions
564 is necessary would be a transition on
565 an inherited property,
566 where the parent specifies a transition of that property for
567 a longer duration (say, ''transition: 4s text-indent'')
568 and a child element that inherits the parent's value specifies
569 a transition of the same property for a shorter duration
570 (say, ''transition: 1s text-indent'').
571 Without the maintenance of this set of completed transitions,
572 implementations could start additional transitions on the child
573 after the initial 1 second transition on the child completes.
574 </p>
576 </div>
578 <p>
579 Various things can cause the <a>computed values</a> of properties
580 on an element to change.
581 These include
582 insertion and removal of elements from the document tree
583 (which both changes whether those elements have <a>computed values</a> and
584 can change the styles of other elements through selector matching),
585 changes to the document tree that cause
586 changes to which selectors match elements,
587 changes to style sheets or style attributes,
588 and other things.
589 This specification does not define when <a>computed values</a> are updated,
590 beyond saying that implementations must not
591 use, present, or display something resulting from the CSS
592 cascading, value computation, and inheritance process [[!CSS3CASCADE]]
593 without updating the <a>computed value</a>
594 (which means merely that implementations cannot avoid
595 meeting requirements of this specification
596 by claiming not to have updated the <a>computed value</a>
597 as part of handling a style change).
598 However,
599 when an implementation updates the <a>computed value</a> of a
600 property on an element
601 to reflect one of these changes,
602 or computes the <a>computed value</a> of a property on an element
603 newly added to the document,
604 it must update the <a>computed value</a>
605 for all properties and elements to reflect all
606 of these changes at the same time
607 (or at least it must be undetectable that it was done at a
608 different time).
609 This processing of a set of simultaneous style changes is called a
610 <dfn export>style change event</dfn>.
611 (Implementations typically have a <a>style change event</a> to
612 correspond with their desired screen refresh rate,
613 and when up-to-date computed style or layout information is needed
614 for a script API that depends on it.)
615 </p>
617 <p>
618 Since this specification does not define
619 when a <a>style change event</a> occurs,
620 and thus what changes to computed values are considered simultaneous,
621 authors should be aware that changing any of the transition
622 properties a small amount of time after making a change that
623 might transition can result in behavior that varies between
624 implementations, since the changes might be considered
625 simultaneous in some implementations but not others.
626 </p>
628 <p>
629 When a <a>style change event</a> occurs,
630 implementations must start transitions based on
631 the <a>computed values</a> that changed in that event.
632 If an element is not in the document during that
633 style change even or was not in the document during
634 the previous style change event,
635 then transitions are not started for that element
636 in that style change event.
637 Otherwise,
638 define the <dfn export>before-change style</dfn> as
639 the <a>computed values</a> of all properties on the element as of
640 the previous <a>style change event</a>,
641 except with any styles derived from declarative
642 animations such as CSS Transitions, CSS Animations
643 ([[CSS3-ANIMATIONS]]),
644 and SMIL Animations ([[SMIL-ANIMATION]], [[SVG11]])
645 updated to the current time.
646 Likewise, define the <dfn export>after-change style</dfn> as
647 the <a>computed values</a> of all properties
648 on the element based on the information
649 known at the start of that <a>style change event</a>,
650 but excluding any styles from CSS Transitions in the computation,
651 and inheriting from
652 the <a>after-change style</a> of the parent.
653 </p>
655 <div class="note">
656 <p>
657 Note that this definition of the <a>after-change style</a>
658 means that a single change
659 can start a transition on the same property
660 on both an ancestor element and its descendant element.
661 This can happen when a property change is inherited
662 from one element with 'transition-*' properties
663 that say to animate the changing property
664 to another element with 'transition-*' properties
665 that also say to animate the changing property.
666 </p>
668 <p>
669 When this happens, both transitions will run,
670 and the transition on the descendant will override
671 the transition on the ancestor
672 because of the normal
673 CSS cascading and inheritance rules ([[CSS3CASCADE]]).
674 </p>
676 <p>
677 If the transition on the descendant completes before
678 the transition on the ancestor,
679 the descendant will then resume inheriting
680 the (still transitioning) value from its parent.
681 This effect is likely not a desirable effect,
682 but it is essentially doing what the author asked for.
683 </p>
684 </div>
686 <p>
687 For each element with a <a>before-change style</a> and
688 an <a>after-change style</a>,
689 and each property (other than shorthands),
690 define the <dfn export>matching transition-property value</dfn> as
691 the last value in the
692 'transition-property' in the element's <a>after-change style</a>
693 that matches the property,
694 as described in
695 [[#transition-property-property]].
696 If there is such a value, then corresponding to it, there is
697 a <dfn export>matching transition duration</dfn>,
698 a <dfn export>matching transition delay</dfn>, and
699 a <dfn export>matching transition timing function</dfn>
700 in the values in the <a>after-change style</a> of
701 'transition-duration', 'transition-delay', and 'transition-timing-function'
702 (see <a href="#list-matching">the rules on matching lists</a>).
703 Define the <dfn export for="transition">combined duration</dfn> of the transition
704 as the sum of max(<a>matching transition duration</a>, ''0s'') and
705 the <a>matching transition delay</a>.
706 For each element and property, the implementation must act
707 as follows:
708 </p>
710 <ol>
711 <li>
712 If all of the following are true:
713 <ul>
714 <li>
715 the element does not have
716 a <a>running transition</a> for the property,
717 </li>
718 <li>
719 the <a>before-change style</a> is different from
720 and can be interpolated with
721 the <a>after-change style</a> for that property,
722 </li>
723 <li>
724 the element does not have a <a>completed transition</a>
725 for the property
726 or the <a>end value</a> of the <a>completed transition</a>
727 is different from the <a>after-change style</a> for the property,
728 </li>
729 <li>
730 there is a <a>matching transition-property value</a>, and
731 </li>
732 <li>
733 the <a>combined duration</a> is greater than ''0s'',
734 </li>
735 </ul>
736 then implementations must
737 remove the <a>completed transition</a> (if present) from the set
738 of completed transitions and
739 start a transition whose:
740 <ul>
741 <li>
742 <a>start time</a> is
743 the time of the <a>style change event</a> plus
744 the <a>matching transition delay</a>,
745 </li>
746 <li>
747 <a>end time</a> is
748 the <a>start time</a> plus
749 the <a>matching transition duration</a>,
750 </li>
751 <li>
752 <a>start value</a> is
753 the value of the transitioning property
754 in the <a>before-change style</a>,
755 </li>
756 <li>
757 <a>end value</a> is
758 the value of the transitioning property
759 in the <a>after-change style</a>,
760 </li>
761 <li>
762 <a>reversing-adjusted start value</a> is the same as
763 the <a>start value</a>, and
764 <li>
765 <a>reversing shortening factor</a> is 1.
766 </li>
767 </ul>
768 </li>
769 <li>
770 Otherwise,
771 if the element has a <a>completed transition</a> for the property
772 and the <a>end value</a> of the <a>completed transition</a>
773 is different from the <a>after-change style</a> for the property,
774 then implementations must
775 remove the <a>completed transition</a> from the set of
776 <a>completed transitions</a>.
777 </li>
778 <li>
779 If the element has a <a>running transition</a> or
780 <a>completed transition</a> for the property,
781 and there is <strong>not</strong>
782 a <a>matching transition-property value</a>,
783 then implementations must
784 <a>cancel</a> the <a>running transition</a>
785 or remove the <a>completed transition</a> from the set of
786 <a>completed transitions</a>.
787 </li>
788 <li>
789 If the element has a <a>running transition</a> for the property,
790 there is a <a>matching transition-property value</a>,
791 and the <a>end value</a> of the <a>running transition</a> is
792 <strong>not</strong> equal to the value of the property in the
793 <a>after-change style</a>, then:
794 <ol>
795 <li>
796 If the <a>current value</a> of the property
797 in the <a>running transition</a>
798 is equal to
799 the value of the property in the <a>after-change style</a>,
800 or if these two values cannot be interpolated,
801 then implementations must
802 <a>cancel</a> the <a>running transition</a>.
803 </li>
804 <li>
805 Otherwise, if the <a>combined duration</a> is
806 less than or equal to ''0s'',
807 or if the
808 <a>current value</a> of the property in the <a>running transition</a>
809 cannot be interpolated with
810 the value of the property in the <a>after-change style</a>,
811 then implementations must
812 <a>cancel</a> the <a>running transition</a>.
813 </li>
814 <li>
815 Otherwise, if the <a>reversing-adjusted start value</a>
816 of the <a>running transition</a> is the same as the value of
817 the property in the <a>after-change style</a>
818 <span class="note">(see the
819 <a href="#reversing">section on reversing of
820 transitions</a> for why these case exists)</span>,
821 implementations must
822 <a>cancel</a> the <a>running transition</a> and
823 start a new transition whose:
824 <ul>
825 <li>
826 <a>reversing-adjusted start value</a> is
827 the <a>end value</a> of the
828 <a>running transition</a>
829 <span class="note">(Note: This represents the logical start state of
830 the transition, and allows some calculations to ignore that
831 the transition started before that state was reached, which
832 in turn allows repeated reversals of the same transition to
833 work correctly),</span>
834 <li>
835 <a>reversing shortening factor</a>
836 is the absolute value, clamped to the range [0, 1],
837 of the sum of:
838 <ol>
839 <li>the output of the timing function of the old transition
840 at the time of the <a>style change event</a>,
841 times the <a>reversing shortening factor</a> of the
842 old transition</li>
843 <li>1 minus the <a>reversing shortening factor</a> of
844 the old transition.</li>
845 </ol>
846 <span class="note">Note: This represents the portion of the
847 space between the <a>reversing-adjusted start value</a>
848 and the <a>end value</a> that the old transition has
849 traversed (in amounts of the value, not time), except with the
850 absolute value and clamping to handle timing functions that
851 have y1 or y2 outside the range [0, 1].</span>
852 </li>
853 <li>
854 <a>start time</a> is
855 the time of the <a>style change event</a> plus:
856 <ol>
857 <li>if the <a>matching transition delay</a>
858 is nonnegative,
859 the <a>matching transition delay</a>, or
860 <li>if the <a>matching transition delay</a>
861 is negative,
862 the product of
863 the new transition's
864 <a>reversing shortening factor</a> and
865 the <a>matching transition delay</a>,
866 </ol>
867 </li>
868 <li>
869 <a>end time</a> is
870 the <a>start time</a> plus the product of
871 the <a>matching transition duration</a> and
872 the new transition's <a>reversing shortening factor</a>,
873 </li>
874 <li>
875 <a>start value</a> is
876 the <a>current value</a> of the property
877 in the <a>running transition</a>,
878 </li>
879 <li>
880 <a>end value</a> is
881 the value of the property
882 in the <a>after-change style</a>,
883 </li>
884 </ul>
885 </li>
886 <li>
887 Otherwise, implementations must
888 <a>cancel</a> the <a>running transition</a>
889 and start a new transition whose:
890 <ul>
891 <li>
892 <a>start time</a> is
893 the time of the <a>style change event</a> plus
894 the <a>matching transition delay</a>,
895 </li>
896 <li>
897 <a>end time</a> is
898 the <a>start time</a> plus
899 the <a>matching transition duration</a>,
900 </li>
901 <li>
902 <a>start value</a> is
903 the <a>current value</a> of the property
904 in the <a>running transition</a>,
905 </li>
906 <li>
907 <a>end value</a> is
908 the value of the property
909 in the <a>after-change style</a>,
910 </li>
911 <li>
912 <a>reversing-adjusted start value</a> is the same as
913 the <a>start value</a>, and
914 <li>
915 <a>reversing shortening factor</a> is 1.
916 </li>
917 </ul>
918 </li>
919 </ol>
920 </li>
922 </ol>
924 <div class="note">
925 <p>
926 Note that the above rules mean that
927 when the computed value of an animatable property changes,
928 the transitions that start are based on the
929 values of the 'transition-property', 'transition-duration',
930 'transition-timing-function', and 'transition-delay' properties
931 at the time the animatable property would first have its new
932 computed value.
933 This means that when one of these 'transition-*' properties
934 changes at the same time as
935 a property whose change might transition,
936 it is the <em>new</em> values of the 'transition-*' properties
937 that control the transition.
938 </p>
939 <div class="example" id="manual-reversing-example">
940 <p style="display:none">
941 Example(s):
942 </p>
943 <p>This provides a way for authors to specify different values
944 of the 'transition-*' properties for the “forward”
945 and “reverse” transitions,
946 when the transitions are between two states
947 (but see <a
948 href="#reversing">below</a> for special reversing behavior when
949 an <em>incomplete</em> transition is interrupted). Authors can
950 specify the value of 'transition-duration',
951 'transition-timing-function', or 'transition-delay' in the same
952 rule where they specify the value that triggers the transition,
953 or can change these properties at the same time as they change
954 the property that triggers the transition. Since it's the new
955 values of these 'transition-*' properties that affect the
956 transition, these values will be used for the transitions
957 <em>to</em> the associated transitioning values. For example:
958 </p>
959 <pre>
960 li {
961 transition: background-color linear 1s;
962 background: blue;
963 }
964 li:hover {
965 background-color: green;
966 transition-duration: 2s; /* applies to the transition *to* the :hover state */
967 }</pre>
968 <p>
969 When a list item with these style rules enters the :hover
970 state, the computed 'transition-duration' at the time that
971 'background-color' would have its new value (''green'') is ''2s'',
972 so the transition from ''blue'' to ''green'' takes 2 seconds.
973 However, when the list item leaves the :hover state, the
974 transition from ''green'' to ''blue'' takes 1 second.
975 </p>
976 </div>
977 </div>
979 <p class="note">
980 Note that once the transition of a property has started
981 (including being in its delay phase),
982 it continues running based on
983 the original timing function, duration, and
984 delay, even if the 'transition-timing-function',
985 'transition-duration', or 'transition-delay' property changes
986 before the transition is complete. However, if the
987 'transition-property' property changes such that the transition
988 would not have started, the transition stops (and the
989 property immediately changes to its final value).
990 </p>
992 <p class="note">
993 Note that above rules mean that
994 transitions do not start when the computed
995 value of a property changes as a result of declarative animation
996 (as opposed to scripted animation).
997 This happens because the before-change style includes up-to-date
998 style for declarative animations.
999 </p>
1001 Faster reversing of interrupted transitions {#reversing}
1002 --------------------------------------------------------
1004 <div class="note">
1006 <p>
1007 Many common transitions effects involve transitions between two states,
1008 such as the transition that occurs when the mouse pointer moves
1009 over a user interface element, and then later moves out of that element.
1010 With these effects, it is common for a running transition
1011 to be interrupted before it completes,
1012 and the property reset to the starting value of that transition.
1013 An example is a hover effect on an element,
1014 where a transition starts when the pointer enters the element,
1015 and then the pointer exits the element before the effect has completed.
1016 If the outgoing and incoming transitions
1017 are executed using their specified durations and timing functions,
1018 the resulting effect can be distractingly asymmetric
1019 because the second transition
1020 takes the full specified time to move a shortened distance.
1021 Instead, this specification makes second transition shorter.
1022 </p>
1024 <p>
1025 The mechanism the above rules use to cause this involves the
1026 <a>reversing shortening factor</a> and the
1027 <a>reversing-adjusted start value</a>.
1028 In particular, the reversing behavior is present whenever
1029 the <a>reversing shortening factor</a> is less than 1.
1030 </p>
1032 <p class="note">
1033 Note that these rules do not fully address the problem for
1034 transition patterns that involve more than two states.
1035 </p>
1037 <p class="note">
1038 Note that these rules lead to the entire timing function of the
1039 new transition being used, rather than jumping into the middle
1040 of a timing function, which can create a jarring effect.
1041 </p>
1043 <p class="note">
1044 This was one of several possibilities that was considered by the
1045 working group. See the
1046 <a href="transition-reversing-demo">reversing demo</a>
1047 demonstrating a number of them, leading to a working group
1048 resolution made on 2013-06-07 and edits made on 2013-11-11.
1049 </p>
1051 </div>
1053 Application of transitions {#application}
1054 =========================================
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 Completion of transitions {#complete}
1115 =====================================
1117 <p>
1118 <a>Running transitions</a>
1119 <dfn export for="transition" id="dfn-complete">complete</dfn>
1120 at a time that equal to or after their end time,
1121 but prior to to the first <a>style change event</a>
1122 whose time is equal to or after their <a>end time</a>.
1123 When a transition completes,
1124 implementations must move
1125 all transitions that complete at that time
1126 from the set of <a>running transitions</a>
1127 to the set of <a>completed transitions</a>
1128 and then fire the <a href="#transition-events">events</a>
1129 for those completions.
1130 <span class="note">(Note that doing otherwise, that is,
1131 firing some of the events before doing all of the moving
1132 from <a>running transitions</a> to <a>completed transitions</a>,
1133 could allow
1134 a style change event to happen
1135 without the necessary transitions completing,
1136 since firing the event could cause a style change event,
1137 if an event handler requests up-to-date computed style or
1138 layout data.)</span>
1139 </p>
1141 <span id="transition-events-">Transition Events</span> {#transition-events}
1142 ===========================================================================
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 <span id="animation-of-property-types-">Animation of property types</span> {#animatable-types}
1248 ==============================================================================================
1250 <p>
1251 Some property types can be interpolated,
1252 which means they can animate smoothly from one value to another.
1253 Other property types cannot, and thus animate only in a single
1254 step from one value to the other.
1255 </p>
1257 Animation of interpolated property types {#interpolated-types}
1258 --------------------------------------------------------------
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 Animation in steps of other property types {#step-types}
1406 --------------------------------------------------------
1408 <p>
1409 When interpolating between two values that cannot be interpolated,
1410 <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>,
1411 interpolation is done using the output <var>p</var> of the timing function.
1412 If <var>p</var> is less than 0.5, then the
1413 result of the interpolation is
1414 <var>V</var><sub>start</sub>;
1415 if <var>p</var> is greater than or equal to 0.5, then the
1416 result of the interpolation is
1417 <var>V</var><sub>end</sub>.
1418 </p>
1420 <p class="note" id="discrete-interpolation-at-risk">
1421 This is a recent change to which implementations have
1422 not yet updated. (Prior to the change CSS Transitions
1423 and CSS Animations did not run on such changes.) It's
1424 possible that it won't be compatible with existing Web content.
1425 If that is the case, the problem may be mitigated by restricting
1426 this behavior only to CSS Animations (and not to CSS Transitions),
1427 and/or restricting it to step timing functions.
1428 </p>
1430 <span id="animatable-properties-">Animatable properties</span> {#animatable-properties}
1431 =======================================================================================
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 <span id="properties-from-css-">Properties from CSS</span> {#animatable-css}
1481 ----------------------------------------------------------------------------
1483 <p>
1484 The following definitions define the animation behavior for
1485 properties in CSS Level 2 Revision 1 ([[CSS21]]) and in Level 3 of
1486 the CSS Color Module ([[CSS3COLOR]]).
1487 </p>
1489 <table class="animatable-properties">
1490 <tr>
1491 <th>Property Name</th>
1492 <th>Type</th>
1493 </tr>
1494 <tr>
1495 <td>'background-color'</td><td>as <a href="#animtype-color">color</a></tr>
1496 <tr>
1497 <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>
1498 </tr>
1499 <tr>
1500 <td>'border-bottom-color'</td><td>as <a href="#animtype-color">color</a></td>
1501 </tr>
1502 <tr>
1503 <td>'border-bottom-width'</td><td>as <a href="#animtype-length">length</a></td>
1504 </tr>
1505 <tr>
1506 <td>'border-left-color'</td><td>as <a href="#animtype-color">color</a></td>
1507 </tr>
1508 <tr>
1509 <td>'border-left-width'</td><td>as <a href="#animtype-length">length</a></td>
1510 </tr>
1511 <tr>
1512 <td>'border-right-color'</td><td>as <a href="#animtype-color">color</a></td>
1513 </tr>
1514 <tr>
1515 <td>'border-right-width'</td><td>as <a href="#animtype-length">length</a></td>
1516 </tr>
1517 <tr>
1518 <td>'border-spacing'</td><td>as <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-length">length</a></td>
1519 </tr>
1520 <tr>
1521 <td>'border-top-color'</td><td>as <a href="#animtype-color">color</a></td>
1522 </tr>
1523 <tr>
1524 <td>'border-top-width'</td><td>as <a href="#animtype-length">length</a></td>
1525 </tr>
1526 <tr>
1527 <td>'bottom'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1528 </tr>
1529 <tr>
1530 <td>'clip'</td><td>as <a href="#animtype-rect">rectangle</a></td>
1531 </tr>
1532 <tr>
1533 <td>'color'</td><td>as <a href="#animtype-color">color</a></td>
1534 </tr>
1535 <tr>
1536 <td>'font-size'</td><td>as <a href="#animtype-length">length</a></td>
1537 </tr>
1538 <tr>
1539 <td>'font-weight!!property'</td><td>as <a href="#animtype-font-weight">font weight</a></td>
1540 </tr>
1541 <tr>
1542 <td>'height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1543 </tr>
1544 <tr>
1545 <td>'left'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1546 </tr>
1547 <tr>
1548 <td>'letter-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1549 </tr>
1550 <tr>
1551 <td>'line-height'</td><td>as either <a href="#animtype-number">number</a> or <a href="#animtype-length">length</a></td>
1552 </tr>
1553 <tr>
1554 <td>'margin-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1555 </tr>
1556 <tr>
1557 <td>'margin-left'</td><td>as <a href="#animtype-length">length</a></td>
1558 </tr>
1559 <tr>
1560 <td>'margin-right'</td><td>as <a href="#animtype-length">length</a></td>
1561 </tr>
1562 <tr>
1563 <td>'margin-top'</td><td>as <a href="#animtype-length">length</a></td>
1564 </tr>
1565 <tr>
1566 <td>'max-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1567 </tr>
1568 <tr>
1569 <td>'max-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1570 </tr>
1571 <tr>
1572 <td>'min-height'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1573 </tr>
1574 <tr>
1575 <td>'min-width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1576 </tr>
1577 <tr>
1578 <td>'opacity'</td><td>as <a href="#animtype-number">number</a></td>
1579 </tr>
1580 <tr>
1581 <td>'outline-color'</td><td>as <a href="#animtype-color">color</a></td>
1582 </tr>
1583 <tr>
1584 <td>'outline-width'</td><td>as <a href="#animtype-length">length</a></td>
1585 </tr>
1586 <tr>
1587 <td>'padding-bottom'</td><td>as <a href="#animtype-length">length</a></td>
1588 </tr>
1589 <tr>
1590 <td>'padding-left'</td><td>as <a href="#animtype-length">length</a></td>
1591 </tr>
1592 <tr>
1593 <td>'padding-right'</td><td>as <a href="#animtype-length">length</a></td>
1594 </tr>
1595 <tr>
1596 <td>'padding-top'</td><td>as <a href="#animtype-length">length</a></td>
1597 </tr>
1598 <tr>
1599 <td>'right'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1600 </tr>
1601 <tr>
1602 <td>'text-indent'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1603 </tr>
1604 <tr>
1605 <td>'text-shadow'</td><td>as <a href="#animtype-shadow-list">shadow list</a></td>
1606 </tr>
1607 <tr>
1608 <td>'top'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1609 </tr>
1610 <tr>
1611 <td>'vertical-align'</td><td>as <a href="#animtype-length">length</a></td>
1612 </tr>
1613 <tr>
1614 <td>'visibility'</td><td>as <a href="#animtype-visibility">visibility</a></td>
1615 </tr>
1616 <tr>
1617 <td>'width'</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td>
1618 </tr>
1619 <tr>
1620 <td>'word-spacing'</td><td>as <a href="#animtype-length">length</a></td>
1621 </tr>
1622 <tr>
1623 <td>'z-index'</td><td>as <a href="#animtype-integer">integer</a></td>
1624 </tr>
1625 </table>
1627 <span id="properties-from-svg-">Properties from SVG</span> {#animatable-svg}
1628 ----------------------------------------------------------------------------
1630 <p>
1631 All properties defined as animatable in the SVG specification, provided
1632 they are one of the property types listed above.
1633 </p>
1635 <!-- <table>
1636 <tr>
1637 <th>Property Name</th><th>Type</th>
1638 </tr>
1639 <tr>
1640 <td>stop-color</td><td>as <a href="#animtype-color">color</a></td>
1641 </tr>
1642 <tr>
1643 <td>stop-opacity</td><td>as <a href="#animtype-number">number</a></td>
1644 </tr>
1645 <tr>
1646 <td>fill</td><td>as <a href="#animtype-paintserver">paint server</a></td>
1647 </tr>
1648 <tr>
1649 <td>fill-opacity</td><td>as <a href="#animtype-number">number</a></td>
1650 </tr>
1651 <tr>
1652 <td>stroke</td><td>as <a href="#animtype-paintserver">paint server</a></td>
1653 </tr>
1654 <tr>
1655 <td>stroke-dasharray</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-number">number</a></td>
1656 </tr>
1657 <tr>
1658 <td>stroke-dashoffset</td><td>as <a href="#animtype-number">number</a></td>
1659 </tr>
1660 <tr>
1661 <td>stroke-miterlimit</td><td>as <a href="#animtype-number">number</a></td>
1662 </tr>
1663 <tr>
1664 <td>stroke-opacity</td><td>as <a href="#animtype-number">number</a></td>
1665 </tr>
1666 <tr>
1667 <td>stroke-width</td><td>as <a href="#animtype-number">number</a></td>
1668 </tr>
1669 <tr>
1670 <td>viewport-fill</td><td>as <a href="#animtype-color">color</a></td>
1671 </tr>
1672 <tr>
1673 <td>viewport-fill-opacity</td><td>as <a href="#animtype-color">color</a></td>
1674 </tr>
1675 </table> -->
1677 Security Considerations {#security}
1678 ===================================
1680 <em>This section is not normative.</em>
1682 The security implications of this specification are limited
1683 because it doesn't allow Web content to do things
1684 that it could not do before.
1685 Rather, it allows things that could previously be done with script
1686 to be done declaratively,
1687 and it ways that implementations can optimize (for frame rate and
1688 CPU usage).
1690 One of the major categories of optimizations
1691 that implementations can make is implementing animation
1692 of certain high-value properties (such as 'transform' and 'opacity')
1693 run on a browser's compositor thread or process
1694 without updating style or layout on the main Web content thread
1695 unless up-to-date style data are needed.
1696 This optimization often requires allocations of graphics memory
1697 to display the contents of the element being animated.
1698 Implementations should take care to ensure that Web content
1699 cannot trigger unsafe out-of-memory handling
1700 by using large numbers of animations
1701 or animations on elements covering large areas
1702 (where large may be defined in terms of pre-transform or post-transform size).
1704 Privacy Considerations {#privacy}
1705 =================================
1707 <em>This section is not normative.</em>
1709 As for security, the privacy considerations of this specification are limited
1710 because it does not allow Web content to do things that it could not do before.
1712 This specification may provide additional mechanisms that help to determine
1713 characteristics of the user's hardware or software.
1714 However, ability to determine performance characteristics of the user's
1715 hardware or software is common to many Web technologies,
1716 and this specification does not introduce new capabilities.
1718 As described in [[#accessibility]],
1719 implementations may provide mitigations to help users with disabilities.
1720 These mitigations are likely to be detectable by Web content,
1721 which means that users who would benefit from these mitigations
1722 may face a tradeoff between keeping their disability private from
1723 the Web content or benefiting from the mitigation.
1725 Accessibility Considerations {#accessibility}
1726 =============================================
1728 <em>This section is not normative.</em>
1730 Motion {#accessibility-motion}
1731 ------------------------------
1733 This specification provides declarative mechanisms for animations
1734 that previously needed to be done using script.
1735 Providing a declarative mechanism has multiple effects:
1736 it makes such animations easier to make and thus likely to be more common,
1737 but it also makes it easier for user agents to modify those animations
1738 if such modifications are needed to meet a user's accessibility needs.
1740 Thus, users who are sensitive to movement,
1741 or who require additional time to read or understand content,
1742 may benefit from user agent features that allow
1743 animations to be disabled or slowed down.
1744 (But see [[#privacy]] for information on the privacy implications
1745 of such mitigations.)
1747 User agent implementors should be aware that Web content
1748 may depend on the firing of <a href="#transition-events">transition events</a>,
1749 so implementations of such mitigations may wish to fire transition events
1750 even if the transitions were not run as continuous animations.
1751 However, it is probably poor practice for Web content to depend on
1752 such events to function correctly.
1754 Cascade {#accessibility-cascade}
1755 --------------------------------
1757 The CSS <a>cascade</a> is a general mechanism in CSS
1758 that allows user needs to interact with author styles.
1759 This specification interacts with the cascade,
1760 but since it only allows animation between values
1761 that result from the existing cascade rules,
1762 it does not interfere with the user's ability to force
1763 CSS properties to have particular values.
1765 The cascade also allows users to disable transitions entirely
1766 by overriding the transition properties.
1769 Changes since Working Draft of 19 November 2013 {#changes}
1770 ==========================================================
1772 <p>The following are the substantive changes made since the
1773 <a href="https://www.w3.org/TR/2013/WD-css3-transitions-20131119/">Working Draft
1774 dated 19 November 2013</a>:</p>
1776 <ul>
1777 <li>Values that cannot be interpolated are transitioned when the timing function crosses its midpoint, instead of not running transitions and changing immediately.</li>
1778 <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>
1779 <li>Completion of transitions is defined somewhat more precisely.</li>
1780 <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>
1781 <li>The interpolation of ''shadow/inset'' values on shadow lists is no longer backwards.</li>
1782 <li>A [[#conformance]] section, [[#security]] section, [[#privacy]] section, [[#accessibility]] section, and [[#idl-index]] have been added</li>
1783 <li>The identifiers accepted by 'transition-property' are defined in terms of <<custom-ident>>.</li>
1784 <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>
1785 </ul>
1787 <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>
1789 <p>For changes in earlier working drafts:</p>
1791 <ol>
1792 <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>
1793 <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
1794 <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>.
1795 </ol>
1797 Acknowledgments {#acknowledgments}
1798 ==================================
1800 <p>Thanks especially to the feedback from
1801 Tab Atkins,
1802 Carine Bournez,
1803 Aryeh Gregor,
1804 Vincent Hardy,
1805 Anne van Kesteren,
1806 Cameron McCormack,
1807 Alex Mogilevsky,
1808 Jasper St. Pierre,
1809 Estelle Weyl,
1810 and all the rest of the
1811 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>