AnimationTimeline: thuộc tính duration

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính chỉ đọc duration của giao diện AnimationTimeline trong Web Animations API trả về giá trị lớn nhất cho timeline này hoặc null.

Lưu ý rằng các giao diện dẫn xuất ViewTimelineScrollTimeline luôn trả về duration là 100%, trong khi DocumentTimeline không có duration và trả về null.

Giá trị

Một số biểu diễn duration của timeline (giá trị lớn nhất của timeline này) hoặc null.

Ví dụ

Duration của view timeline

ViewTimeline luôn trả về duration là 100% dưới dạng CSSUnitValue.

js
const subject = document.querySelector(".subject");
const timeline = new ViewTimeline({
  subject,
  axis: "block",
});

timeline.duration; // CSSUnitValue { value: 100, unit: "percent" }

Duration của scroll timeline

ScrollTimeline luôn trả về duration là 100% dưới dạng CSSUnitValue.

js
const timeline = new ScrollTimeline({
  source: document.documentElement,
  axis: "block",
});

timeline.duration; // CSSUnitValue { value: 100, unit: "percent" }

Duration của document timeline

DocumentTimeline không có duration.

js
document.timeline.duration; // null

Thông số kỹ thuật

Thông số kỹ thuật
Web Animations Module Level 2
# dom-animationtimeline-duration

Tương thích trình duyệt

Xem thêm