From ac3648e015bdc5aaf8745122da44498c795ac7a0 Mon Sep 17 00:00:00 2001 From: Johannes Odland Date: Thu, 28 Dec 2023 13:05:34 +0100 Subject: [PATCH] Schedule tasks in stead of animation frames for updating timelines --- src/scroll-timeline-base.js | 6 +++--- test/expected.txt | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/scroll-timeline-base.js b/src/scroll-timeline-base.js index c9c093f1..c0b97125 100644 --- a/src/scroll-timeline-base.js +++ b/src/scroll-timeline-base.js @@ -230,9 +230,9 @@ function updateMeasurements(source) { } } - requestAnimationFrame(() => { - // Defer ticking timeline to animation frame to prevent - // "ResizeObserver loop completed with undelivered notifications" + setTimeout(() => { + // Schedule a task to update timelines after all measurements are completed + // TODO: run task only once if there are multiple calls to updateMeasurements for the same source for (const ref of details.timelineRefs) { const timeline = ref.deref(); if (timeline) { diff --git a/test/expected.txt b/test/expected.txt index a9b0b3de..f0692ad4 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -191,7 +191,7 @@ PASS /scroll-animations/css/scroll-timeline-axis-parsing.html e.style['scroll-ti PASS /scroll-animations/css/scroll-timeline-axis-parsing.html e.style['scroll-timeline-axis'] = "none" should not set the property value PASS /scroll-animations/css/scroll-timeline-axis-parsing.html e.style['scroll-timeline-axis'] = "block inline" should not set the property value PASS /scroll-animations/css/scroll-timeline-axis-parsing.html e.style['scroll-timeline-axis'] = "block / inline" should not set the property value -PASS /scroll-animations/css/scroll-timeline-axis-writing-mode.html Initial axis +FAIL /scroll-animations/css/scroll-timeline-axis-writing-mode.html Initial axis PASS /scroll-animations/css/scroll-timeline-axis-writing-mode.html Vertical axis PASS /scroll-animations/css/scroll-timeline-axis-writing-mode.html Horizontal axis PASS /scroll-animations/css/scroll-timeline-axis-writing-mode.html Block axis in horizontal writing-mode @@ -555,7 +555,7 @@ PASS /scroll-animations/scroll-timelines/cancel-animation.html The finished prom PASS /scroll-animations/scroll-timelines/cancel-animation.html The cancel event should NOT be fired if the animation is already idle PASS /scroll-animations/scroll-timelines/cancel-animation.html Canceling an animation should fire cancel event on orphaned element PASS /scroll-animations/scroll-timelines/cancel-animation.html Canceling an animation with inactive timeline should cause its start time and hold time to be unresolved -FAIL /scroll-animations/scroll-timelines/cancel-animation.html oncancel event is fired when the timeline is inactive. +TIMEOUT /scroll-animations/scroll-timelines/cancel-animation.html oncancel event is fired when the timeline is inactive. PASS /scroll-animations/scroll-timelines/constructor-no-document.html The source can be null if the document.scrollingElement does not exist PASS /scroll-animations/scroll-timelines/constructor.html A ScrollTimeline can be created with a source PASS /scroll-animations/scroll-timelines/constructor.html A ScrollTimeline can be created with a non-scrolling source @@ -790,12 +790,12 @@ PASS /scroll-animations/scroll-timelines/scroll-animation-effect-phases.tentativ PASS /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html Play pending task doesn't run when the timeline is inactive. 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. -FAIL /scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html Animation current time is correct when the timeline becomes newly inactive and then active again. +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 Finished animation plays on reverse scrolling. FAIL /scroll-animations/scroll-timelines/scroll-animation.html Sending animation finished events by finished animation on reverse scrolling. -FAIL /scroll-animations/scroll-timelines/scroll-timeline-invalidation.html Animation current time and effect local time are updated after scroller content size changes. +PASS /scroll-animations/scroll-timelines/scroll-timeline-invalidation.html Animation current time and effect local time are updated after scroller content size changes. PASS /scroll-animations/scroll-timelines/scroll-timeline-invalidation.html Animation current time and effect local time are updated after scroller size changes. FAIL /scroll-animations/scroll-timelines/scroll-timeline-invalidation.html If scroll animation resizes its scroll timeline scroller, layout reruns once per frame. FAIL /scroll-animations/scroll-timelines/scroll-timeline-range.html Scroll timeline with percentage range [JavaScript API] @@ -957,4 +957,4 @@ FAIL /scroll-animations/view-timelines/view-timeline-sticky-block.html View time FAIL /scroll-animations/view-timelines/view-timeline-sticky-inline.html View timeline with sticky target, block axis. FAIL /scroll-animations/view-timelines/view-timeline-subject-size-changes.html View timeline with subject size change after the creation of the animation FAIL /scroll-animations/view-timelines/zero-intrinsic-iteration-duration.tentative.html Intrinsic iteration duration is non-negative -Passed 432 of 959 tests. +Passed 433 of 959 tests.