css-transitions/Overview.bs

Wed, 03 Feb 2016 15:17:31 +1100

author
L. David Baron <dbaron@dbaron.org>
date
Wed, 03 Feb 2016 15:17:31 +1100
changeset 17009
1577b3ccd54b
parent 16989
255258410d1b
child 17011
3751a4bf606e
permissions
-rw-r--r--

[css-transitions] Fix bikeshed ignored vars warning.

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

mercurial