Skip to content

Commit 8acea35

Browse files
committed
[css-animations-2] Add CSSAnimation interface
1 parent 0d6f12d commit 8acea35

File tree

2 files changed

+225
-1
lines changed

2 files changed

+225
-1
lines changed

css-animations-2/Overview.bs

+78
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ Editor: L. David Baron, Mozilla, dbaron@dbaron.org
2929
Abstract: This CSS module describes a way for authors to animate the values of CSS properties over time, using keyframes. The behavior of these keyframe animations can be controlled by specifying their duration, number of repeats, and repeating behavior.
3030
</pre>
3131
<pre class="anchors">
32+
urlPrefix: https://w3c.github.io/web-animations/; type: interface; spec: web-animations
33+
text: Animation
34+
text: KeyframeEffectReadOnly
3235
urlPrefix: https://w3c.github.io/web-animations/; type: method; for: Animation; spec: web-animations
3336
text: play()
3437
text: pause()
38+
urlPrefix: https://w3c.github.io/web-animations/; type: method; for: KeyframeEffectReadOnly; spec: web-animations
39+
text: getFrames()
3540
urlPrefix: https://w3c.github.io/web-animations/; type: dfn; spec: web-animations
3641
text: animation playback rate
3742
text: current iteration
@@ -268,3 +273,76 @@ after the sample as follows:
268273
269274
Issue: Define the value of <code>elapsedTime</code> for each case.
270275
276+
# DOM interfaces # {#interface-dom}
277+
278+
## The CSSAnimation interface ## {#the-CSSAnimation-interface}
279+
280+
<pre class="idl">
281+
interface CSSAnimation : Animation {
282+
readonly attribute DOMString animationName;
283+
};
284+
</pre>
285+
286+
: <dfn attribute for=CSSAnimation>animationName</dfn>
287+
:: The key used to find matching keyframes rules that define <a>target
288+
effect</a> at the point when the animation was created.
289+
This is the value of the 'animation-name' property that caused this
290+
object to be generated.
291+
292+
<div class="issue">
293+
294+
We need to define a constructor for <a idl>CSSAnimation</a>.
295+
Perhaps something like the following:
296+
297+
<pre class="idl">
298+
[Constructor (DOMString animationName, DOMString defaultEasing)]
299+
partial interface CSSAnimation { };
300+
</pre>
301+
302+
The difficulty is with liveness. The most useful and least magical
303+
(but most complicated) approach is to define a subclass of
304+
{{KeyframeEffectReadOnly}} that has the special behavior of tracking changes
305+
to all @keyframes rules that match the supplied name and automatically
306+
updating the set of keyframes returned by
307+
{{KeyframeEffectReadOnly/getFrames()}} after filling in the default easing.
308+
309+
Something like,
310+
311+
<pre class="idl">
312+
[Constructor (DOMString keyframesName, DOMString defaultEasing)]
313+
interface CSSKeyframeEffectReadOnly : KeyframeEffectReadOnly {
314+
readonly attribute DOMString keyframesName;
315+
readonly attribute DOMString defaultEasing;
316+
};
317+
</pre>
318+
319+
</div>
320+
321+
## Requirements on pending style changes ## {#requirements-on-pending-style-changes}
322+
323+
Various operations may affect the <a lt="computed value">computed values</a> of
324+
properties on elements. User agents may, as an optimization, defer recomputing
325+
these values until it becomes necessary.
326+
However, all operations included in programming interface defined in this
327+
specification, as well as those operations defined in Web Animations
328+
[[!WEB-ANIMATIONS]] that may return objects defined by this specification,
329+
must produce a result consistent with having fully processed any such pending
330+
changes to computed values.
331+
332+
<div class="note">
333+
As an example, in the following code fragment, when the specified style of
334+
<code>elem</code> is initially updated, a user agent may defer recalculating
335+
the computed value of the 'animation' property.
336+
337+
However, the <code>getAnimations</code> method from the {{Element}} interface
338+
which is specified by [[!WEB-ANIMATIONS]] can return {{CSSAnimation}} objects as
339+
defined in this specification, and hence the user agent must calculate the
340+
updated value <code>elem</code>'s 'animation' property and create
341+
the requested {{CSSAnimation}} object before returning its result.
342+
343+
<div><pre class="example lang-javascript">
344+
elem.style.animation = 'fadeOut 1s';
345+
elem.getAnimations()[0].pause();
346+
</pre></div>
347+
348+
</div>

0 commit comments

Comments
 (0)