From 901e9262e3155d6cb04fa4fb04b630ad0262e43e Mon Sep 17 00:00:00 2001 From: Johannes Odland Date: Tue, 6 Feb 2024 16:50:30 +0100 Subject: [PATCH] Fix scroll-animation.html start and current time subtests (#230) --- src/proxy-animation.js | 10 ++++++---- src/scroll-timeline-base.js | 4 +++- test/expected.txt | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/proxy-animation.js b/src/proxy-animation.js index 986fedd..d31f3b6 100644 --- a/src/proxy-animation.js +++ b/src/proxy-animation.js @@ -669,10 +669,6 @@ function tickAnimation(timelineTime) { (timelineTimeMs - fromCssNumberish(details, this.startTime)) * this.playbackRate); - // Conditionally reset the hold time so that the finished state can be - // properly recomputed. - if (playState == 'finished' && effectivePlaybackRate(details) != 0) - details.holdTime = null; updateFinishedState(details, false, false); } } @@ -746,6 +742,12 @@ function createProxyEffect(details) { let totalDuration; + if (timing.duration === Infinity) { + throw TypeError( + "Effect duration cannot be Infinity when used with Scroll " + + "Timelines"); + } + // Duration 'auto' case. if (timing.duration === null || timing.duration === 'auto' || details.autoDurationEffect) { if (details.timeline) { diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index cae2564..702f346 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -362,7 +362,9 @@ export function addAnimation(scrollTimeline, animation, tickAnimation) { animation: animation, tickAnimation: tickAnimation }); - updateInternal(scrollTimeline); + queueMicrotask(() => { + updateInternal(scrollTimeline); + }); } // TODO: this is a private function used for unit testing add function diff --git a/test/expected.txt b/test/expected.txt index 6f702cd..f236043 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -912,8 +912,8 @@ PASS /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html PASS /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html Animation start and current times are correct if scroll timeline is activated after animation.play call. PASS /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html Animation start and current times are correct if scroll timeline is activated after setting start time. PASS /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html Animation current time is correct when the timeline becomes newly inactive and then active again. -FAIL /scroll-animations/scroll-timelines/scroll-animation.html Animation start and current times are correct for each animation state. -FAIL /scroll-animations/scroll-timelines/scroll-animation.html Animation start and current times are correct for each animation state when the animation starts playing with advanced scroller. +PASS /scroll-animations/scroll-timelines/scroll-animation.html Animation start and current times are correct for each animation state. +PASS /scroll-animations/scroll-timelines/scroll-animation.html Animation start and current times are correct for each animation state when the animation starts playing with advanced scroller. PASS /scroll-animations/scroll-timelines/scroll-animation.html Finished animation plays on reverse scrolling. FAIL /scroll-animations/scroll-timelines/scroll-animation.html Sending animation finished events by finished animation on reverse scrolling. PASS /scroll-animations/scroll-timelines/scroll-timeline-invalidation.html Animation current time and effect local time are updated after scroller content size changes. @@ -960,7 +960,7 @@ PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting an unre PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting an unresolved start time sets the hold time to unresolved when the timeline is inactive PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting the start time resolves a pending ready promise PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting the start time resolves a pending ready promise when the timelineis inactive -FAIL /scroll-animations/scroll-timelines/setting-start-time.html Setting an unresolved start time on a play-pending animation makes it idle +PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting an unresolved start time on a play-pending animation makes it idle PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting the start time updates the finished state PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting the start time on a running animation updates the play state PASS /scroll-animations/scroll-timelines/setting-start-time.html Setting the start time on a reverse running animation updates the play state