-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow ability to scroll screen on drag #327
Comments
For now, using up and down arrows / page up and page down buttons work while dragging elements. A decent fix would probably involve checking to see if the cursor + the element height is equal to the bottom of the visible portion of the page and then setting a setInterval loop to offset the scroll slightly every few milliseconds if that condition is still true. Once I get more familiar with the code base and have some free time I'll try to implement this. |
Investigating a few different drag-and-drop libraries, having scroll-drag would be a big win. |
|
@natzar Could you turn that into a PR? It'd need to bind your plugin as an option, and work for horizontal scrolling as well. |
Ok, redone in pure javascript. Travis doesn't let me finish PR. It says function scrollTo is defined but not used, really don't know what it expects, the function scrollTo is defined and used. |
@natzar sorry but have you tested this Jquery version in touch devices? and $(document).scrollTop means it will scroll in the page not in dragula.container? |
As you can specify multiple dragula containers, thats also not optimal. Best would be a custom property like scrollContainer. |
finally find one way to make it scroll in the dragula.container on mobile.
|
Back when a similar issue appeared I tried to fix this for dragula. I gave up because I couldn't figure out how to mix the functionality into dragula. So I made a separate library. You nice people are welcome to take a look at my source if it helps you figure out how to implement something similar in the dragula source. https://github.com/hollowdoor/dom_autoscroller/blob/master/src/index.js Warning! I might not have figured it all out. There are cases I can't test for right now. Use it, or take inspiration from it to solve this problem in dragula. |
I was just about to report this, glad I found the existing bug report before I did. This was my testcase, in case it helps: http://codepen.io/leaverou/pen/zogpWM |
I've tried every solution on this page & none work with nested containers. dom_autoscroller isn't an option as I'm not using nodejs. Completely stuck.... |
`$(document).mouseup(function(e){ drake.on('drag',function(el,source){
}` This is working for me |
This jQuery code at least gives you mouseY and mouseX of the left corner of the element attached to your pointer. I was not able to catch mousemove events to read e.pageY , but this gives you some coords to work with, and you can modify various solutions accordingly. |
Modified from jhon100's comment. because mouseover does not work for me. Then include this code inside your drake.on("drag", function
Then inside your drake.on("drop", function add this to turn the scroll function off. If you are worried about using too much CPU, you can try increasing the ,20); interval to 100+. The scrolling will become less smooth. a value of 16 will attempt to run at 60fps. Note, this solution assumes you want to scroll something inside the whole visible window. |
Scrolling of screen / underlying scroll containers can be easily accomplished by the following: .gu-mirror {
pointer-events: none;
} Otherwise the |
You sir, are a genius. I've no idea why this is not upvoted. I could not figure out why mouse wheel would not work inside the scrolled container. Adding this single piece of CSS worked like a charm. |
I have the same problem but I'm not using that library, and I cannot find the problem... could you help me? I have the container wich will handle the scroll, I have the box to be scrolled and the img that you be used to trigger the scroll action... whose should I put pointer-events: none? I've tried everything and I just can't make it work. |
I have the same problem but I'm not using that library, and I cannot find the problem... could you help me? I have the container wich will handle the scroll, I have the box to be scrolled and the img that you be used to trigger the scroll action... whose should I put pointer-events: none? I've tried everything and I just can't make it work. I'm writting again because this is a very outdated issue... could you help me? |
Currently, if dragging brings you to the edge of the viewport, the list will not scroll down. Ideally, it would be nice to have a feature similar to the one in jQuery UI. Source.
This can be tested simply on the dragula home page, put the page like this:

Grab an object and drag it to the bottom, the list will not scroll. This makes dragula unusable for long lists on smaller screens.
Thanks!
The text was updated successfully, but these errors were encountered: