css3-transitions/Overview.src.html

Thu, 29 Mar 2012 14:51:26 -0700

author
L. David Baron <dbaron@dbaron.org>
date
Thu, 29 Mar 2012 14:51:26 -0700
changeset 5333
a864cedf577e
parent 5332
8e5fc4412bea
child 5334
0bf8cf5edf4b
permissions
-rw-r--r--

Oops, I removed one of fantasai's changes that I should have left.

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@1102 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@5227 41 <dd><a href="http://www.w3.org/TR/2009/WD-css3-transitions-20091201/">
dbaron@5227 42 http://www.w3.org/TR/2009/WD-css3-transitions-20091201/</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 <!-- ======================================================================================================= -->
fantasai@5332 179 <h3 id=the-transition-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 <!-- ======================================================================================================= -->
fantasai@5332 301 <h3 id=the-transition-duration><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>
simon@4370 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'.
dino@936 377 </p>
dino@936 378
dino@936 379 <!-- =======================================================================================================
dino@936 380 -->
dino@936 381
fantasai@5332 382 <h3 id="the-transition-timing-function"><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>.
dino@1907 398 The timing function takes as its input the current elapsed percentage of
dino@1907 399 the transition duration and outputs a percentage that determines how
dino@1907 400 close the transition is to its goal state.
dino@1907 401 </p>
dino@1907 402 <p>
dino@1907 403 A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a>
dino@1907 404 function is defined by a number that divides the domain of operation
dino@1907 405 into equally sized intervals. Each subsequent interval is a equal step
dino@1907 406 closer to the goal state. The function also specifies whether the
dino@1907 407 change in output percentage happens at the start or end of the
dino@1907 408 interval (in other words, if 0% on the input percentage is the point
dino@1907 409 of initial change).
dino@1907 410 </p>
dino@1907 411 <div class="figure">
dino@1907 412 <img src="step.png" alt="The step timing function splits
dino@1907 413 the function domain into a number of disjoint straight line
dino@1907 414 segments. steps(1, start) is a function whose
dino@1907 415 output value is 1 for all input values. steps(1, end) is a function whose
dino@1907 416 output value is 0 for all input values less than 1, and output
dino@1907 417 is 1 for the input value of 1. steps(3, start) is a function that
dino@1907 418 divides the input domain into three segments, each 1/3 in length,
dino@1907 419 and 1/3 above the previous segment, with the first segment starting
dino@1907 420 at 1/3. steps(3, end) is a function that
dino@1907 421 divides the input domain into three segments, each 1/3 in length,
dino@1907 422 and 1/3 above the previous segment, with the first segment starting
dino@1907 423 at 0.">
dino@1907 424 </div>
dino@1907 425 <p class="caption">
dino@1907 426 Step timing functions
dino@1907 427 </p>
dino@1907 428 <p>
dino@1907 429 A <a
dino@1907 430 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic
dbaron@4550 431 B&eacute;zier curve</a> is defined by four control points, P<sub>0</sub>
dino@936 432 through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub>
simon@4370 433 are always set to (0,0) and (1,1). The <code class="property">'transition-timing-function'</code> property is used
dino@936 434 to specify the values for points P<sub>1</sub> and P<sub>2</sub>. These
dino@936 435 can be set to preset values using the keywords listed below, or can be
simon@4370 436 set to specific values using the <code class="css">'cubic-bezier'</code> function.
simon@4370 437 In the <code class="css">'cubic-bezier'</code> function, P<sub>1</sub> and
dino@936 438 P<sub>2</sub> are each specified by both an X and Y value.
dino@936 439 </p>
dino@936 440 <div class="figure">
dbaron@4550 441 <img src="TimingFunction.png" alt="The B&eacute;zier timing function is a
dino@1907 442 smooth curve from point P0 = (0,0) to point P3 = (1,1). The
dino@1907 443 length and orientation of the line segment P0-P1 determines
dino@1907 444 the tangent and the curvature of the curve at P0 and the
dino@1907 445 line segment P2-P3 does the same at P3.">
dino@936 446 </div>
dino@936 447 <p class="caption">
dbaron@4550 448 B&eacute;zier Timing Function Control Points
dino@936 449 </p>
dino@936 450 <table class="propdef">
dino@936 451 <tbody>
dino@936 452 <tr>
dino@936 453 <td>
dino@936 454 <em>Name:</em>
dino@936 455 </td>
dino@936 456 <td>
dino@936 457 <dfn id="transition-timing-function">transition-timing-function</dfn>
dino@936 458 </td>
dino@936 459 </tr>
dino@936 460 <tr>
dino@936 461 <td>
dino@936 462 <em>Value:</em>
dino@936 463 </td>
dino@936 464 <td>
dbaron@5312 465 [ 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 466 </td>
dino@936 467 </tr>
dino@936 468 <tr>
dino@936 469 <td>
dino@936 470 <em>Initial:</em>
dino@936 471 </td>
dino@936 472 <td>
dino@936 473 ease
dino@936 474 </td>
dino@936 475 </tr>
dino@936 476 <tr>
dino@936 477 <td>
dino@936 478 <em>Applies&nbsp;to:</em>
dino@936 479 </td>
dino@936 480 <td>
dino@1469 481 all elements, :before and :after pseudo elements
dino@936 482 </td>
dino@936 483 </tr>
dino@936 484 <tr>
dino@936 485 <td>
dino@936 486 <em>Inherited:</em>
dino@936 487 </td>
dino@936 488 <td>
dino@936 489 no
dino@936 490 </td>
dino@936 491 </tr>
dino@936 492 <tr>
dino@936 493 <td>
dino@936 494 <em>Percentages:</em>
dino@936 495 </td>
dino@936 496 <td>
dino@936 497 N/A
dino@936 498 </td>
dino@936 499 </tr>
dino@936 500 <tr>
dino@936 501 <td>
dino@936 502 <em>Media:</em>
dino@936 503 </td>
dino@936 504 <td>
dino@1469 505 interactive
dino@936 506 </td>
dino@936 507 </tr>
dino@936 508 <tr>
dino@936 509 <td>
dino@936 510 <em>Computed value:</em>
dino@936 511 </td>
dino@936 512 <td>
dino@936 513 Same as specified value.
dino@936 514 </td>
dino@936 515 </tr>
dino@936 516 </tbody>
dino@936 517 </table>
dino@936 518 <p>
dino@936 519 The timing functions have the following definitions.
dino@936 520 </p>
dino@936 521 <dl>
dino@936 522 <dt>
dino@936 523 ease
dino@936 524 </dt>
dino@936 525 <dd>
dino@936 526 The ease function is equivalent to cubic-bezier(0.25, 0.1, 0.25, 1.0).
dino@936 527 </dd>
dino@936 528 <dt>
dino@936 529 linear
dino@936 530 </dt>
dino@936 531 <dd>
dino@936 532 The linear function is equivalent to cubic-bezier(0.0, 0.0, 1.0, 1.0).
dino@936 533 </dd>
dino@936 534 <dt>
dino@936 535 ease-in
dino@936 536 </dt>
dino@936 537 <dd>
dino@936 538 The ease-in function is equivalent to cubic-bezier(0.42, 0, 1.0, 1.0).
dino@936 539 </dd>
dino@936 540 <dt>
dino@936 541 ease-out
dino@936 542 </dt>
dino@936 543 <dd>
dino@936 544 The ease-out function is equivalent to cubic-bezier(0, 0, 0.58, 1.0).
dino@936 545 </dd>
dino@936 546 <dt>
dino@936 547 ease-in-out
dino@936 548 </dt>
dino@936 549 <dd>
dino@936 550 The ease-in-out function is equivalent to cubic-bezier(0.42, 0, 0.58, 1.0)
dino@936 551 </dd>
dino@936 552 <dt>
dino@1907 553 step-start
dino@1907 554 </dt>
dino@1907 555 <dd>
dino@1907 556 The step-start function is equivalent to steps(1, start).
dino@1907 557 </dd>
dino@1907 558 <dt>
dino@1907 559 step-end
dino@1907 560 </dt>
dino@1907 561 <dd>
dino@1907 562 The step-end function is equivalent to steps(1, end).
dino@1907 563 </dd>
dino@1907 564 <dt>
dino@1907 565 steps
dino@1907 566 </dt>
dino@1907 567 <dd>
dino@1907 568 Specifies a stepping function, described above, taking two
dino@1907 569 parameters. The first parameter specifies the number of intervals
dino@2615 570 in the function. It must be a positive integer (greater than 0).
dino@2615 571 The second parameter, which is optional, is
dino@1907 572 either the value 'start' or 'end', and specifies the point
dino@1907 573 at which the change of values occur within the interval.
dino@1907 574 If the second parameter is omitted, it is given the value 'end'.
dino@1907 575 </dd>
dino@1907 576 <dt>
dino@936 577 cubic-bezier
dino@936 578 </dt>
dino@936 579 <dd>
dino@936 580 Specifies a <a
dino@936 581 href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier
dino@936 582 curve</a>. The four values specify points P<sub>1</sub> and
dino@2615 583 P<sub>2</sub> of the curve as (x1, y1, x2, y2). Both x values must be
dino@2615 584 in the range [0, 1] or the definition is invalid. The y values can
dino@2615 585 exceed this range.
dino@936 586 </dd>
dino@936 587 </dl><!-- ======================================================================================================= -->
fantasai@5332 588 <h3 id=the-transition-delay><a id=the-transition-delay-property->
simon@4370 589 The <code class="property">'transition-delay'</code> Property
fantasai@5332 590 </a></h3>
dino@936 591 <p>
simon@4370 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.
dino@936 593 </p>
dino@936 594 <p>
simon@4370 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.
dino@936 596 </p>
dino@936 597 <table class="propdef">
dino@936 598 <tbody>
dino@936 599 <tr>
dino@936 600 <td>
dino@936 601 <em>Name:</em>
dino@936 602 </td>
dino@936 603 <td>
dino@936 604 <dfn id="transition-delay">transition-delay</dfn>
dino@936 605 </td>
dino@936 606 </tr>
dino@936 607 <tr>
dino@936 608 <td>
dino@936 609 <em>Value:</em>
dino@936 610 </td>
dino@936 611 <td>
dino@936 612 &lt;time&gt; [, &lt;time&gt;]*
dino@936 613 </td>
dino@936 614 </tr>
dino@936 615 <tr>
dino@936 616 <td>
dino@936 617 <em>Initial:</em>
dino@936 618 </td>
dino@936 619 <td>
dino@3189 620 0s
dino@936 621 </td>
dino@936 622 </tr>
dino@936 623 <tr>
dino@936 624 <td>
dino@936 625 <em>Applies&nbsp;to:</em>
dino@936 626 </td>
dino@936 627 <td>
dino@1469 628 all elements, :before and :after pseudo elements
dino@936 629 </td>
dino@936 630 </tr>
dino@936 631 <tr>
dino@936 632 <td>
dino@936 633 <em>Inherited:</em>
dino@936 634 </td>
dino@936 635 <td>
dino@936 636 no
dino@936 637 </td>
dino@936 638 </tr>
dino@936 639 <tr>
dino@936 640 <td>
dino@936 641 <em>Percentages:</em>
dino@936 642 </td>
dino@936 643 <td>
dino@936 644 N/A
dino@936 645 </td>
dino@936 646 </tr>
dino@936 647 <tr>
dino@936 648 <td>
dino@936 649 <em>Media:</em>
dino@936 650 </td>
dino@936 651 <td>
dino@1469 652 interactive
dino@936 653 </td>
dino@936 654 </tr>
dino@936 655 <tr>
dino@936 656 <td>
dino@936 657 <em>Computed value:</em>
dino@936 658 </td>
dino@936 659 <td>
dino@936 660 Same as specified value.
dino@936 661 </td>
dino@936 662 </tr>
dino@936 663 </tbody>
dino@936 664 </table><!-- ======================================================================================================= -->
fantasai@5332 665 <h3 id=the-transition-shorthand><a id=the-transition-shorthand-property->
simon@4370 666 The <code class="property">'transition'</code> Shorthand Property
fantasai@5332 667 </a></h3>
dino@936 668 <p>
simon@4370 669 The <code class="property">'transition'</code> shorthand property combines the four properties described above into a single property.
dino@936 670 </p>
dino@1469 671 <p>
dino@1469 672 Note that order is important in this property. The first value that can be
dino@1469 673 parsed as a time is assigned to the transition-duration. The second value that
dino@1469 674 can be parsed as a time is assigned to transition-delay.
dino@1469 675 </p>
dino@1469 676 <p class="issue">
dino@1469 677 An alternative proposal is to accept the font shorthand approach of
dbaron@4550 678 using a "/" character between the values of the same type. e.g. 2s/4s would
dino@1469 679 mean a duration of 2 seconds and a delay of 4 seconds.
dino@1469 680 </p>
dino@936 681 <table class="propdef">
dino@936 682 <tbody>
dino@936 683 <tr>
dino@936 684 <td>
dino@936 685 <em>Name:</em>
dino@936 686 </td>
dino@936 687 <td>
dino@936 688 <dfn id="transition">transition</dfn>
dino@936 689 </td>
dino@936 690 </tr>
dino@936 691 <tr>
dino@936 692 <td>
dino@936 693 <em>Value:</em>
dino@936 694 </td>
dino@936 695 <td>
dino@1469 696 [&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 697 </td>
dino@936 698 </tr>
dino@936 699 <tr>
dino@936 700 <td>
dino@936 701 <em>Initial:</em>
dino@936 702 </td>
dino@936 703 <td>
dino@936 704 see individual properties
dino@936 705 </td>
dino@936 706 </tr>
dino@936 707 <tr>
dino@936 708 <td>
dino@936 709 <em>Applies&nbsp;to:</em>
dino@936 710 </td>
dino@936 711 <td>
dino@1469 712 all elements, :before and :after pseudo elements
dino@936 713 </td>
dino@936 714 </tr>
dino@936 715 <tr>
dino@936 716 <td>
dino@936 717 <em>Inherited:</em>
dino@936 718 </td>
dino@936 719 <td>
dino@936 720 no
dino@936 721 </td>
dino@936 722 </tr>
dino@936 723 <tr>
dino@936 724 <td>
dino@936 725 <em>Percentages:</em>
dino@936 726 </td>
dino@936 727 <td>
dino@936 728 N/A
dino@936 729 </td>
dino@936 730 </tr>
dino@936 731 <tr>
dino@936 732 <td>
dino@936 733 <em>Media:</em>
dino@936 734 </td>
dino@936 735 <td>
dino@1469 736 interactive
dino@936 737 </td>
dino@936 738 </tr>
dino@936 739 <tr>
dino@936 740 <td>
dino@936 741 <em>Computed value:</em>
dino@936 742 </td>
dino@936 743 <td>
dino@936 744 Same as specified value.
dino@936 745 </td>
dino@936 746 </tr>
dino@936 747 </tbody>
dino@936 748 </table>
dino@1531 749
dbaron@1540 750 <h2 id="starting">
dbaron@1540 751 Starting of transitions
dbaron@1540 752 </h2>
dbaron@1540 753
dbaron@1540 754 <p>
dbaron@2569 755 When the computed value of an animatable property changes,
dbaron@1548 756 implementations must decide what transitions to start based on
dbaron@1548 757 the values of the 'transition-property', 'transition-duration',
dbaron@1548 758 'transition-timing-function', and 'transition-delay' properties
dbaron@2569 759 at the time the animatable property would first have its new
dbaron@2570 760 computed value.
dbaron@2570 761 </p>
dbaron@5243 762 <div class="example" id="manual-reversing-example">
dbaron@2570 763 <p style="display:none">
dbaron@2570 764 Example(s):
dbaron@2570 765 </p>
dbaron@5243 766 <p>This provides a way for authors to specify different values
dbaron@5243 767 of the 'transition-*' properties for the &ldquo;forward&rdquo;
dbaron@5243 768 and &ldquo;reverse&rdquo; transitions (but see <a
dbaron@5243 769 href="#reversing">below</a> for special reversing behavior when
dbaron@5243 770 an <em>incomplete</em> transition is interrupted). Authors can
dbaron@5243 771 specify the value of 'transition-duration',
dbaron@5243 772 'transition-timing-function', or 'transition-delay' in the same
dbaron@5243 773 rule where they specify the value that triggers the transition,
dbaron@5243 774 or can change these properties at the same time as they change
dbaron@5243 775 the property that triggers the transition. Since it's the new
dbaron@5243 776 values of these 'transition-*' properties that affect the
dbaron@5243 777 transition, these values will be used for the transitions
dbaron@5243 778 <em>to</em> the associated transitioning values. For example:
dbaron@5243 779 </p>
dbaron@5243 780 <pre>li {
dbaron@5243 781 transition: background-color linear 1s;
dbaron@5243 782 background: blue;
dbaron@5243 783 }
dbaron@5243 784 li:hover {
dbaron@5243 785 background-color: green;
dbaron@5243 786 transition-duration: 2s; /* applies to the transition *to* the :hover state */
dbaron@5243 787 }</pre>
dbaron@2570 788 <p>
dbaron@2570 789 When a list item with these style rules enters the :hover
dbaron@2570 790 state, the computed 'transition-duration' at the time that
dbaron@2570 791 'background-color' would have its new value ('green') is '2s',
dbaron@2570 792 so the transition from 'blue' to 'green' takes 2 seconds.
dbaron@2570 793 However, when the list item leaves the :hover state, the
dbaron@2570 794 transition from 'green' to 'blue' takes 1 second.
dbaron@2570 795 </p>
dbaron@2570 796 </div>
dbaron@5247 797
dbaron@5247 798 <p>
dbaron@5247 799 When the computed value of a property changes, implementations
dbaron@5247 800 must start transitions based on the relevant item (see <a
dbaron@5248 801 href="#transition-property">the definition of
dbaron@5247 802 'transition-property'</a>) in the computed value of
dbaron@5252 803 'transition-property'. Corresponding to this item there are
dbaron@5253 804 values of 'transition-duration' and 'transition-delay' (see <a
dbaron@5252 805 href="#list-matching">the rules on matching lists</a>). Define
dbaron@5252 806 the <dfn>combined duration</dfn> of the transition as the sum of
dbaron@5252 807 max('transition-duration', '0s') and 'transition-delay'. When
dbaron@5252 808 the combined duration is greater than '0s', then a transition
dbaron@5252 809 starts based on the values of 'transition-duration',
dbaron@5252 810 'transition-delay', and 'transition-timing-function'; in other
dbaron@5252 811 cases transitions do not occur.
dbaron@5247 812 </p>
dbaron@5247 813
dbaron@2570 814 <p>
dbaron@2570 815 Since this specification does not define
dbaron@2569 816 when computed values change, and thus what changes to
dbaron@2569 817 computed values are considered simultaneous,
dbaron@1548 818 authors should be aware that changing any of the transition
dbaron@1548 819 properties a small amount of time after making a change that
dbaron@1548 820 might transition can result in behavior that varies between
dbaron@1548 821 implementations, since the changes might be considered
dbaron@1548 822 simultaneous in some implementations but not others.
dbaron@1540 823 </p>
dbaron@4550 824 <p class="note">Say something about simultaneity</p>
dbaron@1540 825
dbaron@1540 826 <p>
dbaron@1548 827 Once the transition of a property has started, it must continue
dbaron@1548 828 running based on the original timing function, duration, and
dbaron@1548 829 delay, even if the 'transition-timing-function',
dbaron@1548 830 'transition-duration', or 'transition-delay' property changes
dbaron@1548 831 before the transition is complete. However, if the
dbaron@1548 832 'transition-property' property changes such that the transition
dbaron@1548 833 would not have started, the transition must stop (and the
dbaron@1548 834 property must immediately change to its final value).
dbaron@1540 835 </p>
dbaron@1540 836
dbaron@1540 837 <p>
dbaron@1548 838 Implementations must not start a transition when the computed
dbaron@1548 839 value of a property changes as a result of declarative animation
dbaron@1548 840 (as opposed to scripted animation).
dbaron@1540 841 </p>
dbaron@1540 842
dbaron@1540 843 <p>
dbaron@1548 844 Implementations also must not start a transition when the
dbaron@1548 845 computed value changes because it is inherited (directly or
dbaron@1548 846 indirectly) from another element that is transitioning the same
dbaron@1548 847 property.
dbaron@1540 848 </p>
dbaron@1540 849
dino@1531 850 <h2 id="reversing">
dbaron@5243 851 Automatically reversing interrupted transitions
dino@1531 852 </h2>
dino@1531 853 <p>
dino@1531 854 A common type of transition effect is when a running transition is
dino@1531 855 interrupted and the property is reset to its original value. An
dino@1531 856 example is a hover effect on an element, where the pointer enters and
dino@1531 857 exits the element before the effect has completed. If the outgoing and
dino@1531 858 incoming transitions are executed using their specified durations and
dino@1531 859 timing functions, the resulting effect can be distractingly
dino@1531 860 asymmetric. Instead, the expected behavior is that the new transition
dino@1531 861 should be the reverse of what has already executed.
dino@1531 862 </p>
dino@1532 863
dino@1531 864 <p>
dino@1532 865 If a running transition with duration T, executing so far for duration TE,
dino@1532 866 from state A, to state B, is interrupted by
dino@1532 867 a property change that would start a new transition back to state A, and
dino@1532 868 all the transition attributes are the same (duration, delay and timing function),
dino@1532 869 then the new transition must reverse the effect. The new transition must:
dino@1531 870 </p>
dino@1532 871
dino@1532 872 <ol>
dino@1532 873 <li>
dino@1532 874 Use the B and A states as its "from" and "to" states respectively. It
dino@1532 875 does not use the current value as its from state, due to the rules below.
dino@1532 876 </li>
dino@1532 877 <li>
dino@1532 878 Execute with the same duration T, but starting as if the transition had
dino@1532 879 already begun, without any transition delay, at the moment which would
dino@1532 880 cause the new transition to finish in TE from the moment of interruption. In other
dino@1532 881 words, the new transition will execute as if it started T-TE in the past.
dino@1532 882 </li>
dino@1532 883 <li>
dino@1532 884 Use a timing function that is the portion of the curve traversed up
dino@1532 885 to the moment of interruption, followed in the opposite direction (towards
dino@1532 886 the starting point). This will make the transition appear as if it
dino@1532 887 is playing backwards.
dino@1532 888 </li>
dino@1532 889 <li>
dino@1532 890 Ignore any transition delay.
dino@1532 891 </li>
dino@1532 892 </ol>
dino@1532 893
dino@1531 894 <p>
dino@1531 895 For example, suppose there is a transition with a duration of two
dino@1531 896 seconds. If this transition is interrupted after 0.5 seconds and the
dino@1531 897 property value assigned to the original value, then the new transition
dino@1531 898 effect will be the reverse of the original, as if it had begun
dino@1531 899 1.5 seconds in the past.
dino@1531 900 </p>
dino@936 901
dino@1532 902 <p>
dino@1532 903 Note that by using the defined from and to states for the reversing
dino@1532 904 transition, it is also possible that it may reverse again, if
dino@1532 905 interrupted; for example, if the transition reversing to state A was
dino@1532 906 again interrupted by a property change to state B.
dino@1532 907 </p>
dino@1532 908
dbaron@2568 909 <p class="issue">Issue:
dbaron@2568 910 This introduces the concept of reversing a timing function,
dbaron@2568 911 which the spec has otherwise resisted doing, and also introduces
dbaron@2568 912 a discontinuity between transitions that have
dbaron@2568 913 almost completed (which get automatically reversed and thus have
dbaron@2568 914 their timing function reversed) and transitions that have fully
dbaron@2568 915 completed (where the reversal doesn't lead to the timing
dbaron@2568 916 function being reversed). An alternative proposal that avoids
dbaron@2568 917 this is to follow the normal timing function algorithm, except
dbaron@2568 918 multiply the duration (and also shorten any negative delay) by
dbaron@2568 919 the (output) value of the transition timing function of the
dbaron@2568 920 incomplete transition at the time it was interrupted, and, to
dbaron@2568 921 account for multiple reverses in sequence, to divide by the
dbaron@2568 922 shortening applied to the transition being interrupted. For
dbaron@2568 923 more details see this thread:
dbaron@2568 924 <a href="http://lists.w3.org/Archives/Public/www-style/2009Nov/thread.html#msg302">November 2009 part</a>,
dbaron@2568 925 <a href="http://lists.w3.org/Archives/Public/www-style/2009Dec/thread.html#msg319">December 2009 part</a>,
dbaron@2568 926 <a href="http://lists.w3.org/Archives/Public/www-style/2010Jan/thread.html#msg136">January 2010 part</a>.
dbaron@2568 927 </p>
dbaron@2568 928
fantasai@5332 929 <h2 id=transition-events><a id=transition-events->
dino@936 930 Transition Events
fantasai@5332 931 </a></h2>
dino@936 932 <p>
dino@936 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>.
dino@936 934 An event is fired for each property that undergoes a transition.
dino@936 935 This allows a content developer to perform actions that synchronize
dino@936 936 with the completion of a transition.
dino@936 937 </p>
dino@936 938 <p>
dino@936 939 Each event provides the name of the property the transition is
dino@936 940 associated with as well as the duration of the transition.
dino@936 941 </p>
dino@936 942 <dl>
dino@936 943 <dt>
dino@936 944 <b>Interface <i><a id="Events-TransitionEvent" name='Events-TransitionEvent'>TransitionEvent</a></i></b>
dino@936 945 </dt>
dino@936 946 <dd>
dino@936 947 <p>
dino@936 948 The <code>TransitionEvent</code> interface provides specific contextual information associated with transitions.
dino@936 949 </p>
dino@936 950 <dl>
dino@936 951 <dt>
dino@936 952 <b>IDL Definition</b>
dino@936 953 </dt>
dino@936 954 <dd>
dino@936 955 <div class='idl-code'>
dino@936 956 <pre>
dino@936 957 interface TransitionEvent : Event {
dino@936 958 readonly attribute DOMString propertyName;
dino@936 959 readonly attribute float elapsedTime;
dbaron@5259 960 readonly attribute DOMString pseudoElement;
dino@936 961 void initTransitionEvent(in DOMString typeArg,
dino@936 962 in boolean canBubbleArg,
dino@936 963 in boolean cancelableArg,
dino@936 964 in DOMString propertyNameArg,
dbaron@5259 965 in float elapsedTimeArg,
dbaron@5259 966 in DOMString pseudoElementArg);
dino@936 967 };
dino@936 968 </pre>
dino@936 969 </div>
dino@936 970 </dd>
dino@936 971 <dt>
dino@936 972 <b>Attributes</b>
dino@936 973 </dt>
dino@936 974 <dd>
dino@936 975 <dl>
dino@936 976 <dt>
dino@936 977 <code class='attribute-name'><a id="Events-TransitionEvent-propertyName" name='Events-TransitionEvent-propertyName'>propertyName</a></code> of type <code>DOMString</code>, readonly
dino@936 978 </dt>
dino@936 979 <dd>
dino@936 980 The name of the CSS property associated with the transition.
dino@936 981 </dd>
dino@936 982 </dl>
dino@936 983 <dl>
dino@936 984 <dt>
dino@936 985 <code class='attribute-name'><a id="Events-TransitionEvent-elapsedTime" name='Events-TransitionEvent-elapsedTime'>elapsedTime</a></code> of type <code>float</code>, readonly
dino@936 986 </dt>
dino@936 987 <dd>
simon@4370 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>.
dino@936 989 </dd>
dino@936 990 </dl>
dbaron@5259 991 <dl>
dbaron@5259 992 <dt>
dbaron@5259 993 <code class='attribute-name'><a id="Events-TransitionEvent-pseudoElement" name='Events-TransitionEvent-pseudoElement'>pseudoElement</a></code> of type <code>DOMString</code>, readonly
dbaron@5259 994 </dt>
dbaron@5259 995 <dd>
dbaron@5259 996 The name (beginning with two colons) of the CSS
dbaron@5259 997 pseudo-element on which the transition occured (in
dbaron@5259 998 which case the target of the event is that
dbaron@5259 999 pseudo-element's corresponding element), or the empty
dbaron@5259 1000 string if the transition occurred on an element (which
dbaron@5259 1001 means the target of the event is that element).
dbaron@5259 1002 </dd>
dbaron@5259 1003 </dl>
dino@936 1004 </dd>
dino@936 1005 <dt>
dino@936 1006 <b>Methods</b>
dino@936 1007 </dt>
dino@936 1008 <dd>
dino@936 1009 <dl>
dino@936 1010 <dt>
dino@936 1011 <code class='method-name'><a id="Events-TransitionEvent-initTransitionEvent" name='Events-TransitionEvent-initTransitionEvent'>initTransitionEvent</a></code>
dino@936 1012 </dt>
dino@936 1013 <dd>
dino@936 1014 <div class='method'>
dino@1469 1015 The <code>initTransitionEvent</code> method is used to
dino@1469 1016 initialize the value of a <code>TransitionEvent</code>
dino@1469 1017 created through the <a
dino@1469 1018 href='http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent'><code>DocumentEvent</code></a>
dino@1469 1019 interface. This method may only be called before the
dino@1469 1020 <code>TransitionEvent</code> has been dispatched via the
dino@1469 1021 <code>dispatchEvent</code> method, though it may be called
dino@1469 1022 multiple times during that phase if necessary. If called
dino@1469 1023 multiple times, the final invocation takes precedence.
dbaron@5287 1024 <p class="issue">Should new events being created still
dbaron@5287 1025 have init*Event methods?</p>
dino@936 1026 <div class='parameters'>
dino@936 1027 <b>Parameters</b>
dino@936 1028 <div class='paramtable'>
dino@936 1029 <dl>
dino@936 1030 <dt>
dino@936 1031 <code class='parameter-name'>typeArg</code> of type <code>DOMString</code>
dino@936 1032 </dt>
dino@936 1033 <dd>
dino@936 1034 Specifies the event type.<br>
dino@936 1035 </dd>
dino@936 1036 <dt>
dino@936 1037 <code class='parameter-name'>canBubbleArg</code> of type <code>boolean</code>
dino@936 1038 </dt>
dino@936 1039 <dd>
dino@936 1040 Specifies whether or not the event can bubble.<br>
dino@936 1041 </dd>
dino@936 1042 <dt>
dino@936 1043 <code class='parameter-name'>cancelableArg</code> of type <code>boolean</code>
dino@936 1044 </dt>
dino@936 1045 <dd>
dino@1469 1046 Specifies whether or not the event's default action can be prevented. Since a TransitionEvent
dino@1469 1047 is purely for notification, there is no default action.<br>
dino@936 1048 </dd>
dino@936 1049 <dt>
dino@936 1050 <code class='parameter-name'>propertyNameArg</code> of type <code>DOMString</code>
dino@936 1051 </dt>
dino@936 1052 <dd>
dbaron@5259 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>.
dbaron@5259 1054 (See the <a href="#Events-TransitionEvent-propertyName">propertyName</a> attribute.)
dino@936 1055 </dd>
dino@936 1056 <dt>
dino@936 1057 <code class='parameter-name'>elapsedTimeArg</code> of type <code>float</code>
dino@936 1058 </dt>
dino@936 1059 <dd>
dino@936 1060 Specifies the amount of time, in seconds, the transition has been running at the time of initialization.
dbaron@5259 1061 (See the <a href="#Events-TransitionEvent-elapsedTime">elapsedTime</a> attribute.)
dbaron@5259 1062 </dd>
dbaron@5259 1063 <dt>
dbaron@5259 1064 <code class='parameter-name'>pseudoElementArg</code> of type <code>DOMString</code>
dbaron@5259 1065 </dt>
dbaron@5259 1066 <dd>
dbaron@5259 1067 Specifies the pseudo-element on which the
dbaron@5259 1068 transition occurred.
dbaron@5259 1069 (See the <a href="#Events-TransitionEvent-pseudoElement">pseudoElement</a> attribute.)
dbaron@5259 1070 <span class="issue">Does adding this additional argument create any compatibility problems?</span>
dino@936 1071 </dd>
dino@936 1072 </dl>
dino@936 1073 </div>
dino@936 1074 </div><!-- parameters -->
dino@936 1075 <div>
dino@936 1076 <b>No Return Value</b>
dino@936 1077 </div>
dino@936 1078 <div>
dino@936 1079 <b>No Exceptions</b>
dino@936 1080 </div>
dino@936 1081 </div><!-- method -->
dino@936 1082 </dd>
dino@936 1083 </dl>
dino@936 1084 </dd>
dino@936 1085 </dl>
dino@936 1086 </dd>
dino@936 1087 </dl>
dino@936 1088 <p>
dino@936 1089 There is one type of transition event available.
dino@936 1090 </p>
dino@936 1091 <dl>
dino@936 1092 <dt>
dino@936 1093 <b>transitionend</b>
dino@936 1094 </dt>
dino@936 1095 <dd>
dino@1469 1096 The 'transitionend' event occurs at the completion of the transition. In the
dino@1469 1097 case where a transition is removed before completion, such as if the
dino@1469 1098 transition-property is removed, then the event will not fire.
dino@936 1099 <ul>
dino@936 1100 <li>Bubbles: Yes
dino@936 1101 </li>
dino@936 1102 <li>Cancelable: Yes
dino@936 1103 </li>
dino@1469 1104 <li>Context Info: propertyName, elapsedTime
dino@936 1105 </li>
dino@936 1106 </ul>
dino@936 1107 </dd>
dino@936 1108 </dl>
dino@936 1109
fantasai@5332 1110 <h2 id="animatable-types"><a id=animation-of-property-types->
dino@936 1111 Animation of property types
fantasai@5332 1112 </a></h2>
dino@936 1113
dino@936 1114 <p>
dino@936 1115 The following describes how each property type undergoes transition or
dino@936 1116 animation.
dino@936 1117 </p>
dino@936 1118
dino@936 1119 <ul>
dino@936 1120 <li>
dino@936 1121 <strong>color</strong>: interpolated via red, green, blue and alpha
dino@936 1122 components (treating each as a number, see below).
dino@3189 1123 <div class="issue">Issue: Are the colors interpolated in
dbaron@1541 1124 premultiplied space or non-premultiplied space?</div>
dino@936 1125 </li>
dino@936 1126 <li>
dino@936 1127 <strong>length</strong>: interpolated as real numbers.
dino@936 1128 </li>
dino@936 1129 <li>
dino@936 1130 <strong>percentage</strong>: interpolated as real numbers.
dino@936 1131 </li>
dino@936 1132 <li>
dino@936 1133 <strong>integer</strong>: interpolated via discrete steps (whole
dino@936 1134 numbers). The interpolation happens in real number space and is
dino@936 1135 converted to an integer using <code>floor()</code>.
dbaron@5286 1136 <span class="issue">
dbaron@5286 1137 This floor behavior is inconsistent with SMIL Animation /
dbaron@5286 1138 SVG Animation.
dbaron@5286 1139 </span>
dino@936 1140 </li>
dino@936 1141 <li>
dbaron@5257 1142 <strong>font weight</strong>: interpolated via discrete steps
dbaron@5257 1143 (multiples of 100). The interpolation happens in real number
dbaron@5286 1144 space and is converted to an integer by rounding to the
dbaron@5286 1145 nearest multiple of 100.
dbaron@5286 1146 <span class="issue">
dbaron@5286 1147 This round-to-nearest behavior is inconsistent with the
dbaron@5286 1148 floor behavior used for integer types, but probably should
dbaron@5286 1149 be consistent (one way or the other).
dbaron@5286 1150 </span>
dbaron@5257 1151 </li>
dbaron@5257 1152 <li>
dino@936 1153 <strong>number</strong>: interpolated as real (floating point)
dino@936 1154 numbers.
dino@936 1155 </li>
dino@936 1156 <li>
bert@1102 1157 <strong>transform list</strong>: see
dbaron@5220 1158 CSS Transforms specification [[!CSS3-TRANSFORMS]].
dino@936 1159 </li>
dino@936 1160 <li>
dino@936 1161 <strong>rectangle</strong>: interpolated via the x, y,
dino@936 1162 width and height components (treating each as a number).
dino@936 1163 </li>
dino@936 1164 <li>
dbaron@5258 1165 <strong>visibility</strong>: if one of the values is
dbaron@5258 1166 'visible', interpolated as a discrete step where values of the
dbaron@5258 1167 timing function between 0 and 1 map to 'visible' and other
dbaron@5258 1168 values of the timing function (which occur only at the
dbaron@5258 1169 start/end of the transition or as a result of 'cubic-bezier()'
dbaron@5258 1170 functions with Y values outside of [0, 1]) map to the closer
dbaron@5258 1171 endpoint; if neither value is 'visible' then not interpolable.
dino@936 1172 </li>
dino@936 1173 <li>
dino@936 1174 <strong>shadow</strong>: interpolated via the color, x, y
dino@936 1175 and blur components (treating them as color and numbers where
dbaron@1539 1176 appropriate). In the case where there are lists of shadows,
dbaron@1539 1177 the shorter list is padded at the end with shadows whose
dbaron@1539 1178 color is transparent and all lengths (x, y, blur) are 0.
dino@936 1179 </li>
dino@936 1180 <li>
dino@936 1181 <strong>gradient</strong>: interpolated via the
dino@936 1182 positions and colors of each stop. They must have the same type
dino@936 1183 (radial or linear) and same number of stops in order to be animated.
dbaron@2964 1184 <span class="note">Note: [[CSS3-IMAGES]] may extend this
dbaron@2964 1185 definition.</span>
dino@936 1186 </li>
dino@936 1187 <li>
dino@936 1188 <strong>paint server</strong> (SVG): interpolation is only supported
dbaron@5319 1189 between: gradient to gradient and color to color. They then
dino@936 1190 work as above.
dino@936 1191 </li>
dino@936 1192 <li>
dino@3189 1193 <strong>list of above types</strong>: If the lists have the
dino@3189 1194 same number of items, each item in the list is interpolated using the
dino@3189 1195 rules above. Otherwise the interpolation is determined by the property
dino@3189 1196 rules. If the property extends its list by repeating values, then this
simon@4370 1197 repeated form will be used in the interpolation (<code class="property">'background-position'</code>
simon@4370 1198 is an example of a property that would transition between lists of different lengths). If
dino@3189 1199 the property does not allow extending its list, then no interpolation
dino@3189 1200 will occur.
dino@1469 1201 </li>
dino@1469 1202 <li>
dino@2615 1203 <strong>a shorthand property</strong>: If any part of a
dino@1469 1204 shorthand can be animated, then interpolation is performed as
dino@2615 1205 if those animatable properties were individually specified.
dino@936 1206 </li>
dino@936 1207 </ul>
dino@936 1208
dbaron@2965 1209 <p class="issue">Issue: Need to describe handling of out-of-range
dbaron@2965 1210 values that can result from cubic-bezier(). Clamping values to the
dbaron@2965 1211 allowed range is probably the best solution.</p>
dbaron@2965 1212
fantasai@5332 1213 <h2 id=animatable-properties><a id=animatable-properties->
dino@936 1214 Animatable properties
fantasai@5332 1215 </a></h2>
dino@936 1216
dbaron@4128 1217 <!--
dbaron@4128 1218 As resolved in
dbaron@4128 1219 http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html
dbaron@4128 1220 -->
dbaron@4128 1221 <p>For properties that exist at the time this specification was
dbaron@4128 1222 developed, this specification defines whether and how they are
dbaron@4128 1223 animated. However, future CSS specifications may define
dbaron@4128 1224 additional properties, additional values for existing properties,
dbaron@4128 1225 or additional animation behavior of existing values. In order to
dbaron@4128 1226 describe new animation behaviors and to have the definition of
dbaron@4128 1227 animation behavior in a more appropriate location, future CSS
dbaron@4128 1228 specifications should include an "Animatable:" line in the summary
dbaron@4128 1229 of the property's definition (in addition to the other lines
dbaron@4128 1230 described in [[CSS21]], <a
dbaron@4128 1231 href="http://www.w3.org/TR/CSS21/about.html#property-defs">section
dbaron@4128 1232 1.4.2</a>). This line should say "no" to indicate that a property
dbaron@4128 1233 cannot be animated or should reference an animation behavior
dbaron@4128 1234 (which may be one of the behaviors in the <a
dbaron@4128 1235 href="#animation-of-property-types-">Animation of property
dbaron@4128 1236 types</a> section above, or may be a new behavior) to define how
dbaron@4128 1237 the property animates. Such definitions override those given in
dbaron@4128 1238 this specification.</p>
dbaron@4128 1239
fantasai@5332 1240 <h3 id=animatable-css><a id=properties-from-css->
dino@936 1241 Properties from CSS
fantasai@5332 1242 </a></h3>
dino@936 1243
simon@4394 1244 <table class="animatable-properties">
dino@936 1245 <tr>
dino@936 1246 <th>Property Name</th>
dino@936 1247 <th>Type</th>
dino@936 1248 </tr>
dino@936 1249 <tr>
dino@936 1250 <td>background-color</td><td>color</tr>
dino@936 1251 <tr>
dino@936 1252 <td>background-position</td><td>percentage, length</td>
dino@936 1253 </tr>
dino@936 1254 <tr>
dino@936 1255 <td>border-bottom-color</td><td>color</td>
dino@936 1256 </tr>
dino@936 1257 <tr>
dino@936 1258 <td>border-bottom-width</td><td>length</td>
dino@936 1259 </tr>
dino@936 1260 <tr>
dino@936 1261 <td>border-left-color</td><td>color</td>
dino@936 1262 </tr>
dino@936 1263 <tr>
dino@936 1264 <td>border-left-width</td><td>length</td>
dino@936 1265 </tr>
dino@936 1266 <tr>
dino@936 1267 <td>border-right-color</td><td>color</td>
dino@936 1268 </tr>
dino@936 1269 <tr>
dino@936 1270 <td>border-right-width</td><td>length</td>
dino@936 1271 </tr>
dino@936 1272 <tr>
dino@936 1273 <td>border-spacing</td><td>length</td>
dino@936 1274 </tr>
dino@936 1275 <tr>
dino@936 1276 <td>border-top-color</td><td>color</td>
dino@936 1277 </tr>
dino@936 1278 <tr>
dino@936 1279 <td>border-top-width</td><td>length</td>
dino@936 1280 </tr>
dino@936 1281 <tr>
dino@936 1282 <td>bottom</td><td>length, percentage</td>
dino@936 1283 </tr>
dino@936 1284 <tr>
simon@1766 1285 <td>clip</td><td>rectangle</td>
simon@1766 1286 </tr>
simon@1766 1287 <tr>
dino@936 1288 <td>color</td><td>color</td>
dino@936 1289 </tr>
dino@936 1290 <tr>
dbaron@5256 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>
dino@936 1292 </tr>
dino@936 1293 <tr>
dino@936 1294 <td>font-size</td><td>length, percentage</td>
dino@936 1295 </tr>
dino@936 1296 <tr>
dbaron@5257 1297 <td>font-weight</td><td>font weight</td>
dino@936 1298 </tr>
dino@936 1299 <tr>
dino@936 1300 <td>height</td><td>length, percentage</td>
dino@936 1301 </tr>
dino@936 1302 <tr>
dino@936 1303 <td>left</td><td>length, percentage</td>
dino@936 1304 </tr>
dino@936 1305 <tr>
dino@936 1306 <td>letter-spacing</td><td>length</td>
dino@936 1307 </tr>
dino@936 1308 <tr>
dino@936 1309 <td>line-height</td><td>number, length, percentage</td>
dino@936 1310 </tr>
dino@936 1311 <tr>
dino@936 1312 <td>margin-bottom</td><td>length</td>
dino@936 1313 </tr>
dino@936 1314 <tr>
dino@936 1315 <td>margin-left</td><td>length</td>
dino@936 1316 </tr>
dino@936 1317 <tr>
dino@936 1318 <td>margin-right</td><td>length</td>
dino@936 1319 </tr>
dino@936 1320 <tr>
dino@936 1321 <td>margin-top</td><td>length</td>
dino@936 1322 </tr>
dino@936 1323 <tr>
dino@936 1324 <td>max-height</td><td>length, percentage</td>
dino@936 1325 </tr>
dino@936 1326 <tr>
dino@936 1327 <td>max-width</td><td>length, percentage </td>
dino@936 1328 </tr>
dino@936 1329 <tr>
dino@936 1330 <td>min-height</td><td>length, percentage</td>
dino@936 1331 </tr>
dino@936 1332 <tr>
dino@936 1333 <td>min-width</td><td>length, percentage</td>
dino@936 1334 </tr>
dino@936 1335 <tr>
dino@936 1336 <td>opacity</td><td>number</td>
dino@936 1337 </tr>
dino@936 1338 <tr>
dino@936 1339 <td>outline-color</td><td>color</td>
dino@936 1340 </tr>
dino@936 1341 <tr>
dino@936 1342 <td>outline-offset</td><td>integer</td>
dino@936 1343 </tr>
dino@936 1344 <tr>
dino@936 1345 <td>outline-width</td><td>length</td>
dino@936 1346 </tr>
dino@936 1347 <tr>
dino@936 1348 <td>padding-bottom</td><td>length</td>
dino@936 1349 </tr>
dino@936 1350 <tr>
dino@936 1351 <td>padding-left</td><td>length</td>
dino@936 1352 </tr>
dino@936 1353 <tr>
dino@936 1354 <td>padding-right</td><td>length</td>
dino@936 1355 </tr>
dino@936 1356 <tr>
dino@936 1357 <td>padding-top</td><td>length</td>
dino@936 1358 </tr>
dino@936 1359 <tr>
dino@936 1360 <td>right</td><td>length, percentage</td>
dino@936 1361 </tr>
dino@936 1362 <tr>
dino@936 1363 <td>text-indent</td><td>length, percentage</td>
dino@936 1364 </tr>
dino@936 1365 <tr>
dino@936 1366 <td>text-shadow</td><td>shadow</td>
dino@936 1367 </tr>
dino@936 1368 <tr>
dino@936 1369 <td>top</td><td>length, percentage</td>
dino@936 1370 </tr>
dino@936 1371 <tr>
dbaron@5245 1372 <td>vertical-align</td><td>length, percentage</td>
dino@936 1373 </tr>
dino@936 1374 <tr>
dino@936 1375 <td>visibility</td><td>visibility</td>
dino@936 1376 </tr>
dino@936 1377 <tr>
dino@936 1378 <td>width</td><td>length, percentage</td>
dino@936 1379 </tr>
dino@936 1380 <tr>
dino@936 1381 <td>word-spacing</td><td>length, percentage</td>
dino@936 1382 </tr>
dino@936 1383 <tr>
dino@936 1384 <td>z-index</td><td>integer</td>
dino@936 1385 </tr>
dino@936 1386 </table>
dino@936 1387
dbaron@2963 1388 <p class="issue">
dbaron@2963 1389 This list omits the following properties that Gecko can animate, and
dbaron@2963 1390 which likely should be included:
dbaron@2963 1391 background-size,
dbaron@2963 1392 border-*-radius,
dbaron@2963 1393 box-shadow,
dbaron@2963 1394 column-count,
dbaron@2963 1395 column-gap,
dbaron@2963 1396 column-rule-color,
dbaron@2963 1397 column-rule-width,
dbaron@2963 1398 column-width,
dbaron@2963 1399 font-size-adjust,
dbaron@2963 1400 font-stretch,
dbaron@2963 1401 marker-offset,
dbaron@2963 1402 text-decoration-color,
dbaron@4124 1403 transform,
dbaron@4124 1404 transform-origin.
dbaron@2963 1405 </p>
dbaron@2963 1406
fantasai@5332 1407 <h3 id=animatable-svg><a id=properties-from-svg->
dino@936 1408 Properties from SVG
fantasai@5332 1409 </a></h3>
dino@936 1410
dino@1469 1411 <p>
dino@1469 1412 All properties defined as animatable in the SVG specification, provided
dino@1469 1413 they are one of the property types listed above.
dino@1469 1414 </p>
dino@1469 1415
dino@1469 1416 <!-- <table>
dino@936 1417 <tr>
dino@936 1418 <th>Property Name</th><th>Type</th>
dino@936 1419 </tr>
dino@936 1420 <tr>
dino@936 1421 <td>stop-color</td><td>color</td>
dino@936 1422 </tr>
dino@936 1423 <tr>
dino@936 1424 <td>stop-opacity</td><td>float</td>
dino@936 1425 </tr>
dino@936 1426 <tr>
dino@936 1427 <td>fill</td><td>paint server</td>
dino@936 1428 </tr>
dino@936 1429 <tr>
dino@936 1430 <td>fill-opacity</td><td>float</td>
dino@936 1431 </tr>
dino@936 1432 <tr>
dino@936 1433 <td>stroke</td><td>paint server</td>
dino@936 1434 </tr>
dino@936 1435 <tr>
dino@936 1436 <td>stroke-dasharray</td><td>list of numbers</td>
dino@936 1437 </tr>
dino@936 1438 <tr>
dino@936 1439 <td>stroke-dashoffset</td><td>number</td>
dino@936 1440 </tr>
dino@936 1441 <tr>
dino@936 1442 <td>stroke-miterlimit</td><td>number</td>
dino@936 1443 </tr>
dino@936 1444 <tr>
dino@936 1445 <td>stroke-opacity</td><td>float</td>
dino@936 1446 </tr>
dino@936 1447 <tr>
dino@936 1448 <td>stroke-width</td><td>float</td>
dino@936 1449 </tr>
dino@936 1450 <tr>
dino@936 1451 <td>viewport-fill</td><td>color</td>
dino@936 1452 </tr>
dino@936 1453 <tr>
dino@936 1454 <td>viewport-fill-opacity</td><td>color</td>
dino@936 1455 </tr>
dino@1469 1456 </table> -->
dino@936 1457
dbaron@5312 1458 <h2 id="acknowledgments">Acknowledgments</h2>
dbaron@5312 1459
dbaron@5312 1460 <p>Thanks especially to the feedback from
dbaron@5312 1461 Tab Atkins,
dbaron@5316 1462 Aryeh Gregor,
dbaron@5316 1463 Vincent Hardy,
dbaron@5316 1464 Cameron McCormack,
dbaron@5316 1465 Alex Mogilevsky,
dbaron@5312 1466 and all the rest of the
dbaron@5312 1467 <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p>
dino@936 1468
dino@936 1469 <h2>References</h2>
dino@936 1470
dino@936 1471 <h3 class="no-num">Normative references</h3>
dino@936 1472 <!--normative-->
dino@936 1473
dino@936 1474 <h3 class="no-num">Other references</h3>
dino@936 1475 <!--informative-->
dino@936 1476
dino@936 1477
dino@936 1478
dino@936 1479 <h2 class="no-num">Property index</h2>
dino@936 1480 <!-- properties -->
dino@936 1481
dino@936 1482
dino@936 1483
dino@936 1484 <h2 class="no-num" id="index">Index</h2>
dino@936 1485 <!--index-->
dino@936 1486
dino@936 1487 </body>
dino@936 1488 </html>
dino@936 1489 <!-- Keep this comment at the end of the file
dino@936 1490 Local variables:
dino@936 1491 mode: sgml
dino@936 1492 sgml-default-doctype-name:"html"
dino@936 1493 sgml-minimize-attributes:t
dino@936 1494 End:
dino@936 1495 -->

mercurial