The DocumentTimeline() constructor of the Web Animations API creates a new instance of the DocumentTimeline object associated with the active document of the current browsing context.
new DocumentTimeline(options)options OptionalAn object specifying options for the new timeline. The following properties are available:
originTime OptionalA number that specifies the zero time for the DocumentTimeline as a number of milliseconds relative to Performance.timeOrigin. Defaults to 0.
A DocumentTimeline with an originTime of zero counts time starting from Performance.timeOrigin. This is the same behavior as Document.timeline.
const timeline = new DocumentTimeline();
console.log(timeline.currentTime === document.timeline.currentTime); // trueSetting a non-zero originTime will offset the DocumentTimeline from Document.timeline by that amount:
const offsetTimeline = new DocumentTimeline({ originTime: 500 });
console.log(document.timeline.currentTime - offsetTimeline.currentTime); // 500A DocumentTimeline relative to the current moment can be constructed with:
const nowTimeline = new DocumentTimeline({
originTime: document.timeline.currentTime,
});
console.log(nowTimeline.currentTime); // 0