css-transitions/Overview.bs

Fri, 29 May 2015 16:46:19 -0700

author
Tab Atkins <jackalmage@gmail.com>
date
Fri, 29 May 2015 16:46:19 -0700
changeset 15674
0f4bf02e8b70
parent 15658
077f1626ecc1
child 16002
bec42e8ed638
permissions
-rw-r--r--

Add 'Work Status' metadata to all Bikeshed source files. Some files also accidentally got whitespace fixes, whoops.

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

mercurial