AnimationTimeline: thuộc tính currentTime

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

Thuộc tính chỉ đọc currentTime của giao diện AnimationTimeline trong Web Animations API trả về thời gian hiện tại của timeline tính bằng mili giây, hoặc null nếu timeline đang không hoạt động.

Giá trị

Một số biểu diễn thời gian hiện tại của timeline tính bằng mili giây, hoặc null nếu timeline đang không hoạt động.

Độ chính xác thời gian bị giảm

Để bảo vệ khỏi tấn công dựa trên thời gian và fingerprinting, độ chính xác của animationTimeline.currentTime có thể bị làm tròn tùy theo thiết lập trình duyệt. Trong Firefox, tùy chọn privacy.reduceTimerPrecision được bật mặc định và mặc định là 2ms. Bạn cũng có thể bật privacy.resistFingerprinting, khi đó độ chính xác sẽ là 100ms hoặc giá trị của privacy.resistFingerprinting.reduceTimerPrecision.microseconds, tùy giá trị nào lớn hơn.

Ví dụ, với độ chính xác thời gian bị giảm, kết quả của animationTimeline.currentTime sẽ luôn là bội số của 0.002, hoặc bội số của 0.1 (hoặc privacy.resistFingerprinting.reduceTimerPrecision.microseconds) khi bật privacy.resistFingerprinting.

js
// reduced time precision (2ms) in Firefox 60
animationTimeline.currentTime;
// Might be:
// 23.404
// 24.192
// 25.514
// …

// reduced time precision with `privacy.resistFingerprinting` enabled
animationTimeline.currentTime;
// Might be:
// 49.8
// 50.6
// 51.7
// …

Thông số kỹ thuật

Specification
Web Animations
# dom-animationtimeline-currenttime

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

Xem thêm