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

Div scrolling disabled when dragging elements in a scrollable div. #583

Open
shawnwakeman opened this issue May 28, 2024 · 11 comments
Open
Labels
question Further information is requested

Comments

@shawnwakeman
Copy link

When you start dragging an element inside a scrollable div, the scroll event for the div is ignored. This issue only takes place when there is no scroll bar on the body, if there is, it will scroll the entire page not the div that holds the draggable elements.

@isaacHagoel
Copy link
Owner

In this example there are a bunch of scrolling containers and it seems to work as expected. Can please you provide more details and a REPL reproducing the issue?

@shawnwakeman
Copy link
Author

Thanks for your response! Those examples are working because the scroll bar is on the body, scrolling with an item currently being dragged, scroll events are applied to the body's scroll bar, and not the parent divs, in the REPL, start dragging an item, you will see the body's scroll bar being moved insead of the one on the parent div that the board is inside of. REPL

@isaacHagoel
Copy link
Owner

It is not the body that's scrolling. you can see that the headers for "doing" and "done" columns stays in place as the page is not moving.
https://github.com/isaacHagoel/svelte-dnd-action/assets/20507787/97fc00f5-d615-4e56-91eb-a346317e17ea

Same is true here:
https://github.com/isaacHagoel/svelte-dnd-action/assets/20507787/e60c7942-5885-4a63-bac1-f7fe67a39b28

@isaacHagoel isaacHagoel added the question Further information is requested label May 31, 2024
@shawnwakeman
Copy link
Author

you are right, the auto scrolling works, actually using the scroll wheel/arrow keys does not. in the original it does because the scroll events are applied to the body and there is no height cap, but in the example i provided, scrolling up and down with the wheel does not scroll through the div like it does when scrolling without dragging.

@isaacHagoel
Copy link
Owner

isaacHagoel commented May 31, 2024 via email

@shawnwakeman
Copy link
Author

shawnwakeman commented May 31, 2024

  1. Start Dragging
  2. While Dragging, Use the scroll wheel

My issue is here, the scroll is not applied properly, if you:
put the mouse over center(inside the div with the class="content") and scroll it scrolls the internal scroll bar, and it does not do that when dragging.

@isaacHagoel
Copy link
Owner

isaacHagoel commented May 31, 2024 via email

@shawnwakeman
Copy link
Author

yes, clicking and holding(not dragging), or just scrolling. They both scroll correctly, but when dragging it does not.

@isaacHagoel
Copy link
Owner

isaacHagoel commented May 31, 2024 via email

@shawnwakeman
Copy link
Author

shawnwakeman commented Jun 1, 2024

Thank you very much! due to some stuttering had to implement an auto scrolling system which works perfectly fine. But i'm completely stumped on the scroll behavior, the main area of issue was scroll event listers, i would get an output like normal but when dragging, nothing.

@isaacHagoel
Copy link
Owner

@shawnwakeman
I figured it out.
It happens because the lib moves the focus to the dragged element when dragged start, specifically in this line.
You can try to comment it out and you'll see that it starts working.
This line was added as a fix for #135 .
If there is an alternative way to solve that issue I don't mind removing the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants