Skip to content

Commit cd33568

Browse files
committed
[css-transitions-2] Add CSSTransition interface
1 parent 539cb0c commit cd33568

2 files changed

Lines changed: 293 additions & 17 deletions

File tree

css-transitions-2/Overview.bs

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ The <dfn>owning element</dfn> of a transition refers to the element or
5555
pseudo-element to which the 'transition-property' property was applied that
5656
generated the animation.
5757

58-
If a transition was generated directly by script then it has no <a>owning
59-
element</a>.
58+
If a transition was generated directly by script (e.g. using the
59+
{{CSSTransition}} constructor) then it has no <a>owning element</a>.
6060

6161
If a transition generated using the markup defined in this specification is
6262
later disassociated from that markup because it is cancelled or replaced by
@@ -70,9 +70,9 @@ cancel an animation).
7070

7171
## Animation composite order ## {#animation-composite-order}
7272

73-
<a spec='web-animations'>Animations</a> generated from the markup defined in
74-
this specification have an <a>animation type</a> of
75-
&lsquo;CSS Transition&rsquo;.
73+
<a spec='web-animations'>Animations</a> generated from the markup and
74+
interfaces (e.g. the {{CSSTransition}} constructor) defined in this
75+
specification have an <a>animation type</a> of &lsquo;CSS Transition&rsquo;.
7676

7777
CSS Transitions have an <em>earlier</em> composite order that CSS Animations
7878
and animations without a specific <a>animation type</a>.
@@ -120,10 +120,8 @@ Note, this behavior relies on the fact that disassociating a transition
120120
from its <a>owning element</a> always causes it to enter (or remain) in the
121121
<a>idle play state</a>.
122122

123-
<!--
124-
Transitions created using the {{CSSTransition()}} constructor are appended
123+
Transitions created using the {{CSSTransition}} constructor are appended
125124
to the <a>global animation list</a> at the moment they are constructed.
126-
-->
127125

128126
# Transition Events # {#transition-events}
129127

@@ -150,6 +148,65 @@ to the <a>global animation list</a> at the moment they are constructed.
150148
</ul>
151149
</dl>
152150

151+
# DOM Interfaces # {#DOM-interfaces}
152+
153+
## The CSSTransition interface ## {#the-CSSTransition-interface}
154+
155+
<pre class="idl">
156+
interface CSSTransition : Animation {
157+
readonly attribute DOMString transitionProperty;
158+
};
159+
</pre>
160+
161+
: <dfn attribute for=CSSTransition>transitionProperty</dfn>
162+
:: The <a>expanded transition property name</a> of this transition.
163+
164+
<div class="issue">
165+
166+
This interface needs a constructor. Perhaps something like the following,
167+
168+
<pre class="idl">
169+
[Constructor (Animatable? target,
170+
DOMString transitionProperty,
171+
any transitionValue,
172+
optional (unrestricted double or KeyframeEffectOptions) options),
173+
Constructor (Animatable? target,
174+
DOMString transitionProperty,
175+
any transitionValue,
176+
(unrestricted double or KeyframeEffectOptions) options,
177+
AnimationTimeline? timeline)]
178+
partial interface CSSTransition { };
179+
</pre>
180+
181+
Using <code>any</code> as the type for <code>transitionValue</code> would allow
182+
the following usage:
183+
184+
<pre class="example lang-javascript">
185+
var transition = new CSSTransition(elem, 'opacity', 1, 2000);
186+
transition.play();
187+
</pre>
188+
189+
The above example, however, is <em>not</em> equivalent to triggering a
190+
transition. It has the following differences:
191+
192+
* It does not update the specified style.
193+
* It would not cancel any existing transition on the given property unless
194+
we add special wording to that effect.
195+
* It would exhibit different composite order to a regular transition
196+
(this should be easily fixed, however).
197+
* It has been suggested that <a
198+
href="https://github.com/w3c/web-animations/issues/62#issuecomment-117357703">script-generated
199+
animations should not apply to the transition level of the cascade</a>.
200+
201+
It is unclear how much we should extend the {{CSSTransition}} constructor to
202+
overcome the above limitations so that it can be used to generate transitions
203+
programmatically, or whether we should introduce a separate helper method such
204+
as has been <a
205+
href="https://lists.w3.org/Archives/Public/www-style/2011Mar/0729.html">suggested
206+
elsewhere</a>.
207+
208+
</div>
209+
153210
<h2 id="issues-common">Issues commonly raised as issues with previous levels</h2>
154211

155212
<p>

0 commit comments

Comments
 (0)