Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1082896 of KeyframeEffect

  • Revision slug: Web/API/KeyframeEffect
  • Revision title: KeyframeEffect
  • Revision id: 1082896
  • Created:
  • Creator: rachelnabors
  • Is current revision? No
  • Comment

Revision Content

{{SeeCompatTable}}{{ APIRef("Web Animations API") }}

The KeyframeEffect interface of the Web Animations API lets us create sets of animatable properties and values, called keyframes. These can then be played using the {{domxref("Animation.Animation()")}} constructor.

Constructor

{{domxref("KeyframeEffect.KeyframeEffect()")}}
Returns a new KeyframeEffect object instance.

Properties

This interface inherits some of its methods and properties from its parent, {{domxref("KeyframeEffectReadOnly")}}, and its grandparent {{domxref("AnimationEffectReadOnly")}}.

{{domxref("KeyframeEffect.target")}}
Gets and sets the element or pseudo-element being animated by this object. This may be null for animations that do not target a specific element.
{{domxref("KeyframeEffect.iterationComposite")}}
Gets and sets the iteration composite operation for resolving the property value changes of this keyframe effect.
{{domxref("KeyframeEffect.composite")}}
Gets and sets the composite operation property for resolving the property value changes between this and other keyframe effects.
{{domxref("KeyframeEffect.spacing")}}
Gets and sets the temporal spacing of the keyframe effect's iterations.

Methods

{{domxref("KeyframeEffect.getKeyframes()")}}
Returns the computed keyframes that make up this effect along with their computed keyframe offsets.
{{domxref("KeyframeEffect.setKeyframes()")}}
Replaces the set of keyframes that make up this effect.
{{domxref("AnimationEffectReadOnly.getComputedTiming()")}}
Returns the calculated, current timing values for this keyframe effect.

Examples

In the Follow the White Rabbit example, the KeyframeEffect constructor is used to create a set of keyframes that dictate how the White Rabbit should animate down the hole:

 var rabbitDownKeyframes = new KeyframeEffect( 
    whiteRabbit, // element to animate
    [
      { transform: 'translateY(0%)' }, // keyframe 
      { transform: 'translateY(100%)' } // keyframe
    ], 
    { duration: 3000, fill: 'forwards' } // keyframe options
  );

Specifications

Specification Status Comment
{{SpecName('Web Animations', '#the-keyframeeffect-interfaces', 'keyframeEffect' )}} {{Spec2('Web Animations')}} Editor's draft.

Browser compatibility

{{CompatibilityTable}}

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatUnknown}} {{CompatGeckoDesktop(47)}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

  • Web Animations API
  • Inherits from {{domxref("KeyframeEffectReadOnly")}} and its parent {{domxref("AnimationEffectReadOnly")}} .
  • {{domxref("Animation")}}

Revision Source

<p>{{SeeCompatTable}}{{ APIRef("Web Animations API") }}</p>

<p>The <strong><code>KeyframeEffect</code></strong> interface of the <a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> lets us create sets of animatable properties and values, called <strong>keyframes. </strong>These can then be played using the&nbsp;{{domxref("Animation.Animation()")}} constructor.</p>

<h2 id="Constructor">Constructor</h2>

<dl>
 <dt>{{domxref("KeyframeEffect.KeyframeEffect()")}}</dt>
 <dd>Returns a new <code>KeyframeEffect</code> object instance.</dd>
</dl>

<h2 id="Properties">Properties</h2>

<p><em>This interface inherits some of its methods and properties from its parent,</em>&nbsp;{{domxref("KeyframeEffectReadOnly")}}, and its grandparent&nbsp;{{domxref("AnimationEffectReadOnly")}}<em>.</em></p>

<dl>
 <dt>{{domxref("KeyframeEffect.target")}}</dt>
 <dd>Gets and sets the element or pseudo-element being animated by this object.&nbsp;This may be <code>null</code> for animations that do not target a specific element.</dd>
 <dt>{{domxref("KeyframeEffect.iterationComposite")}}</dt>
 <dd>Gets and sets the iteration composite operation for resolving the property value changes&nbsp;of this keyframe effect.</dd>
 <dt>{{domxref("KeyframeEffect.composite")}}</dt>
 <dd>Gets and sets the composite operation property for resolving the property value changes&nbsp;between this and other&nbsp;keyframe effects.</dd>
 <dt>{{domxref("KeyframeEffect.spacing")}}</dt>
 <dd>Gets and sets the temporal spacing of the keyframe effect's iterations.</dd>
</dl>

<h3 id="Methods">Methods</h3>

<dl>
 <dt>{{domxref("KeyframeEffect.getKeyframes()")}}</dt>
 <dd>Returns the computed keyframes that make up this effect along with their computed keyframe offsets.</dd>
 <dt>{{domxref("KeyframeEffect.setKeyframes()")}}</dt>
 <dd>Replaces the set of keyframes that make up this effect.</dd>
 <dt>{{domxref("AnimationEffectReadOnly.getComputedTiming()")}}</dt>
 <dd>Returns the calculated, current timing values for this keyframe effect.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<p>In the <a href="https://codepen.io/rachelnabors/pen/eJyWzm/?editors=0010">Follow the White Rabbit example</a>, the KeyframeEffect constructor is used to create a set of keyframes that dictate how the White Rabbit should animate&nbsp;down the hole:</p>

<pre class="brush: js">
&nbsp;var rabbitDownKeyframes = new KeyframeEffect( 
&nbsp; &nbsp; whiteRabbit,&nbsp;// element to animate
&nbsp; &nbsp; [
&nbsp; &nbsp; &nbsp; { transform: 'translateY(0%)' }, // keyframe&nbsp;
&nbsp; &nbsp; &nbsp; { transform: 'translateY(100%)' } // keyframe
&nbsp; &nbsp; ],&nbsp;
&nbsp; &nbsp; { duration: 3000, fill: 'forwards' } // keyframe options
&nbsp; );
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Web Animations', '#the-keyframeeffect-interfaces', 'keyframeEffect' )}}</td>
   <td>{{Spec2('Web Animations')}}</td>
   <td>Editor's draft.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop(47)}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a></li>
 <li>Inherits from {{domxref("KeyframeEffectReadOnly")}} and its parent&nbsp;{{domxref("AnimationEffectReadOnly")}} .</li>
 <li>{{domxref("Animation")}}</li>
</ul>
Revert to this revision