AnimationEvent

  • Revision slug: Web/API/AnimationEvent
  • Revision title: AnimationEvent
  • Revision id: 469113
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{SeeCompatTable}}{{APIRef("Event")}}

Summary

The AnimationEvent interface represents events providing information related to animations.

Properties

Also inherits properties from its parent {{domxref("Event")}}.

{{domxref("AnimationEvent.animationName")}} {{readonlyInline}}
Is a {{domxref("DOMString")}} containing the value of the {{cssxref("animation-name")}} CSS property associated with the transition.
{{domxref("AnimationEvent.elapsedTime")}} {{readonlyInline}}
Is a float giving the amount of time the animation has been running, in seconds, when this event fired, excluding any time the animation was paused. For an "animationstart" event, elapsedTime is 0.0 unless there was a negative value for {{cssxref("animation-delay")}}, in which case the event will be fired with elapsedTime containing  (-1 * delay).
{{domxref("AnimationEvent.pseudoElement")}} {{readonlyInline}}
Is a {{domxref("DOMString")}}, starting with '::', containing the name of the pseudo-element the animation runs on. If the animation doesn't run on a pseudo-element but on the element, an empty string: ''.

Constructor

{{domxref("AnimationEvent.AnimationEvent", "AnimationEvent()")}}
Creates an AnimationEvent event with the given parameters.

Methods

Also inherits methods from its parent {{domxref("Event")}}.

{{domxref("AnimationEvent.initAnimationEvent()")}} {{non-standard_inline}}{{deprecated_inline}}
Initializes a AnimationEvent created using the deprecated {{domxref("Document.createEvent()", "Document.createEvent(\"AnimationEvent\")")}} method.

Specifications

Specification Status Comment
{{ SpecName('CSS3 Animations', '#AnimationEvent-interface', 'AnimationEvent') }} {{ Spec2('CSS3 Animations') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ property_prefix("webkit") }} {{ CompatGeckoDesktop("6.0") }} 10.0 12 {{ property_prefix("o") }}
12.10 (without prefix)
15.0 {{ property_prefix("webkit") }}
4.0 {{ property_prefix("webkit") }}
AnimationEvent() constructor {{CompatNo}} {{ CompatGeckoDesktop("23.0") }} {{CompatNo}} {{CompatNo}} {{CompatNo}}
initAnimationEvent() {{non-standard_inline}}{{deprecated_inline}} 1.0 {{ CompatGeckoDesktop("6.0") }}
Removed in {{ CompatGeckoDesktop("23.0") }}
10.0 12 4.0
pseudoelement {{CompatNo}} {{ CompatGeckoDesktop("23.0") }} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}}{{ property_prefix("webkit") }} {{ CompatGeckoMobile("6.0") }} 10.0 12 {{ property_prefix("o") }}
12.10 (without prefix)
15.0 {{ property_prefix("webkit") }}
{{CompatVersionUnknown}}{{ property_prefix("webkit") }}
AnimationEvent() constructor {{CompatNo}} {{ CompatGeckoMobile("23.0") }} {{CompatNo}} {{CompatNo}} {{CompatNo}}
initAnimationEvent() {{non-standard_inline}}{{deprecated_inline}} {{CompatVersionUnknown}} {{ CompatGeckoMobile("6.0") }}
Removed in {{ CompatGeckoMobile("23.0") }}
10.0 {{CompatVersionUnknown}} {{CompatVersionUnknown}}
pseudoelement {{CompatNo}} {{ CompatGeckoMobile("23.0") }} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

Revision Source

<p>{{SeeCompatTable}}{{APIRef("Event")}}</p>
<h2>Summary</h2>
<p>The <strong><code>AnimationEvent</code></strong> interface represents events providing information related to <a href="/en-US/docs/Web/Guide/CSS/Using_CSS_animations">animations</a>.</p>
<h2 id="Properties">Properties</h2>
<p><em>Also inherits properties from its parent {{domxref("Event")}}</em>.</p>
<dl>
  <dt>
    {{domxref("AnimationEvent.animationName")}} {{readonlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}} containing the value of the {{cssxref("animation-name")}} CSS property associated with the transition.</dd>
  <dt>
    {{domxref("AnimationEvent.elapsedTime")}} {{readonlyInline}}</dt>
  <dd>
    Is a <code>float</code> giving the amount of time the animation has been running, in seconds, when this event fired, excluding any time the animation was paused. For an <code>"animationstart"</code> event, <code>elapsedTime</code> is <code>0.0</code> unless there was a negative value for {{cssxref("animation-delay")}}, in which case the event will be fired with <code>elapsedTime</code> containing&nbsp; <code>(-1 * </code><em>delay</em><code>)</code>.</dd>
  <dt>
    {{domxref("AnimationEvent.pseudoElement")}} {{readonlyInline}}</dt>
  <dd>
    Is a {{domxref("DOMString")}}, starting with <code>'::'</code>, containing the name of the <a href="/en-US/docs/Web/CSS/Pseudo-elements" title="/en-US/docs/Web/CSS/Pseudo-elements">pseudo-element</a> the animation runs on. If the animation doesn't run on a pseudo-element but on the element, an empty string: <code>''</code><code>.</code></dd>
</dl>
<h2 id="Constructor">Constructor</h2>
<dl>
  <dt>
    {{domxref("AnimationEvent.AnimationEvent", "AnimationEvent()")}}</dt>
  <dd>
    Creates an <code>AnimationEvent</code> event with the given parameters.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>Also inherits methods from its parent {{domxref("Event")}}</em>.</p>
<dl>
  <dt>
    {{domxref("AnimationEvent.initAnimationEvent()")}} {{non-standard_inline}}{{deprecated_inline}}</dt>
  <dd>
    Initializes a <code>AnimationEvent</code> created using the deprecated {{domxref("Document.createEvent()", "Document.createEvent(\"AnimationEvent\")")}} method.</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('CSS3 Animations', '#AnimationEvent-interface', 'AnimationEvent') }}</td>
      <td>{{ Spec2('CSS3 Animations') }}</td>
      <td>Initial definition.</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>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1.0 {{ property_prefix("webkit") }}</td>
        <td>{{ CompatGeckoDesktop("6.0") }}</td>
        <td>10.0</td>
        <td>12 {{ property_prefix("o") }}<br />
          12.10 (without prefix)<br />
          15.0 {{ property_prefix("webkit") }}</td>
        <td>4.0 {{ property_prefix("webkit") }}</td>
      </tr>
      <tr>
        <td><code>AnimationEvent()</code> constructor</td>
        <td>{{CompatNo}}</td>
        <td>{{ CompatGeckoDesktop("23.0") }}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
      <tr>
        <td><code>initAnimationEvent()</code> {{non-standard_inline}}{{deprecated_inline}}</td>
        <td>1.0</td>
        <td>{{ CompatGeckoDesktop("6.0") }}<br />
          Removed in {{ CompatGeckoDesktop("23.0") }}</td>
        <td>10.0</td>
        <td>12</td>
        <td>4.0</td>
      </tr>
      <tr>
        <td><code>pseudoelement</code></td>
        <td>{{CompatNo}}</td>
        <td>{{ CompatGeckoDesktop("23.0") }}</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>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatVersionUnknown}}{{ property_prefix("webkit") }}</td>
        <td>{{ CompatGeckoMobile("6.0") }}</td>
        <td>10.0</td>
        <td>12 {{ property_prefix("o") }}<br />
          12.10 (without prefix)<br />
          15.0 {{ property_prefix("webkit") }}</td>
        <td>{{CompatVersionUnknown}}{{ property_prefix("webkit") }}</td>
      </tr>
      <tr>
        <td><code>AnimationEvent()</code> constructor</td>
        <td>{{CompatNo}}</td>
        <td>{{ CompatGeckoMobile("23.0") }}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
      <tr>
        <td><code>initAnimationEvent()</code> {{non-standard_inline}}{{deprecated_inline}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{ CompatGeckoMobile("6.0") }}<br />
          Removed in {{ CompatGeckoMobile("23.0") }}</td>
        <td>10.0</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td><code>pseudoelement</code></td>
        <td>{{CompatNo}}</td>
        <td>{{ CompatGeckoMobile("23.0") }}</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/CSS/Using_CSS_animations">Using CSS animations</a></li>
  <li>{{ CSS_Reference:animation() }}</li>
</ul>
Revert to this revision