css-transitions/Overview.bs

Fri, 23 Dec 2016 14:12:12 -0800

author
L. David Baron <dbaron@dbaron.org>
date
Fri, 23 Dec 2016 14:12:12 -0800
changeset 18576
b63d15c1c8f2
parent 18371
33e8db41720d
child 18691
61a574d3c7e5
permissions
-rw-r--r--

[css-transitions] Fix ambiguous reference for 'background-image', and link to latest css2 rather than css21.

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

mercurial