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 1085879 of KeyframeEffectReadOnly

  • Revision slug: Web/API/KeyframeEffectReadOnly
  • Revision title: KeyframeEffectReadOnly
  • Revision id: 1085879
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

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

The KeyframeEffectReadOnly interface of the Web Animations API describes sets of animatable properties and values that can be played using the {{domxref("Animation.Animation()")}} constructor. 

Note: The animations created with KeyframeEffectReadOnly are imutable. To create animations you can change with JavaScript on the fly, try {{domxref("KeyframeEffect")}} instead.

Constructor

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

Properties

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

{{domxref("KeyframeEffectReadOnly.target")}} {{readonlyInline}}
The element or pseudo-element being animated by this object. This may be null for animations that do not target a specific element.
{{domxref("AnimationEffectReadOnly.timing")}} {{readonlyInline}}
The {{domxref("AnimationEffectTimingReadOnly")}} object associated with the animation containing all the animation's timing values.

Future properties

The following options are currently not shipped anywhere, but will be added in the near future.

{{domxref("KeyframeEffectReadOnly.composite")}} {{readonlyInline}}
The composite operation property for resolving the property value changes between this and other keyframe effects.
{{domxref("KeyframeEffectReadOnly.iterationComposite")}} {{readonlyInline}}
The iteration composite operation for resolving the property value changes of this keyframe effect.
{{domxref("KeyframeEffectReadOnly.spacing")}} {{readonlyInline}}
The temporal spacing of the keyframe effect's iterations

Methods

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

Examples

In the Down the Rabbit Hole (with CSS Animations) example, all of Alice's animations are done with CSS. CSS Animations use KeyframeEffectReadOnly objects, so you can't tinker with them directly with the Web Animations API. But you can inspect them like so:

// Have a look at the animations on Alice. 
// Her effect is a KeyframeEffectReadOnly object.
document.getElementById("alice").getAnimations()[0].effect;

// Inspect her timing object. 
document.getElementById("alice").getAnimations()[0].effect.timing;

// See what her current timing values are right now. 
// How do they differ from the above?
document.getElementById("alice").getAnimations()[0].effect.getComputedTiming();

Specifications

Specification Status Comment
{{SpecName('Web Animations', '#keyframeeffectreadonly', 'keyframeEffectReadOnly' )}} {{Spec2('Web Animations')}} Editor's draft.

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatUnknown}} {{CompatUnknown}} {{ CompatGeckoDesktop("48.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
composite, iterationComposite, and spacing options {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatChrome(39.0)}} {{CompatChrome(39.0)}} {{ CompatGeckoMobile("48.0")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
composite, iterationComposite, and spacing options {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

  • Web Animations API
  • Inherits from {{domxref("AnimationEffectReadOnly")}}.
  • {{domxref("KeyframeEffect")}} inherits from it.
  • Can be played with an {{domxref("Animation")}} object.

Revision Source

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

<p>The <strong><code>KeyframeEffectReadOnly</code></strong>&nbsp;interface of the <a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> describes sets of animatable properties and values that can be played using&nbsp;the&nbsp;{{domxref("Animation.Animation()")}} constructor.&nbsp;</p>

<div class="note">
<p><strong>Note</strong>: The animations created with <code>KeyframeEffectReadOnly</code> are imutable. To create animations you can change with JavaScript on the fly, try&nbsp;{{domxref("KeyframeEffect")}} instead.</p>
</div>

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

<dl>
 <dt>{{domxref("KeyframeEffectReadOnly.KeyframeEffectReadOnly()")}}</dt>
 <dd>Returns a new <code>KeyframeEffectReadOnly</code>&nbsp;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("AnimationEffectReadOnly")}}<em>.</em></p>

<dl>
 <dt>{{domxref("KeyframeEffectReadOnly.target")}}&nbsp;{{readonlyInline}}</dt>
 <dd>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("AnimationEffectReadOnly.timing")}} {{readonlyInline}}</dt>
 <dd>The {{domxref("AnimationEffectTimingReadOnly")}} object&nbsp;associated with the animation containing all the animation's timing values.</dd>
</dl>

<h3 id="Future_properties">Future properties</h3>

<p>The following options are currently not shipped anywhere, but will be added in the near future.</p>

<dl>
 <dt>{{domxref("KeyframeEffectReadOnly.composite")}}&nbsp;{{readonlyInline}}</dt>
 <dd>The composite operation property for resolving the property value changes&nbsp;between this and other&nbsp;keyframe effects.</dd>
 <dt>{{domxref("KeyframeEffectReadOnly.iterationComposite")}}&nbsp;{{readonlyInline}}</dt>
 <dd>The iteration composite operation for resolving the property value changes&nbsp;of this keyframe effect.</dd>
 <dt>{{domxref("KeyframeEffectReadOnly.spacing")}}&nbsp;{{readonlyInline}}</dt>
 <dd>The temporal spacing of the keyframe effect's iterations</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("KeyframeEffectReadOnly.getKeyframes()")}}&nbsp;{{readonlyInline}}</dt>
 <dd>Returns the computed keyframes that make up this effect along with their computed keyframe offsets.</dd>
 <dt>{{domxref("AnimationEffectReadOnly.getComputedTiming()")}}&nbsp;{{readonlyInline}}</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/QyOqqW">Down the Rabbit Hole (with CSS Animations) example</a>, all of Alice's animations are done with CSS. CSS Animations use <code>KeyframeEffectReadOnly</code> objects, so you can't tinker with them directly with the Web Animations API. But you <em>can</em>&nbsp;inspect them like so:</p>

<pre class="brush: js">
// Have a look at the animations on Alice. 
// Her effect is a KeyframeEffectReadOnly object.
document.getElementById("alice").getAnimations()[0].effect;

// Inspect her timing object. 
document.getElementById("alice").getAnimations()[0].effect.timing;

// See what her current timing values are right now. 
// How do they differ from the above?
document.getElementById("alice").getAnimations()[0].effect.getComputedTiming();
</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', '#keyframeeffectreadonly', 'keyframeEffectReadOnly' )}}</td>
   <td>{{Spec2('Web Animations')}}</td>
   <td>Editor's draft.</td>
  </tr>
 </tbody>
</table>

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

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

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</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>{{CompatUnknown}}</td>
   <td>{{ CompatGeckoDesktop("48.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>composite</code>, <code>iterationComposite</code>, and <code>spacing</code> options</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</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>{{CompatChrome(39.0)}}</td>
   <td>{{CompatChrome(39.0)}}</td>
   <td>{{ CompatGeckoMobile("48.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>composite</code>, <code>iterationComposite</code>, and <code>spacing</code> options</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</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("AnimationEffectReadOnly")}}.</li>
 <li>{{domxref("KeyframeEffect")}} inherits from it.</li>
 <li>Can be played with an&nbsp;{{domxref("Animation")}} object.</li>
</ul>
Revert to this revision