Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
improvement: PlayProgressBar Smooth Transition #4591
Instead of tying the play progress update lifecycle to the timeupdate
Here's a video!
Specific Changes proposed
Instead of relying on the
Thanks for the PR!
I'd like other core contributors to weigh in, but I have some concerns.
Intervals tend not to be a great way to do animation because they aren't very precise (anything that blocks the UI thread blocks/offsets execution of timers). If we were to stop using
timeupdate to trigger progress bar updates, I think it'd be better to make use of
Also, the loss of throttling concerns me. The
update() function is not fast and causes reflow/repaint. Calling it on a 15ms interval might cause performance problems on slower/mobile devices.
@misteroneill agreed on throttling. I can add back throttling the update function to ensure it only gets fired at most once every 15ms. However, we can't throttle it more than that if we want the play progress bar to appear as though it's progressing smoothly (at least if we do it in JS).
Another option here (that I'm not opposed to) is to make use of CSS transitions. It would require a bit more work, and I noticed janky issues when clicking around (we have to do logic where we remove the transition when someone clicks around the
@mawenmaywin this PR modifies the source code of video.js, which is only present when you clone the repo, not when you install via
Alternatively, these changes are pretty small. You can also just modify the
Given @gkatsev's update on not needing to test contrib-ads and my updates to the events that this timer binds to, what am I missing here? Looking at the unit tests, it doesn't seem like this really fits into any of them. Happy to add any unit tests y'all think are appropriate though.
On another note, doesn't seem like this should result in any updates to the docs.
I'll be here and dedicated to getting this over the finish line as soon as I get replies. :-)
I'm still a bit worried about having a setInterval that runs every 15ms. Though, I do agree with you it'll be nice to get this fixed. Maybe a larger interval would be ok? like 50ms or 100ms?
Also, I think bring the throttling back would be good, and of course, it should match the internal we're using. Another thought is to wrap the