css3-transitions/Overview.src.html

Thu, 12 Jul 2012 17:35:04 -0700

author
L. David Baron <dbaron@dbaron.org>
date
Thu, 12 Jul 2012 17:35:04 -0700
changeset 6223
8f1870702065
parent 6218
13621f209435
child 6224
81d3d19891b6
permissions
-rw-r--r--

Actually describe how the interpolation works.

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

mercurial