Skip to content
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

Improve auto-scrolling for small containers / large drag sources #23

Closed
clauderic opened this issue Dec 4, 2020 · 8 comments · Fixed by #140
Closed

Improve auto-scrolling for small containers / large drag sources #23

clauderic opened this issue Dec 4, 2020 · 8 comments · Fixed by #140
Labels
enhancement New feature or request

Comments

@clauderic
Copy link
Owner

Currently if you have a small scroll container and a large drag source, it's nearly impossible to get fine controlled auto-scrolling working properly given the existing auto-scrolling logic.

The getScrollDirectionAndSpeed will need to be updated to take into account the relative size of the item being dragged compared to the scroll container's actual size

@horprogs
Copy link

Hey, first of all, thank you for your job!
This issue is related to this behaviour, right? Is there any way to improve this?

ezgif com-gif-maker

@clauderic
Copy link
Owner Author

@horprogs that's one of the manifestations of the issue, indeed.

On how this could be improved: Generally I think it's a bit tricky to find a one-size-fits-all strategy for auto-scrolling. I think in the future this should be a bit more extensible, and have either a pointer coordinates based strategy or a strategy that is based on the bounding rect of the dragged element

@Sorgrum
Copy link

Sorgrum commented Feb 20, 2021

@clauderic Looking the grid example, I wonder if the auto-scrolling is too aggressive. Right now it seems that the page auto-scrolls when the element is brought down past the halfway point of the page. A simple solution might be to only scroll if the element that is being dragged is nearing the edge of the viewport. Any thoughts?

@Simba14
Copy link

Simba14 commented Mar 2, 2021

Having similar issues but with on drag instantly scrolling to the top in a scrollable container.
Any workarounds?

@ohayojp
Copy link

ohayojp commented Mar 5, 2021

I don't know if this is related to this issue but when you try to scroll with dragged element without DragOverlay element position won't be updated for the scroll duration. You can see it here: https://5fc05e08a4a65d0021ae0bf2-vfebfgjygq.chromatic.com/?path=/docs/presets-sortable-grid--without-drag-overlay

Drag element and try to scroll the page with it. Result: mouse position and element position are different.
One solution is to set dragged item position to fixed when isDragging, but then after scrolling the page initial position of dragged element will be way off

@willadamskeane
Copy link

I'm running into this issue as well - has anyone found an interim workaround?

@clauderic
Copy link
Owner Author

I'm working on a fix to these issues here: #140

@AlfainCoder
Copy link

I am using dnd-Kit and sortable, context with an array. In my case auto scrolling is not working in a list while item being dragged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants