-
Notifications
You must be signed in to change notification settings - Fork 390
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
emit dragStart when element starts moving, not on pointer down event #13
Comments
+1, also ran into this. Could we add another event to listen for, that's only fired once dragging actually starts? |
👍 I think you're right in the approach you suggest, @desandro. First event we hear from a dragging library should be when dragging actually starts. Browser already throws click and mousedown on its own. Treating the first mousedown like a drag start has problems:
You still working on this? Open to a fork? |
In a year since I opened this issue, there have been two positive responses. This helps, but I'm not likely to change the feature just yet. |
+1, I think jQuery UI Draggable is doing it right here. Please take another look at this Desandro :) |
I've jsut ran into similar issue: I need to differentiate between click and dragstart. More specific, it would be great if I could control that the event is not prevented here:
|
Add `distance` option and make `dragStart` event fire only when the element is moved. Fixes the bug with nested form elements clickability.
In the end I opted to add a small handle to my draggable object as a workaround. In the future it would be great to be able to click / drag the whole object without triggering conflicting styles. |
👍 |
1 similar comment
+1 |
I implemented the "wait to fire dragStart" functionality in this fork. It's non-breaking, if you want the dragStart event to wait to fire until there's movement, just add Let me know what you think :) |
Works a treat, and is about as simple as could be. Thanks!! :) |
Running into this exact problem right now - need a way to differentiate between clicks and actual drags. I have some functionality that needs to happen only on click, but right now it's happening both on click and after a drag, because the events tied to click are still firing after dragging an element. |
@willdavidow This is true. I wrote a small fix that makes sure drag only fires if you actually start dragging, but click will still fire, as you say. A better fix for most people (I think) would be to prevent the click event if a drag has happened. It's been about a month now so I don't remember exactly what that code looked like, but I remember thinking that the second part would be a bit nontrivial. |
@willdavidow There is a couple of PRs attached to this issue. You can find a fix you like more. For example, have a look at my fix. I've added the tolerance parameter (the way it is done in jquery.draggable). The PR is not merged. |
I've pushed a new branch drag-start. In this branch, |
Thanks @desandro, @SimpleAsCouldBe and @mr-mig - not emitting dragStart until a user actually begins dragging is definitely helpful for some things I need to add to the prototype I'm working on, but the issue with not being able to kill the click looms. Is there a way to cancel that click event that is being passed through? Nothing is working. I've tried all of these in both dragStart and dragEnd: e.returnValue = false; // nope Am I missing something (I probably am)... ? |
@willdavidow This sounds similar to #19. Take a look! |
This works to solve my issue as well! 👍 I would also add this to the dragEnd so that any libraries built on top of draggabilly have a consistant event API with dragEnd only getting called when items are dragged:
|
Thanks, is this merged in v1.1.2 or should we take care of that in our own code? |
This is likely to land in v1.2.0, which I am currently working on |
@desandro Is there an ETA on 1.2.0? Looking forward to it. |
+1 |
Draggabilly v1.2.0 has been released. Draggabilly now triggers |
Awesome, thanks a lot! Starting testing it :-) |
Thanks David. Can't wait to try it.
|
This is consistent with jQuery UI Draggable. It makes sense, as it prevents moving logic from being triggered when it doesn't have to.
I'm running into a problem on a Packery+draggable demo, trying use just pointer events. When item is 'clicked' (pointer doesn't move), I want to do different logic.
Eh, this may be problematic in the long run.
The text was updated successfully, but these errors were encountered: