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 1045184 of DocumentTimeline

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

Revision Content

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

the DocumentTimeline interface of the the Web Animations API represents animation timelines, including the default document timeline (accessed via {{domxref("Document.timeline")}}).

Constructor

{{domxref("DocumentTimeline.DocumentTimeline()")}}
Creates a new DocumentTimeline object associated with the active document of the current browsing context.

Properties

This interface inherits its property from its parent, {{domxref("AnimationTimeline")}}.

{{domxref("AnimationTimeline.currentTime")}}
Returns the time value in milliseconds for this timeline or null if it is inactive.

Examples

We could share a single documentTimeline among multiple animations, thus allowing us to manipulate just that group of animations via their shared timeline. This bit of code would start all the cats animating 500 milliseconds into their animations:

var cats = document.querySelectorAll('.sharedTimelineCat');
cats = Array.prototype.slice.call(cats);

var sharedTimeline = new DocumentTimeline(500);

cats.forEach(function(cat) { 
  var catKeyframes = new KeyframeEffect(cat, keyframes, timing);
  var catAnimation = new Animation(catKeyframes, sharedTimeline);
  catAnimation.play(); 
});

Specifications

Specification Status Comment
{{SpecName('Web Animations', '#the-documenttimeline-interface', 'DocumentTimeline' )}} {{Spec2('Web Animations')}} Editor's draft.

Browser compatibility

{{CompatibilityTable}}

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

See also

  • Web Animations API
  • {{domxref("AnimationTimeline")}}
  • {{domxref("AnimationTimeline.currentTime")}}
  • {{domxref("Document.timeline")}}
  • {{domxref("DocumentTimeline.DocumentTimeline()")}}

Revision Source

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

<p>the <strong><code>DocumentTimeline</code></strong> interface of the the <a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> represents animation timelines, including the default document timeline (accessed via {{domxref("Document.timeline")}}).</p>

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

<dl>
 <dt>{{domxref("DocumentTimeline.DocumentTimeline()")}}</dt>
 <dd>Creates a new <code>DocumentTimeline</code> object associated with the active document of the current browsing context.</dd>
</dl>

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

<p><em>This interface inherits its property from its parent, {{domxref("AnimationTimeline")}}.</em></p>

<dl>
 <dt>{{domxref("AnimationTimeline.currentTime")}}</dt>
 <dd>Returns the time value in milliseconds for this timeline or&nbsp;<code>null</code>&nbsp;if it is inactive.</dd>
</dl>

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

<p>We could share a single&nbsp;<code>documentTimeline</code> among multiple animations, thus allowing us to manipulate just that group of animations via their shared timeline. This bit of code would start all the cats animating 500 milliseconds into their animations:</p>

<pre class="brush: js">
var cats = document.querySelectorAll('.sharedTimelineCat');
cats = Array.prototype.slice.call(cats);

var sharedTimeline = new DocumentTimeline(500);

cats.forEach(function(cat) {&nbsp;
&nbsp; var catKeyframes = new KeyframeEffect(cat, keyframes, timing);
&nbsp; var catAnimation = new Animation(catKeyframes, sharedTimeline);
&nbsp; catAnimation.play();&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-documenttimeline-interface', 'DocumentTimeline' )}}</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>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>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</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>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{ CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</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>{{domxref("AnimationTimeline")}}</li>
 <li>{{domxref("AnimationTimeline.currentTime")}}</li>
 <li>{{domxref("Document.timeline")}}</li>
 <li>{{domxref("DocumentTimeline.DocumentTimeline()")}}</li>
</ul>
Revert to this revision