- Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathOverview.bs
1406 lines (1268 loc) · 59.2 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<style type="text/css">
div.prod { margin: 1em 2em; }
table.event-handlers {
border-collapse: collapse;
}
table.event-handlers th,
table.event-handlers td {
padding: 0.2em 1em;
}
table.event-handlers td {
border: 1px solid black;
}
</style>
<pre class="metadata">
Title: CSS Transitions Level 1
Status: ED
Work Status: Refining
Shortname: css-transitions
Group: csswg
Level: 1
TR: https://www.w3.org/TR/css-transitions-1/
Previous version: https://www.w3.org/TR/2018/WD-css-transitions-1-20181011/
Previous version: https://www.w3.org/TR/2017/WD-css-transitions-1-20171130/
Previous version: https://www.w3.org/TR/2013/WD-css3-transitions-20131119/
ED: https://drafts.csswg.org/css-transitions/
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Editor: Dean Jackson, Apple Inc https://www.apple.com/, dino@apple.com, w3cid 42080
Editor: Brian Birtles, Mozilla https://www.mozilla.org/, bbirtles@mozilla.com, w3cid 43194
Former Editor: David Hyatt, Apple Inc https://www.apple.com/, hyatt@apple.com, w3cid 34140
Former Editor: Chris Marrin, Apple Inc https://www.apple.com/, cmarrin@apple.com
Issue Tracking: Bugzilla bugs for all levels https://www.w3.org/Bugs/Public/buglist.cgi?product=CSS&component=Transitions&resolution=---
Test Suite: https://wpt.fyi/results/css/css-transitions
Abstract: CSS Transitions allows property changes in CSS values to occur smoothly over a specified duration.
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.
Ignored Vars: x1, x2, y1, y2
Link Defaults: css-transforms (property) transform
</pre>
<pre class="link-defaults">
spec:css22; type:property;
text:top
text:right
text:bottom
text:left
text:margin-top
text:margin-right
text:margin-bottom
text:margin-left
text:padding-top
text:padding-right
text:padding-bottom
text:padding-left
text:border-top-color
text:border-right-color
text:border-bottom-color
text:border-left-color
text:border-top-width
text:border-right-width
text:border-bottom-width
text:border-left-width
text:background-color
text:background-position
text:border-spacing
text:width
text:height
text:min-width
text:min-height
text:max-width
text:max-height
text:clip
text:letter-spacing
text:line-height
text:outline-color
text:outline-width
text:text-indent
text:font-size
text:font-weight
text:vertical-align
text:visibility
text:word-spacing
text:z-index
spec:css-backgrounds-3; type:property;
text:background-image
text:background-origin
spec:css-color-4;
type:property;
text:color
text:opacity
type:value
text:green
text:blue
text:transparent
spec:css-values-3; type:type; text:<time>
</pre>
<!-- FIXME: These overrides aren't great for dev/TR switching -->
<pre class="anchors">
url: https://www.w3.org/TR/css3-background/#shadow-inset; type: value; for: shadow; text: inset;
url: https://www.w3.org/TR/css3-background/#box-shadow-none; type: value; for: shadow; text: none;
url: https://www.w3.org/TR/CSS21/visufx.html#propdef-visibility; type: value; for: visibility; text: visible;
urlPrefix: https://www.w3.org/TR/css3-color/; type: value;
text: transparent
text: blue
text: green
url: http://w3c.github.io/dom/#constructing-events; type: dfn; text: event constructor;
urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn; spec: html
text: event handlers
text: event handler event type
text: event handler content attributes
text: event handler IDL attributes
urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn; spec: html
text: HTML elements
text: dispatch; url: concept-event-dispatch
url: https://html.spec.whatwg.org/#document; type: interface; text: Document; spec: html
</pre>
Introduction {#introduction}
============================
<p><em>This section is not normative.</em>
<p>
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.
</p>
Value Definitions {#values}
-----------------
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.
<span id="transitions-">Transitions</span> {#transitions}
=========================================================
<p>
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 gradual transitions using new CSS properties. These properties are used to animate smoothly from the old state to the new state over time.
</p>
<p>
For example, suppose that transitions of one second have been defined on the 'left' and
'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.
</p>
<figure>
<img src="images/transition-example.svg" width="518"
alt="Example showing the initial, intermediate, and final states of a box whose color and position is interpolated">
<figcaption>
Transitions of 'left' and 'background-color'.
</figcaption>
</figure>
<p>
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.
</p>
<p>
The transition for a property is defined using a number of new properties. For example:
</p>
<div class="example">
<p style="display:none">
Example(s):
</p>
<pre>
div {
transition-property: opacity;
transition-duration: 2s;
}
</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.
</div>
<p>
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:
</p>
<div class="example">
<p style="display:none">
Example(s):
</p>
<pre>
div {
transition-property: opacity, left;
transition-duration: 2s, 4s;
}
</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.
</div>
<p id="list-matching">
In the case where the lists of values in transition properties
do not have the same length, the length of the
'transition-property' list determines the number of items in
each list examined when starting transitions. The lists are
matched up from the first value: excess values at the end are
not used. If one of the other properties doesn't have enough
comma-separated values to match the number of values of
'transition-property', the user agent must calculate its used value by
repeating the list of values until there are enough. This
truncation or repetition does not affect the computed value.
<span class="note">
Note: This is analogous to the behavior of the 'background-*'
properties, with 'background-image' analogous to
'transition-property'.
</span>
</p>
<div class="example">
<p style="display:none">
Example(s):
</p>
<pre>
div {
transition-property: opacity, left, top, width;
transition-duration: 2s, 1s;
}
</pre>The above example defines a transition on the 'opacity' property of 2 seconds duration, a
transition on the 'left' property of 1
second duration, a transition on the 'top' property of 2 seconds duration and a
transition on the 'width' property of 1
second duration.
</div>
<p>
While authors can use transitions to create dynamically changing content,
dynamically changing content can lead to seizures in some users.
For information on how to avoid content that can lead to seizures, see
<a href="https://www.w3.org/TR/WCAG20/#seizure">Guideline 2.3:
Seizures:
Do not design content in a way that is known to cause seizures</a>
([[WCAG20]]).
</p>
<span id="the-transition-property-property-">The 'transition-property' Property</span> {#transition-property-property}
----------------------------------------------------------------------------------------------------------------------
<p>
The 'transition-property' property specifies the name of the CSS property to which the transition is applied.
</p>
<pre class="propdef">
Name: transition-property
Value: none | <<single-transition-property>>#
Initial: all
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: the keyword ''transition-property/none'' else a list of identifiers
Animation type: not animatable
</pre>
<div class="prod">
<dfn type id="single-transition-property"><single-transition-property></dfn> = ''transition-property/all'' | <<custom-ident>>
</div>
<p>
A value of
<dfn value for="transition-property">none</dfn>
means that no property will transition.
Otherwise, a list of properties to be transitioned, or the
keyword <dfn value for="transition-property">all</dfn>
which indicates that all properties are to be
transitioned, is given.
</p>
<p>
If one of the identifiers listed is not a recognized property
name, the implementation must
still start transitions on the animatable properties in the
list using the duration, delay, and timing function at their
respective indices in the lists for 'transition-duration',
'transition-delay', and 'transition-timing-function'. In other
words, unrecognized properties must be kept in
the list to preserve the matching of indices.
</p>
<p>
The <<custom-ident>> production in <<single-transition-property>>
also excludes the keyword ''transition-property/none'',
in addition to the keywords always excluded from <<custom-ident>>.
This means that
''transition-property/none'', ''inherit'', and ''initial'' are not
permitted as items within a list of more that one identifier;
any list that uses them is syntactically invalid.
</p>
<p>
For the keyword ''transition-property/all'',
or if one of the identifiers listed is a
shorthand property, implementations must start transitions for
all its longhand sub-properties (or, for
''transition-property/all'', all properties), using the duration, delay,
and timing function at the index corresponding to the shorthand.
</p>
<p>
If a property is specified multiple times in the value of
'transition-property' (either on its own, via a shorthand that
contains it, or via the ''transition-property/all'' value), then the transition that
starts uses the duration, delay, and timing function at the
index corresponding to the <em>last</em> item in the value of
'transition-property' that calls for animating that property.
</p>
<p class="note">
Note: The ''transition-property/all'' value and 'all' shorthand
property work in similar ways, so the
''transition-property/all'' value is just like a shorthand that
covers all properties.
</p>
<span id="the-transition-duration-property-">The 'transition-duration' Property</span> {#transition-duration-property}
----------------------------------------------------------------------------------------------------------------------
<p>
The 'transition-duration' property defines the length of time that a transition takes.
</p>
<pre class="propdef">
Name: transition-duration
Value: <<time [0s,∞]>>#
Initial: ''0s''
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: list, each item a duration
Animation type: not animatable
</pre>
<p>
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.
</p>
<span id="transition-timing-function_tag">The 'transition-timing-function' Property</span> {#transition-timing-function-property}
---------------------------------------------------------------------------------------------------------------------------------
<p>
The 'transition-timing-function' property
describes how the intermediate values used during a transition will be
calculated. It allows for a transition to change speed over its
duration. These effects are commonly called <em>easing</em> functions.
</p>
<p>
Timing functions are defined in the separate CSS Easing Functions module
[[!css-easing-1]].
The <a spec=css-easing>input progress value</a> used is the percentage
of the transition duration, and the <a spec=css-easing>output progress
value</a> is used as the <var>p</var> value when [=interpolating=]
the property value (see [[#application]]).
</p>
<pre class="propdef">
Name: transition-timing-function
Value: <<easing-function>>#
Initial: ''transition-timing-function/ease''
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: as specified
Animation type: not animatable
</pre>
<span id="the-transition-delay-property-">The 'transition-delay' Property</span> {#transition-delay-property}
-------------------------------------------------------------------------------------------------------------
<p>
The 'transition-delay' property defines when the transition will start. It allows a transition to begin execution after 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.
</p>
<p>
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.
</p>
<pre class="propdef">
Name: transition-delay
Value: <<time>>#
Initial: ''0s''
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: list, each item a duration
Animation type: not animatable
</pre>
<span id="the-transition-shorthand-property-">The 'transition' Shorthand Property</span> {#transition-shorthand-property}
-------------------------------------------------------------------------------------------------------------------------
<p>
The 'transition' shorthand property combines the four properties described above into a single property.
</p>
<pre class="propdef shorthand">
Name: transition
Value: <<single-transition>>#
Applies to: all elements
Inherited: no
Percentages: N/A
Animation type: not animatable
</pre>
<div class="prod">
<dfn type id="single-transition"><single-transition></dfn> = [ ''transition-property/none'' | <<single-transition-property>> ] || <<time>> || <<easing-function>> || <<time>>
</div>
<p>
Note that order is important within the items in this property:
the first value that can be parsed as a time is assigned to the
transition-duration,
and the second value that can be parsed as a time is assigned to
transition-delay.
</p>
<p>
If there is more than one <<single-transition>> in the shorthand,
and any of the transitions has
''transition-property/none'' as the <<single-transition-property>>,
then the declaration is invalid.
</p>
Starting of transitions {#starting}
===================================
<p>
Implementations must maintain a set of
<dfn export lt="running transition">running transitions</dfn>,
each of which applies to a specific element and non-shorthand
property. Each of these transitions also has a
<dfn export for="transition">start time</dfn>, <dfn export for="transition">end time</dfn>,
<dfn export for="transition">start value</dfn>, <dfn export for="transition">end value</dfn>,
<dfn export for="transition">reversing-adjusted start value</dfn>, and <dfn export for="transition">reversing shortening factor</dfn>.
Transitions are added to this set as described in this section,
and are removed from this set
when they <a>complete</a>
or when implementations are required to <dfn export for="transition">cancel</dfn> them.
<span class="note">
For the rationale behind the <a>reversing-adjusted start value</a>
and <a>reversing shortening factor</a>, see [[#reversing]].
</span>
</p>
<p>
Implementations must also maintain a set of
<dfn export lt="completed transition">completed transitions</dfn>,
each of which
(like <a>running transitions</a>)
applies to a specific element and non-shorthand property.
<span class="note">
This specification maintains the invariant that
there is never both a <a>running transition</a> and
a <a>completed transition</a> for the same property and element.
</span>
</p>
<p>
If an element is no longer in the document,
implementations must <a>cancel</a> any <a>running transitions</a>
on it and remove transitions on it from the
<a>completed transitions</a>.
</p>
<div class="note">
<p>
This set of completed transitions
needs to be maintained
in order to prevent
transitions from repeating themselves in certain cases,
i.e., to maintain the invariant
that this specification tries to maintain
that unrelated style changes do not trigger transitions.
</p>
<p class="example">
An example where maintaining the set of completed transitions
is necessary would be a transition on
an inherited property,
where the parent specifies a transition of that property for
a longer duration (say, ''transition: 4s text-indent'')
and a child element that inherits the parent's value specifies
a transition of the same property for a shorter duration
(say, ''transition: 1s text-indent'').
Without the maintenance of this set of completed transitions,
implementations could start additional transitions on the child
after the initial 1 second transition on the child completes.
</p>
</div>
<p>
Various things can cause the <a>computed values</a> of properties
on an element to change.
These include
insertion and removal of elements from the document tree
(which both changes whether those elements have <a>computed values</a> and
can change the styles of other elements through selector matching),
changes to the document tree that cause
changes to which selectors match elements,
changes to style sheets or style attributes,
and other things.
This specification does not define when <a>computed values</a> are updated,
beyond saying that implementations must not
use, present, or display something resulting from the CSS
cascading, value computation, and inheritance process [[!CSS3CASCADE]]
without updating the <a>computed value</a>
(which means merely that implementations cannot avoid
meeting requirements of this specification
by claiming not to have updated the <a>computed value</a>
as part of handling a style change).
However,
when an implementation updates the <a>computed value</a> of a
property on an element
to reflect one of these changes,
or computes the <a>computed value</a> of a property on an element
newly added to the document,
it must update the <a>computed value</a>
for all properties and elements to reflect all
of these changes at the same time
(or at least it must be undetectable that it was done at a
different time).
This processing of a set of simultaneous style changes is called a
<dfn export>style change event</dfn>.
(Implementations typically have a <a>style change event</a> to
correspond with their desired screen refresh rate,
and when up-to-date computed style or layout information is needed
for a script API that depends on it.)
</p>
<p>
Since this specification does not define
when a <a>style change event</a> occurs,
and thus what changes to computed values are considered simultaneous,
authors should be aware that changing any of the transition
properties a small amount of time after making a change that
might transition can result in behavior that varies between
implementations, since the changes might be considered
simultaneous in some implementations but not others.
</p>
<p>
When a <a>style change event</a> occurs,
implementations must start transitions based on
the <a>computed values</a> that changed in that event.
If an element is not in the document during that
style change event or was not in the document during
the previous style change event,
then transitions are not started for that element
in that style change event.
Otherwise,
define the <dfn export>before-change style</dfn> as
the <a>computed values</a> of all properties on the element as of
the previous <a>style change event</a>,
except with any styles derived from declarative
animations such as CSS Transitions, CSS Animations
([[CSS3-ANIMATIONS]]),
and SMIL Animations ([[SMIL-ANIMATION]], [[SVG11]])
updated to the current time.
Likewise, define the <dfn export>after-change style</dfn> as
the <a>computed values</a> of all properties
on the element based on the information
known at the start of that <a>style change event</a>,
but using the computed values of the 'animation-*' properties from the
<a>before-change style</a>,
excluding any styles from CSS Transitions in the computation,
and inheriting from
the <a>after-change style</a> of the parent.
Note that this means the <a>after-change style</a> does not differ from
the <a>before-change style</a> due to newly created or canceled CSS
Animations.
</p>
<div class="note">
<p>
Note that this definition of the <a>after-change style</a>
means that a single change
can start a transition on the same property
on both an ancestor element and its descendant element.
This can happen when a property change is inherited
from one element with 'transition-*' properties
that say to animate the changing property
to another element with 'transition-*' properties
that also say to animate the changing property.
</p>
<p>
When this happens, both transitions will run,
and the transition on the descendant will override
the transition on the ancestor
because of the normal
CSS cascading and inheritance rules ([[CSS3CASCADE]]).
</p>
<p>
If the transition on the descendant completes before
the transition on the ancestor,
the descendant will then resume inheriting
the (still transitioning) value from its parent.
This effect is likely not a desirable effect,
but it is essentially doing what the author asked for.
</p>
</div>
<p>
For each element with a <a>before-change style</a> and
an <a>after-change style</a>,
and each property (other than shorthands),
define the <dfn export>matching transition-property value</dfn> as
the last value in the
'transition-property' in the element's <a>after-change style</a>
that matches the property,
as described in
[[#transition-property-property]].
If there is such a value, then corresponding to it, there is
a <dfn export>matching transition duration</dfn>,
a <dfn export>matching transition delay</dfn>, and
a <dfn export>matching transition timing function</dfn>
in the values in the <a>after-change style</a> of
'transition-duration', 'transition-delay', and 'transition-timing-function'
(see <a href="#list-matching">the rules on matching lists</a>).
Define the <dfn export for="transition">combined duration</dfn> of the transition
as the sum of max(<a>matching transition duration</a>, ''0s'') and
the <a>matching transition delay</a>.
</p>
When comparing the [=before-change style=] and [=after-change style=]
for a given property,
the property values are <dfn>transitionable</dfn>
if they have an [=animation type=] that is
<em>neither</em>[=not animatable=]<em>nor</em>[=discrete=].
Note: Even if a <em>property</em> is defined to have an [=animation type=]
that is <em>not</em>[=discrete=],
for a particular pair of <em>property values</em>
the [=animation type=] may be [=discrete=].
For example,
the [=animation type=] of the 'box-shadow' property is
<a lt="combining shadow lists">shadow list</a>,
which defines that
when the ''shadow/inset'' keyword is absent in one value
but present in the other,
[=discrete=] animation is used.
As a result
''0px 0px black'' and ''inset 10px 10px black''
are <em>not</em>[=transitionable=].
For each element and property, the implementation must act
as follows:
<ol>
<li>
If all of the following are true:
<ul>
<li>
the element does not have
a <a>running transition</a> for the property,
</li>
<li>
the <a>before-change style</a> is different from
the <a>after-change style</a> for that property,
and the values for the property are [=transitionable=],
</li>
<li>
the element does not have a <a>completed transition</a>
for the property
or the <a>end value</a> of the <a>completed transition</a>
is different from the <a>after-change style</a> for the property,
</li>
<li>
there is a <a>matching transition-property value</a>, and
</li>
<li>
the <a>combined duration</a> is greater than ''0s'',
</li>
</ul>
then implementations must
remove the <a>completed transition</a> (if present) from the set
of completed transitions and
start a transition whose:
<ul>
<li>
<a>start time</a> is
the time of the <a>style change event</a> plus
the <a>matching transition delay</a>,
</li>
<li>
<a>end time</a> is
the <a>start time</a> plus
the <a>matching transition duration</a>,
</li>
<li>
<a>start value</a> is
the value of the transitioning property
in the <a>before-change style</a>,
</li>
<li>
<a>end value</a> is
the value of the transitioning property
in the <a>after-change style</a>,
</li>
<li>
<a>reversing-adjusted start value</a> is the same as
the <a>start value</a>, and
<li>
<a>reversing shortening factor</a> is 1.
</li>
</ul>
</li>
<li>
Otherwise,
if the element has a <a>completed transition</a> for the property
and the <a>end value</a> of the <a>completed transition</a>
is different from the <a>after-change style</a> for the property,
then implementations must
remove the <a>completed transition</a> from the set of
<a>completed transitions</a>.
</li>
<li>
If the element has a <a>running transition</a> or
<a>completed transition</a> for the property,
and there is <strong>not</strong>
a <a>matching transition-property value</a>,
then implementations must
<a>cancel</a> the <a>running transition</a>
or remove the <a>completed transition</a> from the set of
<a>completed transitions</a>.
</li>
<li>
If the element has a <a>running transition</a> for the property,
there is a <a>matching transition-property value</a>,
and the <a>end value</a> of the <a>running transition</a> is
<strong>not</strong> equal to the value of the property in the
<a>after-change style</a>, then:
<ol>
<li>
If the <a>current value</a> of the property
in the <a>running transition</a>
is equal to
the value of the property in the <a>after-change style</a>,
or if these two values are not [=transitionable=],
then implementations must
<a>cancel</a> the <a>running transition</a>.
</li>
<li>
Otherwise, if the <a>combined duration</a> is
less than or equal to ''0s'',
or if the
<a>current value</a> of the property in the <a>running transition</a>
is not [=transitionable=] with
the value of the property in the <a>after-change style</a>,
then implementations must
<a>cancel</a> the <a>running transition</a>.
</li>
<li>
Otherwise, if the <a>reversing-adjusted start value</a>
of the <a>running transition</a> is the same as the value of
the property in the <a>after-change style</a>
<span class="note">(see the
<a href="#reversing">section on reversing of
transitions</a> for why these case exists)</span>,
implementations must
<a>cancel</a> the <a>running transition</a> and
start a new transition whose:
<ul>
<li>
<a>reversing-adjusted start value</a> is
the <a>end value</a> of the
<a>running transition</a>
<span class="note">(Note: This represents the logical start state of
the transition, and allows some calculations to ignore that
the transition started before that state was reached, which
in turn allows repeated reversals of the same transition to
work correctly),</span>
<li>
<a>reversing shortening factor</a>
is the absolute value, clamped to the range [0, 1],
of the sum of:
<ol>
<li>the output of the timing function of the old transition
at the time of the <a>style change event</a>,
times the <a>reversing shortening factor</a> of the
old transition</li>
<li>1 minus the <a>reversing shortening factor</a> of
the old transition.</li>
</ol>
<span class="note">Note: This represents the portion of the
space between the <a>reversing-adjusted start value</a>
and the <a>end value</a> that the old transition has
traversed (in amounts of the value, not time), except with the
absolute value and clamping to handle timing functions that
have y1 or y2 outside the range [0, 1].</span>
</li>
<li>
<a>start time</a> is
the time of the <a>style change event</a> plus:
<ol>
<li>if the <a>matching transition delay</a>
is nonnegative,
the <a>matching transition delay</a>, or
<li>if the <a>matching transition delay</a>
is negative,
the product of
the new transition's
<a>reversing shortening factor</a> and
the <a>matching transition delay</a>,
</ol>
</li>
<li>
<a>end time</a> is
the <a>start time</a> plus the product of
the <a>matching transition duration</a> and
the new transition's <a>reversing shortening factor</a>,
</li>
<li>
<a>start value</a> is
the <a>current value</a> of the property
in the <a>running transition</a>,
</li>
<li>
<a>end value</a> is
the value of the property
in the <a>after-change style</a>,
</li>
</ul>
</li>
<li>
Otherwise, implementations must
<a>cancel</a> the <a>running transition</a>
and start a new transition whose:
<ul>
<li>
<a>start time</a> is
the time of the <a>style change event</a> plus
the <a>matching transition delay</a>,
</li>
<li>
<a>end time</a> is
the <a>start time</a> plus
the <a>matching transition duration</a>,
</li>
<li>
<a>start value</a> is
the <a>current value</a> of the property
in the <a>running transition</a>,
</li>
<li>
<a>end value</a> is
the value of the property
in the <a>after-change style</a>,
</li>
<li>
<a>reversing-adjusted start value</a> is the same as
the <a>start value</a>, and
<li>
<a>reversing shortening factor</a> is 1.
</li>
</ul>
</li>
</ol>
</li>
</ol>
<div class="note">
<p>
Note that the above rules mean that
when the computed value of an animatable property changes,
the transitions that start are based on the
values of the 'transition-property', 'transition-duration',
'transition-timing-function', and 'transition-delay' properties
at the time the animatable property would first have its new
computed value.
This means that when one of these 'transition-*' properties
changes at the same time as
a property whose change might transition,
it is the <em>new</em> values of the 'transition-*' properties
that control the transition.
</p>
<div class="example" id="manual-reversing-example">
<p style="display:none">
Example(s):
</p>
<p>This provides a way for authors to specify different values
of the 'transition-*' properties for the “forward”
and “reverse” transitions,
when the transitions are between two states
(but see <a
href="#reversing">below</a> for special reversing behavior when
an <em>incomplete</em> transition is interrupted). Authors can
specify the value of 'transition-duration',
'transition-timing-function', or 'transition-delay' in the same
rule where they specify the value that triggers the transition,
or can change these properties at the same time as they change
the property that triggers the transition. Since it's the new
values of these 'transition-*' properties that affect the
transition, these values will be used for the transitions
<em>to</em> the associated transitioning values. For example:
</p>
<pre>
li {
transition: background-color linear 1s;
background: blue;
}
li:hover {
background-color: green;
transition-duration: 2s; /* applies to the transition *to* the :hover state */
}</pre>
<p>
When a list item with these style rules enters the :hover
state, the computed 'transition-duration' at the time that
'background-color' would have its new value (''green'') is ''2s'',
so the transition from ''blue'' to ''green'' takes 2 seconds.
However, when the list item leaves the :hover state, the
transition from ''green'' to ''blue'' takes 1 second.
</p>
</div>
</div>
<p class="note">
Note that once the transition of a property has started
(including being in its delay phase),
it continues running based on
the original timing function, duration, and
delay, even if the 'transition-timing-function',
'transition-duration', or 'transition-delay' property changes
before the transition is complete. However, if the
'transition-property' property changes such that the transition
would not have started, the transition stops (and the
property immediately changes to its final value).
</p>
<p class="note">
Note that above rules mean that
transitions do not start when the computed
value of a property changes as a result of declarative animation
(as opposed to scripted animation).
This happens because the before-change style includes up-to-date
style for declarative animations.
</p>
Faster reversing of interrupted transitions {#reversing}
--------------------------------------------------------
<div class="note">
<p>
Many common transitions effects involve transitions between two states,
such as the transition that occurs when the mouse pointer moves
over a user interface element, and then later moves out of that element.
With these effects, it is common for a running transition
to be interrupted before it completes,
and the property reset to the starting value of that transition.
An example is a hover effect on an element,
where a transition starts when the pointer enters the element,
and then the pointer exits the element before the effect has completed.
If the outgoing and incoming transitions
are executed using their specified durations and timing functions,
the resulting effect can be distractingly asymmetric
because the second transition
takes the full specified time to move a shortened distance.
Instead, this specification makes second transition shorter.
</p>
<p>
The mechanism the above rules use to cause this involves the
<a>reversing shortening factor</a> and the
<a>reversing-adjusted start value</a>.
In particular, the reversing behavior is present whenever
the <a>reversing shortening factor</a> is less than 1.
</p>
<p class="note">
Note that these rules do not fully address the problem for
transition patterns that involve more than two states.
</p>
<p class="note">
Note that these rules lead to the entire timing function of the
new transition being used, rather than jumping into the middle
of a timing function, which can create a jarring effect.
</p>
<p class="note">
This was one of several possibilities that was considered by the
working group. See the
<a href="examples/transition-reversing-demo">reversing demo</a>
demonstrating a number of them, leading to a working group
resolution made on 2013-06-07 and edits made on 2013-11-11.
</p>
</div>
Application of transitions {#application}
=========================================
<p>
When a property on an element is undergoing a transition
(that is, when or after the transition has started and before the
<a>end time</a> of the transition)
the transition adds a style called the <dfn export>current value</dfn>
to the CSS cascade
at the level defined for CSS Transitions in [[!CSS3CASCADE]].
</p>
<p class="note">
Note that this means that computed values
resulting from CSS transitions
can inherit to descendants just like
any other computed values.