-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix: Change requestNamedAnimationFrame to apply last change per frame instead of first #8799
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8799 +/- ##
=======================================
Coverage 83.12% 83.12%
=======================================
Files 120 120
Lines 8052 8052
Branches 1931 1931
=======================================
Hits 6693 6693
Misses 1359 1359 ☔ View full report in Codecov by Sentry. |
@@ -1714,7 +1714,7 @@ class Component { | |||
*/ | |||
requestNamedAnimationFrame(name, fn) { | |||
if (this.namedRafs_.has(name)) { | |||
return; | |||
this.cancelNamedAnimationFrame(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this still return
as well or do we now want to execute the code below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous, if a raf with that name is already queued, it returned and did not add the new raf of this name.
Now if the named raf is queued, instead of returning, that queued one is cancelled, then the new raf is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
Description
The current implementation of
requestNamedAnimationFrame
prevents multiple updates on a frame but by disregarding all but the first request per frame. This throttling behaviour is apparent when playing a very short video - if atimeupdate
occurs just before theended
event, the progress bar position on thetimeupdate
is set at say 98% and 100% from theended
is discarded. Although #8633 removed the throttle from theended
handler itself, the throttle and non-throttled update can still both execute between frames.Specific Changes proposed
Changes the implementation to apply only the last callback instead. If any exist they will be cancelled. There will still be only one update, but now it's the last.
Updates tests to reflect the changed behaviour.
Fixes #8782
Requirements Checklist
npm run docs:api
to error