Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle double precision in playState #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/proxy-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,20 @@ function parseTimelineRangePart(timeline, value, position) {
unsupportedTimeline(timeline);
}

function isGreaterOrEqual(a, b) {
if (Math.abs(a - b) <= 100000 * Number.EPSILON) {
return true;
}
return a > b;
}

function isLessOrEqual(a, b) {
if (Math.abs(a - b) <= 100000 * Number.EPSILON) {
return true;
}
return a < b;
}

// Create an alternate Animation class which proxies API requests.
// TODO: Create a full-fledged proxy so missing methods are automatically
// fetched from Animation.
Expand Down Expand Up @@ -1495,10 +1509,9 @@ export class ProxyAnimation {
// * animation’s effective playback rate < 0 and current time <= 0,
// then finished.
if (currentTime != null) {
if (details.animation.playbackRate > 0 &&
currentTime >= effectEnd(details))
if (details.animation.playbackRate > 0 && isGreaterOrEqual(currentTime, effectEnd(details)))
return 'finished';
if (details.animation.playbackRate < 0 && currentTime <= 0)
if (details.animation.playbackRate < 0 && isLessOrEqual(currentTime , 0))
return 'finished';
}

Expand Down
2 changes: 2 additions & 0 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ PASS /scroll-animations/scroll-timelines/current-time-root-scroller.html current
PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles direction: rtl correctly
PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles writing-mode: vertical-rl correctly
PASS /scroll-animations/scroll-timelines/current-time-writing-modes.html currentTime handles writing-mode: vertical-lr correctly
PASS /scroll-animations/scroll-timelines/duration.html The duration of a scroll timeline is 100%
PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay to a positive number
PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay to a negative number
PASS /scroll-animations/scroll-timelines/effect-updateTiming.html Allows setting the delay of an animation in progress: positive delay that causes the animation to be no longer in-effect
Expand Down Expand Up @@ -1026,6 +1027,7 @@ PASS /scroll-animations/view-timelines/block-view-timeline-current-time.tentativ
FAIL /scroll-animations/view-timelines/block-view-timeline-nested-subject.tentative.html View timeline with subject that is not a direct descendant of the scroll container
FAIL /scroll-animations/view-timelines/change-animation-range-updates-play-state.html Changing the animation range updates the play state
FAIL /scroll-animations/view-timelines/contain-alignment.html Stability of animated elements aligned to the bounds of a contain region
PASS /scroll-animations/view-timelines/duration.html The duration of a view timeline is 100%
PASS /scroll-animations/view-timelines/fieldset-source.html Fieldset is a valid source for a view timeline
FAIL /scroll-animations/view-timelines/get-keyframes-with-timeline-offset.html Report specified timeline offsets
FAIL /scroll-animations/view-timelines/get-keyframes-with-timeline-offset.html Computed offsets can be outside [0,1] for keyframes with timeline offsets
Expand Down
Loading