Improve: programmatic scrolling experience #107
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR can be treated as a breaking change and touches on several things. Let me describe it by points.
First of all, this PR addresses the issue of subsequent
setScrollPercent
.When we added
setScrollPercent,
it was naively working just by running a browser scroll, so the rest of the code doesn't need a big refactoring because we relied on thescroll
event.There are a couple of issues with this:
setScrollPercent
, soscroll
can't distinguish which scroll we process now. And there is no way to stop the previous scroll from progressing.trackScroll
setup (like linear scrolling). We can't add easing fortrackScroll
onevent
because some easings progress towards the goal non-linearly, which means you scroll to the bottom, but easing plays in the opposite direction. In addition to the connected video duration to the scroll percentage.Also, nice to have things are:
videoPercentage
, so we could operate this value in some scenarios,Feel free to share your thoughts.
And maybe we finally need to build a repro for advanced cases for easier testing and regression.
One more thing: I added a few lines of code to support
onChange
, but we can do it separately, of course. I just showed how easy it is now.