css-transitions/Overview.bs

Tue, 05 May 2015 14:18:12 -0700

author
Tab Atkins <jackalmage@gmail.com>
date
Tue, 05 May 2015 14:18:12 -0700
changeset 15501
48e00a20f418
parent 15492
85035644dbe0
child 15628
02844ef0064f
permissions
-rw-r--r--

[css-transitions] Remove unnecessary link default.

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

mercurial