Add scrolling support vertically and horizontally#449
Conversation
|
This PR is just full of awesome! |
TODO: When hovering the dragged item at scrollEdge, the scrolling should automatically begin to scroll. Drag and scrolling code is inspired by jQuery UI's sortable and draggable widgets.
|
This looks fantastic. What needs to happen for this to be mergeable? |
| // For iframe. When dragging an item and mouse moves out of the iframe and | ||
| // mouseup, then decides to move back, the event will be 0 so we should | ||
| // just call cancel. | ||
| if (whichMouseButton(e) === 0 { cancel(); } |
There was a problem hiding this comment.
There was a problem hiding this comment.
I'll have this fixed. Thanks for the catch!
|
I think it's pretty much ready. |
|
+++1 for this... |
| if (node === null) { return null; } | ||
| if (node.scrollHeight > node.clientHeight) { | ||
| return node; | ||
| } else { |
There was a problem hiding this comment.
else here is redundant, please remove
| } else { | ||
| if (!/(body|html)/i.test(node.parentNode.tagName)) { | ||
| return getScrollContainer(node.parentNode); | ||
| } else { |
There was a problem hiding this comment.
else here is redundant, please remove
| if (node.scrollHeight > node.clientHeight) { | ||
| return node; | ||
| } else { | ||
| if (!/(body|html)/i.test(node.parentNode.tagName)) { |
There was a problem hiding this comment.
I don't understand why I need a variable for this. Why would you want to hold on to the reference if it's not going to be used unless we're scrolling?
There was a problem hiding this comment.
I created a commit for it, e9e4e5a; but I'm not sure if I'm happy with this path. I'm open to suggestions.
There was a problem hiding this comment.
@nguyenj I just meant putting it in a variable like this:
var rbodyhtml = /(body|html)/i
if (!rbodyhtml.test(node.parentNode.tagName)) {
// ...I avoid inline regular expressions in conditionals because they dampen readability. There's no need to hoist it to the top of the file, certainly.
|
Just wanted to pass along some info... Looks like for my use case, where I want each container to be able to scroll vertically when I move the card over it, I will likely need to write something custom... Hopefully dragula provides me with enough events to be able to do it without having to fork the library. /Paul |
|
@purtuga can you provide me a jsbin example? I have an example setup on the index.html for scrolling within a container. It would be easier to debug your issue if I'm able to see the markup and css. |
|
Hi @nguyenj, thanks for responding... |
| var doc = document; | ||
| var documentElement = doc.documentElement; | ||
| var _autoScrollingInterval; // reference to auto scrolling | ||
| var BODY_HTML_TAG_REGEX = new RegExp(/(body|html)/, 'i'); |
There was a problem hiding this comment.
You can just keep it as a literal /(body|html)/i
|
@nguyenj Could use use |
|
@nguyenj I setup a quick prototype here: http://jsbin.com/mahuwitani This prototype is also setup where the Thanks for your time on this and for contributing back. |
|
looking forward to this PR can be merged into Dragula ASAP |
|
@purtuga That's interesting; thanks for pointing that out. I'm not sure if I'll be able to address your particular issue with dragging in multi-directions. I suspect the issue to be that, it's only looking for the closest container "type" to that item and checking to see if it's scrollable-that's probably why it's not scrolling horizontal because the parent to the item is vertically scrollable. |
|
@nguyenj Thanks for the reply. |
|
Hi guys, when do you add this PR into dragula? I am looking foreward to use this awesome feature :) |
|
@bevacqua Let me know if there is anything else–I pushed up a simple |
|
@gxzhou519 your issues should be fixed. Thanks @adam-h! |
|
Tests are passing locally; but not entirely sure why CI is failing. |
|
@nguyenj are you running the tests locally with the same configuration options as on Travis? |
|
@joshsmith The only thing that is the same that I am running from |
|
When will this be getting merged? |
Also simplify animationFrame polyfills as browser support is excellent and older browsers are buggy (some have no support for cancelling) so it's better to fallback.
|
I see that there was some activity. Is there an ETA on this being merged? |
|
Good question! I have no idea. |
|
Wow, what do we need to do to get this merged? :O ESSENTIAL for this great piece of software |
|
@nguyenj Does this cover the case where the elements that you want to scroll are not always Dragula containers? For example, you have a Kanban style board, which has overflowed the viewport, and you want to scroll the viewport when you approach the top/bottom edges such that you can place cards in different vertices? Essentially, initiating a page scroll on an entire page instead of just the containers. |
|
Any ETA? |
|
Awesome. I tried out these change though and couldn't get it to work when i wanted to scroll to a container that wasn't currently in view. I made some modifications, but I'm unsure if this would make the package better or if this a use case specific to me. Essentially I'm checking the need to scroll when looking to see if I'm over a target that is dropable, and removing the mouseEvents from the startScroll function and grabing them from the params passed into findDropTarget. |
|
@gardinit sorry I’ve lost interest in pursuing to modify this PR as it seems that this library is in active and the author seems to have stopped maintaining this project-just take a look at all the unresolved issues and open PRs. |
Merge remote-tracking branch 'scrollfork2/fix/scroll' into scroll # Conflicts: # dist/dragula.js # dist/dragula.min.js
|
I'd say that sadly this library should be considered dead. Given the lack of response form the author to PRs and issues he's moved his focus else where. So those looking for a similar solution (with working scroll when dragging no less) would be well served with draggable |
|
That's indeed what I've switched to @pete-hotchkiss Lukas |
|
I have switched to https://github.com/clauderic/react-sortable-hoc with great success! |
|
Is there a fork with this PR? |
|
@danielehrhardt You can see if https://github.com/benelliott/dragula works for you |
|
@danielehrhardt have you looked into https://github.com/Shopify/draggable? The community there is a little more vibrant. |
|
Closing this as this project is DEAD. |
|
⚰️ |
|
For those that are stuck with dragula: try dom-autoscroller. |

This PR will be addressing these drag and scrolling issues: #327, #121.
TODOS: