-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Try using a percentage based calculation for block drag scrolling velocity. #23448
Conversation
Size Change: +64 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
Nice! |
Very nice improvement. Thanks! |
2ad9d77
to
f6ab680
Compare
f6ab680
to
2aba546
Compare
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.
A little feedback on duplication, otherwise looks good
const dragDistance = Math.max( | ||
offsetDragStartPosition - | ||
offsetDragPosition - | ||
SCROLL_INACTIVE_DISTANCE_PX, | ||
0 | ||
); | ||
const distancePercentage = dragDistance / moveableDistance; |
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.
These lines appear to be duplicates of lines in the previous if-clause - is there a way to eliminate this duplication?
Description
This tries an iteration on the behavior in #23082.
See also #23446 for an alternative.
It's based on the refactor to hooks in #23444, so the diff looks bigger than it is. That PR should ideally be merged first.
How does this differ from #23082
In #23082, when the user drags more than 50px the page starts scrolling in the direction they've dragged. The speed of the scrolling is based on how far the user drags.
Because the scroll speed is calculated using pixels, if the user starts dragging a block that's already near the top of the screen upwards there's a limit to the speed that the page can scroll. On the other hand, when dragging downwards from the top, very fast scroll speeds can be unexpectedly achieved due to the amount of space a user can drag into.
This PR makes the calculation percentage based. If the user drags to the top of the page the page scrolls at the same speed as if they dragged to the bottom, regardless of where they started dragging from.
How has this been tested?
Types of changes
Non-breaking enhancement
Checklist: