Skip to content

Commit 88aafc3

Browse files
authored
[web-animations-1] Add timeline to animate() options (#5013)
The options dictionary in `Element.animate` now has an optional nullable timeline member. This allows timeline to be set via that method in addition to Animation constructor. The semantic of handling explicit null and implicit/explicit undefined timelines are the same between the two methods. Here are some examples of how this may be used: ``` // Create animation with a null timeline. div.animate({color: 'red' }, { duration: 1000, timeline: null}); ``` ``` // Create a scroll-linked animation. div.animate({color: 'red' }, { duration: 1000, timeline: new ScrollTimeline()}); ```
1 parent 597ea0c commit 88aafc3

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

web-animations-1/Overview.bs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5789,6 +5789,7 @@ interface mixin Animatable {
57895789

57905790
dictionary KeyframeAnimationOptions : KeyframeEffectOptions {
57915791
DOMString id = "";
5792+
AnimationTimeline? timeline;
57925793
};
57935794

57945795
dictionary GetAnimationsOptions {
@@ -5813,17 +5814,21 @@ dictionary GetAnimationsOptions {
58135814
If the above procedure causes an exception to be thrown, propagate the
58145815
exception and abort this procedure.
58155816

5817+
1. If <var>options</var> is a {{KeyframeAnimationOptions}} object, let
5818+
<var>timeline</var> be the <code>timeline</code> member of
5819+
<var>options</var> or, if <code>timeline</code> member of
5820+
<var>options</var> is missing, be the <a>default document timeline</a>
5821+
of the <a>node document</a> of the element on which this method was
5822+
called.
5823+
58165824
1. Construct a new {{Animation}} object, <var>animation</var>, in
58175825
the <a>relevant Realm</a> of <var>target</var> by using the
58185826
same procedure as the {{Animation()}} constructor, passing
5819-
<var>effect</var> as the argument of the same name, and
5820-
the <a>default document timeline</a> of the <a>node document</a>
5821-
of the element on which this method was called as the
5822-
<var>timeline</var> argument.
5827+
<var>effect</var> and <var>timeline</var> as arguments of the same name.
58235828

58245829
1. If <var>options</var> is a {{KeyframeAnimationOptions}} object,
5825-
assign the value of the <code>id</code> member of <var>options</var> to
5826-
<var>animation</var>'s {{Animation/id}} attribute.
5830+
assign the value of the <code>id</code> member of <var>options</var>
5831+
to <var>animation</var>'s {{Animation/id}} attribute.
58275832

58285833
1. Run the procedure to <a>play an animation</a> for
58295834
<var>animation</var> with the <var>auto-rewind</var> flag set to true.
@@ -5856,10 +5861,8 @@ animation.play();</pre>
58565861
same interpretation as defined for that constructor.
58575862
: <dfn argument for="Animatable/animate(keyframes, options)"
58585863
lt="options">options</dfn>
5859-
:: The timing and animation options for the created {{KeyframeEffect}}.
5860-
This value is passed to the {{KeyframeEffect(target, keyframes,
5861-
options)}} constructor as the <var>options</var> parameter and has the
5862-
same interpretation as defined for that constructor.
5864+
:: The timing and animation options for the created {{KeyframeEffect}} and
5865+
{{Animation}}.
58635866

58645867
</div>
58655868

@@ -5910,6 +5913,13 @@ animation.play();</pre>
59105913
:: The string to assign to the generated {{Animation}}'s {{Animation/id}}
59115914
attribute.
59125915

5916+
: <dfn dict-member for=KeyframeAnimationOptions>timeline</dfn>
5917+
:: An optional value which, if present, specifies the <a>timeline</a>
5918+
with which to associate the newly-created <a>animation</a>.
5919+
If missing, the <a>default document timeline</a> of the
5920+
{{Document}} <a lt="document associated with a window">associated</a>
5921+
with the {{Window}} that is the <a>current global object</a> is used.
5922+
59135923
: <dfn dict-member for=GetAnimationsOptions>subtree</dfn>
59145924
:: If true, indicates that [=animations=] associated with an
59155925
[=animation effect=] whose [=target element=] is a [=descendant=]

0 commit comments

Comments
 (0)