@@ -2801,6 +2801,11 @@ Animation effects {#animation-effects}
2801
2801
<code> max(min(<a>start delay</a> + <a>active duration</a> ,
2802
2802
<a for="animation effect">end time</a> ), 0)</code>
2803
2803
2804
+
2805
+ Furthermore, an <dfn>endpoint-inclusive active interval</dfn> flag
2806
+ may be specified when determining the phase.
2807
+ If not specified, it is assumed to be false.
2808
+
2804
2809
An [=animation effect=] is in the
2805
2810
<dfn export for="animation effect">before phase</dfn>
2806
2811
if the animation effect's [=local time=]
@@ -2809,7 +2814,8 @@ Animation effects {#animation-effects}
2809
2814
2810
2815
* the [=local time=] is less than the [=before-active boundary time=] ,
2811
2816
<em> or</em>
2812
- * the [=animation direction=] is “backwards”
2817
+ * the [=animation direction=] is “backwards”,
2818
+ the [=endpoint-inclusive active interval=] flag is false,
2813
2819
and the [=local time=] is equal to the [=before-active boundary time=] .
2814
2820
2815
2821
An [=animation effect=] is in the
@@ -2820,7 +2826,8 @@ Animation effects {#animation-effects}
2820
2826
2821
2827
* the [=local time=] is greater than the [=active-after boundary time=] ,
2822
2828
<em> or</em>
2823
- * the [=animation direction=] is “forwards”
2829
+ * the [=animation direction=] is “forwards”,
2830
+ the [=endpoint-inclusive active interval=] flag is false,
2824
2831
and the [=local time=] is equal to the [=active-after boundary time=] .
2825
2832
2826
2833
An [=animation effect=] is in the
@@ -3001,34 +3008,24 @@ Animation effects {#animation-effects}
3001
3008
</div>
3002
3009
3003
3010
<div class=example>
3004
- Alternatively, the author can set the specified style
3005
- at the start of the animation and then animate <em> from</em>
3006
- the original value as illustrated below:
3011
+ More conveniently, an {{Animation}} 's {{Animation/commitStyles}} method can
3012
+ be used to produce the same effect.
3007
3013
3008
3014
<pre highlight=javascript>
3009
- elem.style.transform = 'translateY(100px)' ;
3010
- elem.animate({ transform: 'none' , offset: 0 }, 200);
3015
+ elem.animate({ transform: 'translateY(100px)' }, 200).finished.then(() => {
3016
+ elem.commitStyles();
3017
+ });
3011
3018
</pre>
3012
3019
</div>
3013
3020
3014
3021
<div class=example>
3015
- Complex effects involving layering many animations on top of one another
3016
- could require temporary use of forwards fill modes
3017
- to capture the final value of an animation before canceling it.
3018
- For example:
3022
+ Alternatively, the author can set the specified style
3023
+ at the start of the animation and then animate <em> from</em>
3024
+ the original value as illustrated below:
3019
3025
3020
3026
<pre highlight=javascript>
3021
- elem.addEventListener('click' , async evt => {
3022
- const animation = elem.animate(
3023
- { transform: \`translate(${evt.clientX}px, ${evt.clientY}px)\` },
3024
- { duration: 800, fill: 'forwards' }
3025
- );
3026
- await animation.finished;
3027
- // commitStyles will record the style up to and including \`animation\` and
3028
- // update elem's specified style with the result.
3029
- animation.commitStyles();
3030
- animation.cancel();
3031
- });
3027
+ elem.style.transform = 'translateY(100px)' ;
3028
+ elem.animate({ transform: 'none' , offset: 0 }, 200);
3032
3029
</pre>
3033
3030
</div>
3034
3031
@@ -4890,6 +4887,28 @@ The {{Animation}} interface {#the-animation-interface}
4890
4887
calling this method <em> does</em> trigger a [=style change event=]
4891
4888
(see [[#model-liveness]] ).
4892
4889
4890
+ <div class=note>
4891
+
4892
+ In order to simplify the common case
4893
+ of persisting a completed animation,
4894
+ the procedure to [=commit computed styles=]
4895
+ uses endpoint-*inclusive* timing (see [[#interval-timing]] )
4896
+ when determining the phase of the animation
4897
+ (see [[#animation-effect-phases-and-states]] ).
4898
+
4899
+ As a result, the following code will persist
4900
+ the `transform: translateY(100px)` style in specified style
4901
+ despite not having a
4902
+ [=fill mode=] of [=fill mode/forwards=] or [=fill mode/both=] .
4903
+
4904
+ <pre highlight=javascript>
4905
+ elem.animate({ transform: 'translateY(100px)' }, 200).finished.then(() => {
4906
+ elem.commitStyles();
4907
+ });
4908
+ </pre>
4909
+
4910
+ </div>
4911
+
4893
4912
<div class=note>
4894
4913
4895
4914
Since the procedure to [=commit computed styles=]
@@ -4986,7 +5005,11 @@ The {{Animation}} interface {#the-animation-interface}
4986
5005
1. Let |effect value| be the result of calculating
4987
5006
the result of |partialEffectStack| for |property|
4988
5007
using |target|'s computed style
4989
- (see [[#calculating-the-result-of-an-effect-stack]] ).
5008
+ (see [[#calculating-the-result-of-an-effect-stack]] ) and
5009
+ setting the [=endpoint-inclusive active interval=] flag
5010
+ to true
5011
+ when calculating the animation effect phase
5012
+ (see [[#animation-effect-phases-and-states]] ).
4990
5013
4991
5014
1. [=Set a CSS declaration=] of |property| for |effect value|
4992
5015
in |inline style|.
0 commit comments