Thu, 29 Mar 2012 13:08:32 -0700
Fix markup validation errors and warnings.
1 <!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
2 'http://www.w3.org/TR/html4/strict.dtd'>
4 <html lang="en">
5 <head>
6 <title>CSS Transitions</title>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
8 <link rel="stylesheet" type="text/css" href="../default.css">
9 <style type="text/css">
10 table.animatable-properties {
11 border-collapse: collapse;
12 }
13 table.animatable-properties td {
14 padding: 0.2em 1em;
15 border: 1px solid black;
16 }
17 </style>
18 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
19 </head>
21 <body>
23 <div class="head">
24 <!--logo-->
26 <h1>CSS Transitions</h1>
28 <h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
29 <dl>
30 <dt>This version:
31 <dd>
32 <a href="[VERSION]">
33 http://dev.w3.org/csswg/css3-transitions/</a>
34 <!--http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]-->
35 <dt>Latest version:
36 <dd><a href="http://www.w3.org/TR/css3-transitions">
37 [LATEST]</a>
38 <dt>Editor's draft:
39 <dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
40 <dt>Previous version:
41 <dd><a href="http://www.w3.org/TR/2009/WD-css3-transitions-20091201/">
42 http://www.w3.org/TR/2009/WD-css3-transitions-20091201/</a>
43 <dt id="editors-list">Editors:
44 <dd><a href="mailto:dino@apple.com">Dean Jackson</a> (<a
45 href="http://www.apple.com/">Apple Inc</a>)
46 <dd><a href="mailto:hyatt@apple.com">David Hyatt</a> (<a
47 href="http://www.apple.com/">Apple Inc</a>)
48 <dd><a href="mailto:cmarrin@apple.com">Chris Marrin</a> (<a
49 href="http://www.apple.com/">Apple Inc</a>)
50 <dd class=vcard><a class=fn href="http://dbaron.org/">L. David Baron</a> (<a
51 class=org href="http://www.mozilla.com/">Mozilla</a>)
53 <dt>Issues list:
54 <dd><a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transitions&resolution=---&cmdtype=doit">in Bugzilla</a>
56 <dt>Discussion:</dt>
57 <dd><a href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a> with subject line “<kbd>[[SHORTNAME]] <var>… message topic …</var></kbd>”
59 <dt>Test suite:
60 <dd>none yet
61 </dl>
63 <!--copyright-->
65 <hr title="Separator for header">
66 </div>
68 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
70 <p>CSS Transitions allows property changes in CSS values to occur smoothly
71 over a specified duration.
73 <h2 class="no-num no-toc" id="status">Status of this document</h2>
74 <!--status-->
76 <p>
77 The <a href="ChangeLog">list of changes made to this specification</a> is
78 available.
79 </p>
81 <h2 class="no-num no-toc" id="contents">Table of contents</h2>
82 <!--toc-->
85 <h2 id="introduction">Introduction</h2>
87 <p><em>This section is not normative.</em>
88 <p>
89 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.
90 </p>
92 <h2 id="transitions">Transitions</h2>
93 <p>
94 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.
95 </p>
96 <p>
97 For example, suppose that transitions of one second have been defined on the <code class="property">'left'</code> and
98 <code class="property">'background-color'</code> properties. The following diagram illustrates the effect of updating those properties on an element, in this case moving it to the right and changing the background from red to blue. This assumes other transition parameters still have their default values.
99 </p>
100 <div class="figure">
101 <img src="transition1.png" alt="">
102 </div>
103 <p class="caption">
104 Transitions of <code class="property">'left'</code> and <code class="property">'background-color'</code>
105 </p>
106 <p>
107 Transitions are a presentational effect. The computed value of a property transitions over time from the old value to the new value. Therefore if a script queries the computed style of a property as it is transitioning, it will see an intermediate value that represents the current animated value of the property.
108 </p>
109 <p>
110 Only animatable CSS properties can be transitioned. See the table at the end of this document for a list
111 of properties that are animatable.
112 </p>
113 <p>
114 The transition for a property is defined using a number of new properties. For example:
115 </p>
116 <div class="example">
117 <p style="display:none">
118 Example(s):
119 </p>
120 <pre>
121 div {
122 transition-property: opacity;
123 transition-duration: 2s;
124 }
125 </pre>The above example defines a transition on the <code class="property">'opacity'</code> property that, when a new value is assigned to it, will cause a smooth change between the old value and the new value over a period of two seconds.
126 </div>
127 <p>
128 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:
129 </p>
130 <div class="example">
131 <p style="display:none">
132 Example(s):
133 </p>
134 <pre>
135 div {
136 transition-property: opacity, left;
137 transition-duration: 2s, 4s;
138 }
140 </pre>This will cause the <code class="property">'opacity'</code> property to transition over a period of two seconds and the left property to transition over a period of four seconds.
141 </div>
143 <p id="list-matching">
144 In the case where the lists of values in transition properties
145 do not have the same length, the length of the
146 'transition-property' list determines the number of items in
147 each list examined when starting transitions. The lists are
148 matched up from the first value: excess values at the end are
149 not used. If one of the other properties doesn't have enough
150 comma-separated values to match the number of values of
151 'transition-property', the UA must calculate its used value by
152 repeating the list of values until there are enough. This
153 truncation or repetition does not affect the computed value.
154 <span class="note">
155 Note: This is analogous to the behavior of the 'background-*'
156 properties, with 'background-image' analogous to
157 'transition-property'.
158 </span>
159 </p>
161 <div class="example">
162 <p style="display:none">
163 Example(s):
164 </p>
165 <pre>
166 div {
167 transition-property: opacity, left, top, width;
168 transition-duration: 2s, 1s;
169 }
170 </pre>The above example defines a transition on the <code class="property">'opacity'</code> property of 2 seconds duration, a
171 transition on the <code class="property">'left'</code> property of 1
172 second duration, a transition on the <code class="property">'top'</code> property of 2 seconds duration and a
173 transition on the <code class="property">'width'</code> property of 1
174 second duration.
176 </div>
178 <!-- ======================================================================================================= -->
179 <h3>
180 The <code class="property">'transition-property'</code> Property
181 </h3>
182 <p>
183 The <code class="property">'transition-property'</code> property specifies the name of the CSS property to which the transition is applied.
184 </p>
185 <div class="issue">
186 We may ultimately want to support a keypath syntax for this property. A keypath syntax would enable different transitions to be specified for components of a property. For example the blur of a shadow could have a different transition than the color of a shadow.
187 </div>
188 <table class="propdef">
189 <tbody>
190 <tr>
191 <td>
192 <em>Name:</em>
193 </td>
194 <td>
195 <dfn id="transition-property">transition-property</dfn>
196 </td>
197 </tr>
198 <tr>
199 <td>
200 <em>Value:</em>
201 </td>
202 <td>
203 none | [ all | <IDENT> ] [ ',' [ all | <IDENT> ] ]*
204 </td>
205 </tr>
206 <tr>
207 <td>
208 <em>Initial:</em>
209 </td>
210 <td>
211 all
212 </td>
213 </tr>
214 <tr>
215 <td>
216 <em>Applies to:</em>
217 </td>
218 <td>
219 all elements, :before and :after pseudo elements
220 </td>
221 </tr>
222 <tr>
223 <td>
224 <em>Inherited:</em>
225 </td>
226 <td>
227 no
228 </td>
229 </tr>
230 <tr>
231 <td>
232 <em>Percentages:</em>
233 </td>
234 <td>
235 N/A
236 </td>
237 </tr>
238 <tr>
239 <td>
240 <em>Media:</em>
241 </td>
242 <td>
243 visual
244 </td>
245 </tr>
246 <tr>
247 <td>
248 <em>Computed value:</em>
249 </td>
250 <td>
251 Same as specified value.
252 </td>
253 </tr>
254 </tbody>
255 </table>
257 <p>
258 A value of 'none' means that no property will transition.
259 Otherwise, a list of properties to be transitioned, or the
260 keyword 'all' which indicates that all properties are to be
261 transitioned, is given.
262 </p>
264 <p>
265 If one of the identifiers listed is not a recognized property
266 name or is not an animatable property, the implementation must
267 still start transitions on the animatable properties in the
268 list using the duration, delay, and timing function at their
269 respective indices in the lists for 'transition-duration',
270 'transition-delay', and 'transition-timing-function'. In other
271 words, unrecognized or non-animatable properties must be kept in
272 the list to preserve the matching of indices.
273 </p>
274 <p class="issue">
275 Are 'none', 'inherit', and 'initial' allowed as items in
276 a list of identifiers (of length greater than one)?
277 </p>
278 <p>
279 For the keyword 'all', or if one of the identifiers listed is a
280 shorthand property, implementations must start transitions for
281 any of its longhand sub-properties that are animatable (or, for
282 'all', all animatable properties), using the duration, delay,
283 and timing function at the index corresponding to the shorthand.
284 </p>
285 <p>
286 If a property is specified multiple times in the value of
287 'transition-property' (either on its own, via a shorthand that
288 contains it, or via the 'all' value), then the transition that
289 starts uses the duration, delay, and timing function at the
290 index corresponding to the <em>last</em> item in the value of
291 'transition-property' that calls for animating that property.
292 </p>
293 <p class="note">
294 Note: The <code class="property">all</code> value and shorthand
295 properties work in similar ways, so the <code
296 class="property">all</code> value is just like a shorthand that
297 covers all properties.
298 </p>
300 <!-- ======================================================================================================= -->
301 <h3>
302 The <code class="property">'transition-duration'</code> Property
303 </h3>
304 <p>
305 The <code class="property">'transition-duration'</code> property defines the length of time that a transition takes.
306 </p>
307 <table class="propdef">
308 <tbody>
309 <tr>
310 <td>
311 <em>Name:</em>
312 </td>
313 <td>
314 <dfn id="transition-duration">transition-duration</dfn>
315 </td>
316 </tr>
317 <tr>
318 <td>
319 <em>Value:</em>
320 </td>
321 <td>
322 <time> [, <time>]*
323 </td>
324 </tr>
325 <tr>
326 <td>
327 <em>Initial:</em>
328 </td>
329 <td>
330 0s
331 </td>
332 </tr>
333 <tr>
334 <td>
335 <em>Applies to:</em>
336 </td>
337 <td>
338 all elements, :before and :after pseudo elements
339 </td>
340 </tr>
341 <tr>
342 <td>
343 <em>Inherited:</em>
344 </td>
345 <td>
346 no
347 </td>
348 </tr>
349 <tr>
350 <td>
351 <em>Percentages:</em>
352 </td>
353 <td>
354 N/A
355 </td>
356 </tr>
357 <tr>
358 <td>
359 <em>Media:</em>
360 </td>
361 <td>
362 interactive
363 </td>
364 </tr>
365 <tr>
366 <td>
367 <em>Computed value:</em>
368 </td>
369 <td>
370 Same as specified value.
371 </td>
372 </tr>
373 </tbody>
374 </table>
375 <p>
376 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 <code class="property">transition-duration</code> is treated as '0s'.
377 </p>
379 <!-- =======================================================================================================
380 -->
382 <h3 id="transition-timing-function_tag">
383 The <code class="property">'transition-timing-function'</code> Property
384 </h3>
385 <p>
386 The <code class="property">'transition-timing-function'</code> property
387 describes how the intermediate values used during a transition will be
388 calculated. It allows for a transition to change speed over its
389 duration. These effects are commonly called <em>easing</em> functions.
390 In either case, a mathematical function that provides a smooth curve is
391 used.
392 </p>
393 <p>
394 Timing functions are either defined as a stepping function or
395 a <a
396 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
397 Bézier curve</a>.
398 The timing function takes as its input the current elapsed percentage of
399 the transition duration and outputs a percentage that determines how
400 close the transition is to its goal state.
401 </p>
402 <p>
403 A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a>
404 function is defined by a number that divides the domain of operation
405 into equally sized intervals. Each subsequent interval is a equal step
406 closer to the goal state. The function also specifies whether the
407 change in output percentage happens at the start or end of the
408 interval (in other words, if 0% on the input percentage is the point
409 of initial change).
410 </p>
411 <div class="figure">
412 <img src="step.png" alt="The step timing function splits
413 the function domain into a number of disjoint straight line
414 segments. steps(1, start) is a function whose
415 output value is 1 for all input values. steps(1, end) is a function whose
416 output value is 0 for all input values less than 1, and output
417 is 1 for the input value of 1. steps(3, start) is a function that
418 divides the input domain into three segments, each 1/3 in length,
419 and 1/3 above the previous segment, with the first segment starting
420 at 1/3. steps(3, end) is a function that
421 divides the input domain into three segments, each 1/3 in length,
422 and 1/3 above the previous segment, with the first segment starting
423 at 0.">
424 </div>
425 <p class="caption">
426 Step timing functions
427 </p>
428 <p>
429 A <a
430 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
431 Bézier curve</a> is defined by four control points, P<sub>0</sub>
432 through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub>
433 are always set to (0,0) and (1,1). The <code class="property">'transition-timing-function'</code> property is used
434 to specify the values for points P<sub>1</sub> and P<sub>2</sub>. These
435 can be set to preset values using the keywords listed below, or can be
436 set to specific values using the <code class="css">'cubic-bezier'</code> function.
437 In the <code class="css">'cubic-bezier'</code> function, P<sub>1</sub> and
438 P<sub>2</sub> are each specified by both an X and Y value.
439 </p>
440 <div class="figure">
441 <img src="TimingFunction.png" alt="The Bézier timing function is a
442 smooth curve from point P0 = (0,0) to point P3 = (1,1). The
443 length and orientation of the line segment P0-P1 determines
444 the tangent and the curvature of the curve at P0 and the
445 line segment P2-P3 does the same at P3.">
446 </div>
447 <p class="caption">
448 Bézier Timing Function Control Points
449 </p>
450 <table class="propdef">
451 <tbody>
452 <tr>
453 <td>
454 <em>Name:</em>
455 </td>
456 <td>
457 <dfn id="transition-timing-function">transition-timing-function</dfn>
458 </td>
459 </tr>
460 <tr>
461 <td>
462 <em>Value:</em>
463 </td>
464 <td>
465 [ ease | linear | ease-in | ease-out | ease-in-out | step-start | step-end | steps(<integer>[, [ start | end ] ]?) | cubic-bezier(<number>, <number>, <number>, <number>) ] [, [ ease | linear | ease-in | ease-out | ease-in-out | step-start | step-end | steps(<number>[, [ start | end ] ]?) | cubic-bezier(<number>, <number>, <number>, <number>) ] ]*
466 </td>
467 </tr>
468 <tr>
469 <td>
470 <em>Initial:</em>
471 </td>
472 <td>
473 ease
474 </td>
475 </tr>
476 <tr>
477 <td>
478 <em>Applies to:</em>
479 </td>
480 <td>
481 all elements, :before and :after pseudo elements
482 </td>
483 </tr>
484 <tr>
485 <td>
486 <em>Inherited:</em>
487 </td>
488 <td>
489 no
490 </td>
491 </tr>
492 <tr>
493 <td>
494 <em>Percentages:</em>
495 </td>
496 <td>
497 N/A
498 </td>
499 </tr>
500 <tr>
501 <td>
502 <em>Media:</em>
503 </td>
504 <td>
505 interactive
506 </td>
507 </tr>
508 <tr>
509 <td>
510 <em>Computed value:</em>
511 </td>
512 <td>
513 Same as specified value.
514 </td>
515 </tr>
516 </tbody>
517 </table>
518 <p>
519 The timing functions have the following definitions.
520 </p>
521 <dl>
522 <dt>
523 ease
524 </dt>
525 <dd>
526 The ease function is equivalent to cubic-bezier(0.25, 0.1, 0.25, 1.0).
527 </dd>
528 <dt>
529 linear
530 </dt>
531 <dd>
532 The linear function is equivalent to cubic-bezier(0.0, 0.0, 1.0, 1.0).
533 </dd>
534 <dt>
535 ease-in
536 </dt>
537 <dd>
538 The ease-in function is equivalent to cubic-bezier(0.42, 0, 1.0, 1.0).
539 </dd>
540 <dt>
541 ease-out
542 </dt>
543 <dd>
544 The ease-out function is equivalent to cubic-bezier(0, 0, 0.58, 1.0).
545 </dd>
546 <dt>
547 ease-in-out
548 </dt>
549 <dd>
550 The ease-in-out function is equivalent to cubic-bezier(0.42, 0, 0.58, 1.0)
551 </dd>
552 <dt>
553 step-start
554 </dt>
555 <dd>
556 The step-start function is equivalent to steps(1, start).
557 </dd>
558 <dt>
559 step-end
560 </dt>
561 <dd>
562 The step-end function is equivalent to steps(1, end).
563 </dd>
564 <dt>
565 steps
566 </dt>
567 <dd>
568 Specifies a stepping function, described above, taking two
569 parameters. The first parameter specifies the number of intervals
570 in the function. It must be a positive integer (greater than 0).
571 The second parameter, which is optional, is
572 either the value 'start' or 'end', and specifies the point
573 at which the change of values occur within the interval.
574 If the second parameter is omitted, it is given the value 'end'.
575 </dd>
576 <dt>
577 cubic-bezier
578 </dt>
579 <dd>
580 Specifies a <a
581 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier
582 curve</a>. The four values specify points P<sub>1</sub> and
583 P<sub>2</sub> of the curve as (x1, y1, x2, y2). Both x values must be
584 in the range [0, 1] or the definition is invalid. The y values can
585 exceed this range.
586 </dd>
587 </dl><!-- ======================================================================================================= -->
588 <h3>
589 The <code class="property">'transition-delay'</code> Property
590 </h3>
591 <p>
592 The <code class="property">'transition-delay'</code> 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 <code class="property">'transition-delay'</code> 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.
593 </p>
594 <p>
595 If the value for <code class="property">'transition-delay'</code> 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 <code class="property">'transition-delay'</code>, the starting values are taken from the moment the property is changed.
596 </p>
597 <table class="propdef">
598 <tbody>
599 <tr>
600 <td>
601 <em>Name:</em>
602 </td>
603 <td>
604 <dfn id="transition-delay">transition-delay</dfn>
605 </td>
606 </tr>
607 <tr>
608 <td>
609 <em>Value:</em>
610 </td>
611 <td>
612 <time> [, <time>]*
613 </td>
614 </tr>
615 <tr>
616 <td>
617 <em>Initial:</em>
618 </td>
619 <td>
620 0s
621 </td>
622 </tr>
623 <tr>
624 <td>
625 <em>Applies to:</em>
626 </td>
627 <td>
628 all elements, :before and :after pseudo elements
629 </td>
630 </tr>
631 <tr>
632 <td>
633 <em>Inherited:</em>
634 </td>
635 <td>
636 no
637 </td>
638 </tr>
639 <tr>
640 <td>
641 <em>Percentages:</em>
642 </td>
643 <td>
644 N/A
645 </td>
646 </tr>
647 <tr>
648 <td>
649 <em>Media:</em>
650 </td>
651 <td>
652 interactive
653 </td>
654 </tr>
655 <tr>
656 <td>
657 <em>Computed value:</em>
658 </td>
659 <td>
660 Same as specified value.
661 </td>
662 </tr>
663 </tbody>
664 </table><!-- ======================================================================================================= -->
665 <h3>
666 The <code class="property">'transition'</code> Shorthand Property
667 </h3>
668 <p>
669 The <code class="property">'transition'</code> shorthand property combines the four properties described above into a single property.
670 </p>
671 <p>
672 Note that order is important in this property. The first value that can be
673 parsed as a time is assigned to the transition-duration. The second value that
674 can be parsed as a time is assigned to transition-delay.
675 </p>
676 <p class="issue">
677 An alternative proposal is to accept the font shorthand approach of
678 using a "/" character between the values of the same type. e.g. 2s/4s would
679 mean a duration of 2 seconds and a delay of 4 seconds.
680 </p>
681 <table class="propdef">
682 <tbody>
683 <tr>
684 <td>
685 <em>Name:</em>
686 </td>
687 <td>
688 <dfn id="transition">transition</dfn>
689 </td>
690 </tr>
691 <tr>
692 <td>
693 <em>Value:</em>
694 </td>
695 <td>
696 [<'transition-property'> || <'transition-duration'> || <'transition-timing-function'> || <'transition-delay'> [, [<'transition-property'> || <'transition-duration'> || <'transition-timing-function'> || <'transition-delay'>]]*
697 </td>
698 </tr>
699 <tr>
700 <td>
701 <em>Initial:</em>
702 </td>
703 <td>
704 see individual properties
705 </td>
706 </tr>
707 <tr>
708 <td>
709 <em>Applies to:</em>
710 </td>
711 <td>
712 all elements, :before and :after pseudo elements
713 </td>
714 </tr>
715 <tr>
716 <td>
717 <em>Inherited:</em>
718 </td>
719 <td>
720 no
721 </td>
722 </tr>
723 <tr>
724 <td>
725 <em>Percentages:</em>
726 </td>
727 <td>
728 N/A
729 </td>
730 </tr>
731 <tr>
732 <td>
733 <em>Media:</em>
734 </td>
735 <td>
736 interactive
737 </td>
738 </tr>
739 <tr>
740 <td>
741 <em>Computed value:</em>
742 </td>
743 <td>
744 Same as specified value.
745 </td>
746 </tr>
747 </tbody>
748 </table>
750 <h2 id="starting">
751 Starting of transitions
752 </h2>
754 <p>
755 When the computed value of an animatable property changes,
756 implementations must decide what transitions to start based on
757 the values of the 'transition-property', 'transition-duration',
758 'transition-timing-function', and 'transition-delay' properties
759 at the time the animatable property would first have its new
760 computed value.
761 </p>
762 <div class="example" id="manual-reversing-example">
763 <p style="display:none">
764 Example(s):
765 </p>
766 <p>This provides a way for authors to specify different values
767 of the 'transition-*' properties for the “forward”
768 and “reverse” transitions (but see <a
769 href="#reversing">below</a> for special reversing behavior when
770 an <em>incomplete</em> transition is interrupted). Authors can
771 specify the value of 'transition-duration',
772 'transition-timing-function', or 'transition-delay' in the same
773 rule where they specify the value that triggers the transition,
774 or can change these properties at the same time as they change
775 the property that triggers the transition. Since it's the new
776 values of these 'transition-*' properties that affect the
777 transition, these values will be used for the transitions
778 <em>to</em> the associated transitioning values. For example:
779 </p>
780 <pre>li {
781 transition: background-color linear 1s;
782 background: blue;
783 }
784 li:hover {
785 background-color: green;
786 transition-duration: 2s; /* applies to the transition *to* the :hover state */
787 }</pre>
788 <p>
789 When a list item with these style rules enters the :hover
790 state, the computed 'transition-duration' at the time that
791 'background-color' would have its new value ('green') is '2s',
792 so the transition from 'blue' to 'green' takes 2 seconds.
793 However, when the list item leaves the :hover state, the
794 transition from 'green' to 'blue' takes 1 second.
795 </p>
796 </div>
798 <p>
799 When the computed value of a property changes, implementations
800 must start transitions based on the relevant item (see <a
801 href="#transition-property">the definition of
802 'transition-property'</a>) in the computed value of
803 'transition-property'. Corresponding to this item there are
804 values of 'transition-duration' and 'transition-delay' (see <a
805 href="#list-matching">the rules on matching lists</a>). Define
806 the <dfn>combined duration</dfn> of the transition as the sum of
807 max('transition-duration', '0s') and 'transition-delay'. When
808 the combined duration is greater than '0s', then a transition
809 starts based on the values of 'transition-duration',
810 'transition-delay', and 'transition-timing-function'; in other
811 cases transitions do not occur.
812 </p>
814 <p>
815 Since this specification does not define
816 when computed values change, and thus what changes to
817 computed values are considered simultaneous,
818 authors should be aware that changing any of the transition
819 properties a small amount of time after making a change that
820 might transition can result in behavior that varies between
821 implementations, since the changes might be considered
822 simultaneous in some implementations but not others.
823 </p>
824 <p class="note">Say something about simultaneity</p>
826 <p>
827 Once the transition of a property has started, it must continue
828 running based on the original timing function, duration, and
829 delay, even if the 'transition-timing-function',
830 'transition-duration', or 'transition-delay' property changes
831 before the transition is complete. However, if the
832 'transition-property' property changes such that the transition
833 would not have started, the transition must stop (and the
834 property must immediately change to its final value).
835 </p>
837 <p>
838 Implementations must not start a transition when the computed
839 value of a property changes as a result of declarative animation
840 (as opposed to scripted animation).
841 </p>
843 <p>
844 Implementations also must not start a transition when the
845 computed value changes because it is inherited (directly or
846 indirectly) from another element that is transitioning the same
847 property.
848 </p>
850 <h2 id="reversing">
851 Automatically reversing interrupted transitions
852 </h2>
853 <p>
854 A common type of transition effect is when a running transition is
855 interrupted and the property is reset to its original value. An
856 example is a hover effect on an element, where the pointer enters and
857 exits the element before the effect has completed. If the outgoing and
858 incoming transitions are executed using their specified durations and
859 timing functions, the resulting effect can be distractingly
860 asymmetric. Instead, the expected behavior is that the new transition
861 should be the reverse of what has already executed.
862 </p>
864 <p>
865 If a running transition with duration T, executing so far for duration TE,
866 from state A, to state B, is interrupted by
867 a property change that would start a new transition back to state A, and
868 all the transition attributes are the same (duration, delay and timing function),
869 then the new transition must reverse the effect. The new transition must:
870 </p>
872 <ol>
873 <li>
874 Use the B and A states as its "from" and "to" states respectively. It
875 does not use the current value as its from state, due to the rules below.
876 </li>
877 <li>
878 Execute with the same duration T, but starting as if the transition had
879 already begun, without any transition delay, at the moment which would
880 cause the new transition to finish in TE from the moment of interruption. In other
881 words, the new transition will execute as if it started T-TE in the past.
882 </li>
883 <li>
884 Use a timing function that is the portion of the curve traversed up
885 to the moment of interruption, followed in the opposite direction (towards
886 the starting point). This will make the transition appear as if it
887 is playing backwards.
888 </li>
889 <li>
890 Ignore any transition delay.
891 </li>
892 </ol>
894 <p>
895 For example, suppose there is a transition with a duration of two
896 seconds. If this transition is interrupted after 0.5 seconds and the
897 property value assigned to the original value, then the new transition
898 effect will be the reverse of the original, as if it had begun
899 1.5 seconds in the past.
900 </p>
902 <p>
903 Note that by using the defined from and to states for the reversing
904 transition, it is also possible that it may reverse again, if
905 interrupted; for example, if the transition reversing to state A was
906 again interrupted by a property change to state B.
907 </p>
909 <p class="issue">Issue:
910 This introduces the concept of reversing a timing function,
911 which the spec has otherwise resisted doing, and also introduces
912 a discontinuity between transitions that have
913 almost completed (which get automatically reversed and thus have
914 their timing function reversed) and transitions that have fully
915 completed (where the reversal doesn't lead to the timing
916 function being reversed). An alternative proposal that avoids
917 this is to follow the normal timing function algorithm, except
918 multiply the duration (and also shorten any negative delay) by
919 the (output) value of the transition timing function of the
920 incomplete transition at the time it was interrupted, and, to
921 account for multiple reverses in sequence, to divide by the
922 shortening applied to the transition being interrupted. For
923 more details see this thread:
924 <a href="http://lists.w3.org/Archives/Public/www-style/2009Nov/thread.html#msg302">November 2009 part</a>,
925 <a href="http://lists.w3.org/Archives/Public/www-style/2009Dec/thread.html#msg319">December 2009 part</a>,
926 <a href="http://lists.w3.org/Archives/Public/www-style/2010Jan/thread.html#msg136">January 2010 part</a>.
927 </p>
929 <h2>
930 Transition Events
931 </h2>
932 <p>
933 The completion of a CSS Transition generates a corresponding <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM Event</a>.
934 An event is fired for each property that undergoes a transition.
935 This allows a content developer to perform actions that synchronize
936 with the completion of a transition.
937 </p>
938 <p>
939 Each event provides the name of the property the transition is
940 associated with as well as the duration of the transition.
941 </p>
942 <dl>
943 <dt>
944 <b>Interface <i><a id="Events-TransitionEvent" name='Events-TransitionEvent'>TransitionEvent</a></i></b>
945 </dt>
946 <dd>
947 <p>
948 The <code>TransitionEvent</code> interface provides specific contextual information associated with transitions.
949 </p>
950 <dl>
951 <dt>
952 <b>IDL Definition</b>
953 </dt>
954 <dd>
955 <div class='idl-code'>
956 <pre>
957 interface TransitionEvent : Event {
958 readonly attribute DOMString propertyName;
959 readonly attribute float elapsedTime;
960 readonly attribute DOMString pseudoElement;
961 void initTransitionEvent(in DOMString typeArg,
962 in boolean canBubbleArg,
963 in boolean cancelableArg,
964 in DOMString propertyNameArg,
965 in float elapsedTimeArg,
966 in DOMString pseudoElementArg);
967 };
968 </pre>
969 </div>
970 </dd>
971 <dt>
972 <b>Attributes</b>
973 </dt>
974 <dd>
975 <dl>
976 <dt>
977 <code class='attribute-name'><a id="Events-TransitionEvent-propertyName" name='Events-TransitionEvent-propertyName'>propertyName</a></code> of type <code>DOMString</code>, readonly
978 </dt>
979 <dd>
980 The name of the CSS property associated with the transition.
981 </dd>
982 </dl>
983 <dl>
984 <dt>
985 <code class='attribute-name'><a id="Events-TransitionEvent-elapsedTime" name='Events-TransitionEvent-elapsedTime'>elapsedTime</a></code> of type <code>float</code>, readonly
986 </dt>
987 <dd>
988 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>.
989 </dd>
990 </dl>
991 <dl>
992 <dt>
993 <code class='attribute-name'><a id="Events-TransitionEvent-pseudoElement" name='Events-TransitionEvent-pseudoElement'>pseudoElement</a></code> of type <code>DOMString</code>, readonly
994 </dt>
995 <dd>
996 The name (beginning with two colons) of the CSS
997 pseudo-element on which the transition occured (in
998 which case the target of the event is that
999 pseudo-element's corresponding element), or the empty
1000 string if the transition occurred on an element (which
1001 means the target of the event is that element).
1002 </dd>
1003 </dl>
1004 </dd>
1005 <dt>
1006 <b>Methods</b>
1007 </dt>
1008 <dd>
1009 <dl>
1010 <dt>
1011 <code class='method-name'><a id="Events-TransitionEvent-initTransitionEvent" name='Events-TransitionEvent-initTransitionEvent'>initTransitionEvent</a></code>
1012 </dt>
1013 <dd>
1014 <div class='method'>
1015 The <code>initTransitionEvent</code> method is used to
1016 initialize the value of a <code>TransitionEvent</code>
1017 created through the <a
1018 href='http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent'><code>DocumentEvent</code></a>
1019 interface. This method may only be called before the
1020 <code>TransitionEvent</code> has been dispatched via the
1021 <code>dispatchEvent</code> method, though it may be called
1022 multiple times during that phase if necessary. If called
1023 multiple times, the final invocation takes precedence.
1024 <p class="issue">Should new events being created still
1025 have init*Event methods?</p>
1026 <div class='parameters'>
1027 <b>Parameters</b>
1028 <div class='paramtable'>
1029 <dl>
1030 <dt>
1031 <code class='parameter-name'>typeArg</code> of type <code>DOMString</code>
1032 </dt>
1033 <dd>
1034 Specifies the event type.<br>
1035 </dd>
1036 <dt>
1037 <code class='parameter-name'>canBubbleArg</code> of type <code>boolean</code>
1038 </dt>
1039 <dd>
1040 Specifies whether or not the event can bubble.<br>
1041 </dd>
1042 <dt>
1043 <code class='parameter-name'>cancelableArg</code> of type <code>boolean</code>
1044 </dt>
1045 <dd>
1046 Specifies whether or not the event's default action can be prevented. Since a TransitionEvent
1047 is purely for notification, there is no default action.<br>
1048 </dd>
1049 <dt>
1050 <code class='parameter-name'>propertyNameArg</code> of type <code>DOMString</code>
1051 </dt>
1052 <dd>
1053 Specifies the name of the property associated with the <a href='http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event'><code>Event</code></a>.
1054 (See the <a href="#Events-TransitionEvent-propertyName">propertyName</a> attribute.)
1055 </dd>
1056 <dt>
1057 <code class='parameter-name'>elapsedTimeArg</code> of type <code>float</code>
1058 </dt>
1059 <dd>
1060 Specifies the amount of time, in seconds, the transition has been running at the time of initialization.
1061 (See the <a href="#Events-TransitionEvent-elapsedTime">elapsedTime</a> attribute.)
1062 </dd>
1063 <dt>
1064 <code class='parameter-name'>pseudoElementArg</code> of type <code>DOMString</code>
1065 </dt>
1066 <dd>
1067 Specifies the pseudo-element on which the
1068 transition occurred.
1069 (See the <a href="#Events-TransitionEvent-pseudoElement">pseudoElement</a> attribute.)
1070 <span class="issue">Does adding this additional argument create any compatibility problems?</span>
1071 </dd>
1072 </dl>
1073 </div>
1074 </div><!-- parameters -->
1075 <div>
1076 <b>No Return Value</b>
1077 </div>
1078 <div>
1079 <b>No Exceptions</b>
1080 </div>
1081 </div><!-- method -->
1082 </dd>
1083 </dl>
1084 </dd>
1085 </dl>
1086 </dd>
1087 </dl>
1088 <p>
1089 There is one type of transition event available.
1090 </p>
1091 <dl>
1092 <dt>
1093 <b>transitionend</b>
1094 </dt>
1095 <dd>
1096 The 'transitionend' event occurs at the completion of the transition. In the
1097 case where a transition is removed before completion, such as if the
1098 transition-property is removed, then the event will not fire.
1099 <ul>
1100 <li>Bubbles: Yes
1101 </li>
1102 <li>Cancelable: Yes
1103 </li>
1104 <li>Context Info: propertyName, elapsedTime
1105 </li>
1106 </ul>
1107 </dd>
1108 </dl>
1110 <h2 id="animation-of-property-types-">
1111 Animation of property types
1112 </h2>
1114 <p>
1115 The following describes how each property type undergoes transition or
1116 animation.
1117 </p>
1119 <ul>
1120 <li>
1121 <strong>color</strong>: interpolated via red, green, blue and alpha
1122 components (treating each as a number, see below).
1123 <div class="issue">Issue: Are the colors interpolated in
1124 premultiplied space or non-premultiplied space?</div>
1125 </li>
1126 <li>
1127 <strong>length</strong>: interpolated as real numbers.
1128 </li>
1129 <li>
1130 <strong>percentage</strong>: interpolated as real numbers.
1131 </li>
1132 <li>
1133 <strong>integer</strong>: interpolated via discrete steps (whole
1134 numbers). The interpolation happens in real number space and is
1135 converted to an integer using <code>floor()</code>.
1136 <span class="issue">
1137 This floor behavior is inconsistent with SMIL Animation /
1138 SVG Animation.
1139 </span>
1140 </li>
1141 <li>
1142 <strong>font weight</strong>: interpolated via discrete steps
1143 (multiples of 100). The interpolation happens in real number
1144 space and is converted to an integer by rounding to the
1145 nearest multiple of 100.
1146 <span class="issue">
1147 This round-to-nearest behavior is inconsistent with the
1148 floor behavior used for integer types, but probably should
1149 be consistent (one way or the other).
1150 </span>
1151 </li>
1152 <li>
1153 <strong>number</strong>: interpolated as real (floating point)
1154 numbers.
1155 </li>
1156 <li>
1157 <strong>transform list</strong>: see
1158 CSS Transforms specification [[!CSS3-TRANSFORMS]].
1159 </li>
1160 <li>
1161 <strong>rectangle</strong>: interpolated via the x, y,
1162 width and height components (treating each as a number).
1163 </li>
1164 <li>
1165 <strong>visibility</strong>: if one of the values is
1166 'visible', interpolated as a discrete step where values of the
1167 timing function between 0 and 1 map to 'visible' and other
1168 values of the timing function (which occur only at the
1169 start/end of the transition or as a result of 'cubic-bezier()'
1170 functions with Y values outside of [0, 1]) map to the closer
1171 endpoint; if neither value is 'visible' then not interpolable.
1172 </li>
1173 <li>
1174 <strong>shadow</strong>: interpolated via the color, x, y
1175 and blur components (treating them as color and numbers where
1176 appropriate). In the case where there are lists of shadows,
1177 the shorter list is padded at the end with shadows whose
1178 color is transparent and all lengths (x, y, blur) are 0.
1179 </li>
1180 <li>
1181 <strong>gradient</strong>: interpolated via the
1182 positions and colors of each stop. They must have the same type
1183 (radial or linear) and same number of stops in order to be animated.
1184 <span class="note">Note: [[CSS3-IMAGES]] may extend this
1185 definition.</span>
1186 </li>
1187 <li>
1188 <strong>paint server</strong> (SVG): interpolation is only supported
1189 between: gradient to gradient and color to color. They then
1190 work as above.
1191 </li>
1192 <li>
1193 <strong>list of above types</strong>: If the lists have the
1194 same number of items, each item in the list is interpolated using the
1195 rules above. Otherwise the interpolation is determined by the property
1196 rules. If the property extends its list by repeating values, then this
1197 repeated form will be used in the interpolation (<code class="property">'background-position'</code>
1198 is an example of a property that would transition between lists of different lengths). If
1199 the property does not allow extending its list, then no interpolation
1200 will occur.
1201 </li>
1202 <li>
1203 <strong>a shorthand property</strong>: If any part of a
1204 shorthand can be animated, then interpolation is performed as
1205 if those animatable properties were individually specified.
1206 </li>
1207 </ul>
1209 <p class="issue">Issue: Need to describe handling of out-of-range
1210 values that can result from cubic-bezier(). Clamping values to the
1211 allowed range is probably the best solution.</p>
1213 <h2>
1214 Animatable properties
1215 </h2>
1217 <!--
1218 As resolved in
1219 http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html
1220 -->
1221 <p>For properties that exist at the time this specification was
1222 developed, this specification defines whether and how they are
1223 animated. However, future CSS specifications may define
1224 additional properties, additional values for existing properties,
1225 or additional animation behavior of existing values. In order to
1226 describe new animation behaviors and to have the definition of
1227 animation behavior in a more appropriate location, future CSS
1228 specifications should include an "Animatable:" line in the summary
1229 of the property's definition (in addition to the other lines
1230 described in [[CSS21]], <a
1231 href="http://www.w3.org/TR/CSS21/about.html#property-defs">section
1232 1.4.2</a>). This line should say "no" to indicate that a property
1233 cannot be animated or should reference an animation behavior
1234 (which may be one of the behaviors in the <a
1235 href="#animation-of-property-types-">Animation of property
1236 types</a> section above, or may be a new behavior) to define how
1237 the property animates. Such definitions override those given in
1238 this specification.</p>
1240 <h3>
1241 Properties from CSS
1242 </h3>
1244 <table class="animatable-properties">
1245 <tr>
1246 <th>Property Name</th>
1247 <th>Type</th>
1248 </tr>
1249 <tr>
1250 <td>background-color</td><td>color</tr>
1251 <tr>
1252 <td>background-position</td><td>percentage, length</td>
1253 </tr>
1254 <tr>
1255 <td>border-bottom-color</td><td>color</td>
1256 </tr>
1257 <tr>
1258 <td>border-bottom-width</td><td>length</td>
1259 </tr>
1260 <tr>
1261 <td>border-left-color</td><td>color</td>
1262 </tr>
1263 <tr>
1264 <td>border-left-width</td><td>length</td>
1265 </tr>
1266 <tr>
1267 <td>border-right-color</td><td>color</td>
1268 </tr>
1269 <tr>
1270 <td>border-right-width</td><td>length</td>
1271 </tr>
1272 <tr>
1273 <td>border-spacing</td><td>length</td>
1274 </tr>
1275 <tr>
1276 <td>border-top-color</td><td>color</td>
1277 </tr>
1278 <tr>
1279 <td>border-top-width</td><td>length</td>
1280 </tr>
1281 <tr>
1282 <td>bottom</td><td>length, percentage</td>
1283 </tr>
1284 <tr>
1285 <td>clip</td><td>rectangle</td>
1286 </tr>
1287 <tr>
1288 <td>color</td><td>color</td>
1289 </tr>
1290 <tr>
1291 <td>crop <span class="issue">css3-content will likely advance slower than this specification, in which case this definition should move there</span></td><td>rectangle</td>
1292 </tr>
1293 <tr>
1294 <td>font-size</td><td>length, percentage</td>
1295 </tr>
1296 <tr>
1297 <td>font-weight</td><td>font weight</td>
1298 </tr>
1299 <tr>
1300 <td>height</td><td>length, percentage</td>
1301 </tr>
1302 <tr>
1303 <td>left</td><td>length, percentage</td>
1304 </tr>
1305 <tr>
1306 <td>letter-spacing</td><td>length</td>
1307 </tr>
1308 <tr>
1309 <td>line-height</td><td>number, length, percentage</td>
1310 </tr>
1311 <tr>
1312 <td>margin-bottom</td><td>length</td>
1313 </tr>
1314 <tr>
1315 <td>margin-left</td><td>length</td>
1316 </tr>
1317 <tr>
1318 <td>margin-right</td><td>length</td>
1319 </tr>
1320 <tr>
1321 <td>margin-top</td><td>length</td>
1322 </tr>
1323 <tr>
1324 <td>max-height</td><td>length, percentage</td>
1325 </tr>
1326 <tr>
1327 <td>max-width</td><td>length, percentage </td>
1328 </tr>
1329 <tr>
1330 <td>min-height</td><td>length, percentage</td>
1331 </tr>
1332 <tr>
1333 <td>min-width</td><td>length, percentage</td>
1334 </tr>
1335 <tr>
1336 <td>opacity</td><td>number</td>
1337 </tr>
1338 <tr>
1339 <td>outline-color</td><td>color</td>
1340 </tr>
1341 <tr>
1342 <td>outline-offset</td><td>integer</td>
1343 </tr>
1344 <tr>
1345 <td>outline-width</td><td>length</td>
1346 </tr>
1347 <tr>
1348 <td>padding-bottom</td><td>length</td>
1349 </tr>
1350 <tr>
1351 <td>padding-left</td><td>length</td>
1352 </tr>
1353 <tr>
1354 <td>padding-right</td><td>length</td>
1355 </tr>
1356 <tr>
1357 <td>padding-top</td><td>length</td>
1358 </tr>
1359 <tr>
1360 <td>right</td><td>length, percentage</td>
1361 </tr>
1362 <tr>
1363 <td>text-indent</td><td>length, percentage</td>
1364 </tr>
1365 <tr>
1366 <td>text-shadow</td><td>shadow</td>
1367 </tr>
1368 <tr>
1369 <td>top</td><td>length, percentage</td>
1370 </tr>
1371 <tr>
1372 <td>vertical-align</td><td>length, percentage</td>
1373 </tr>
1374 <tr>
1375 <td>visibility</td><td>visibility</td>
1376 </tr>
1377 <tr>
1378 <td>width</td><td>length, percentage</td>
1379 </tr>
1380 <tr>
1381 <td>word-spacing</td><td>length, percentage</td>
1382 </tr>
1383 <tr>
1384 <td>z-index</td><td>integer</td>
1385 </tr>
1386 </table>
1388 <p class="issue">
1389 This list omits the following properties that Gecko can animate, and
1390 which likely should be included:
1391 background-size,
1392 border-*-radius,
1393 box-shadow,
1394 column-count,
1395 column-gap,
1396 column-rule-color,
1397 column-rule-width,
1398 column-width,
1399 font-size-adjust,
1400 font-stretch,
1401 marker-offset,
1402 text-decoration-color,
1403 transform,
1404 transform-origin.
1405 </p>
1407 <h3>
1408 Properties from SVG
1409 </h3>
1411 <p>
1412 All properties defined as animatable in the SVG specification, provided
1413 they are one of the property types listed above.
1414 </p>
1416 <!-- <table>
1417 <tr>
1418 <th>Property Name</th><th>Type</th>
1419 </tr>
1420 <tr>
1421 <td>stop-color</td><td>color</td>
1422 </tr>
1423 <tr>
1424 <td>stop-opacity</td><td>float</td>
1425 </tr>
1426 <tr>
1427 <td>fill</td><td>paint server</td>
1428 </tr>
1429 <tr>
1430 <td>fill-opacity</td><td>float</td>
1431 </tr>
1432 <tr>
1433 <td>stroke</td><td>paint server</td>
1434 </tr>
1435 <tr>
1436 <td>stroke-dasharray</td><td>list of numbers</td>
1437 </tr>
1438 <tr>
1439 <td>stroke-dashoffset</td><td>number</td>
1440 </tr>
1441 <tr>
1442 <td>stroke-miterlimit</td><td>number</td>
1443 </tr>
1444 <tr>
1445 <td>stroke-opacity</td><td>float</td>
1446 </tr>
1447 <tr>
1448 <td>stroke-width</td><td>float</td>
1449 </tr>
1450 <tr>
1451 <td>viewport-fill</td><td>color</td>
1452 </tr>
1453 <tr>
1454 <td>viewport-fill-opacity</td><td>color</td>
1455 </tr>
1456 </table> -->
1458 <h2 id="acknowledgments">Acknowledgments</h2>
1460 <p>Thanks especially to the feedback from
1461 Tab Atkins,
1462 Aryeh Gregor,
1463 Vincent Hardy,
1464 Cameron McCormack,
1465 Alex Mogilevsky,
1466 and all the rest of the
1467 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>
1469 <h2>References</h2>
1471 <h3 class="no-num">Normative references</h3>
1472 <!--normative-->
1474 <h3 class="no-num">Other references</h3>
1475 <!--informative-->
1479 <h2 class="no-num">Property index</h2>
1480 <!-- properties -->
1484 <h2 class="no-num" id="index">Index</h2>
1485 <!--index-->
1487 </body>
1488 </html>
1489 <!-- Keep this comment at the end of the file
1490 Local variables:
1491 mode: sgml
1492 sgml-default-doctype-name:"html"
1493 sgml-minimize-attributes:t
1494 End:
1495 -->