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

  • Revision slug: Web/API/DocumentTimeline
  • Revision title: DocumentTimeline
  • Revision id: 1045028
  • Created:
  • Creator: rachelnabors
  • Is current revision? No
  • Comment Moving syntax to its constructor. Interfaces don't have syntaxes. Their constructors do.

Revision Content

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

Document timelines, including the default document timeline, {{domxref("Document.timeline")}}, are represented in the Web Animations API by the DocumentTimeline interface.

Constructor

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

Attributes

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

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>Document timelines, including the default document timeline,&nbsp;<code>{{domxref("Document.timeline")}}</code>,&nbsp;are represented in the <a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a>&nbsp;by the <strong><code>DocumentTimeline</code></strong> interface.</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="Attributes">Attributes</h2>

<dl>
 <dt><code><a href="/en-US/docs/Web/API/AnimationTimeline/currentTime">DocumentTimeline.currentTime</a></code></dt>
 <dd>Returns the time value in milliseconds for this timeline or&nbsp;<code>null</code>&nbsp;if this timeline is inactive. (Inherited from&nbsp;<code>{{domxref("AnimationTimeline")}}</code>.)</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;&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