Prevent click propagation on drag and drop
See original GitHub issueI was wondering if anyone had an issue with click event being fired after drag and drop.
My container is a huge list of images wrapped with links to a dedicated page.
Sometimes when the drap and drop is initiated on top of the image, the click event gets fired when releasing the mouse.
Is there an easy way to prevent this from happening?
I was thinking about adding a class no-click
to the container then adding a click eventListener to all children which will check if the parent has the class no-click
and then stop the propagation of the event.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:12
- Comments:10
Top Results From Across the Web
Prevent click event if dragged - javascript - Stack Overflow
In the first mousemove event, search all children for click event listeners, remove all of them, on mouseup restore them (possibly after a ......
Read more >Event.stopPropagation() - Web APIs | MDN
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Read more >Stop propagation of 'drag' event for marker in Leaflet
Is there a possibility to prevent Leaflet dragstart event from triggering just moment after start dragging a marker.
Read more >Preventing Drag.Move click propagation on child element
There are two solutions: 1. In your #parent event listener, check the event.target element. event.target is the element that was actually ...
Read more >event.stopImmediatePropagation() | jQuery API Documentation
stopPropagation () . To simply prevent the event from bubbling to ancestor elements but allow other event handlers to execute on the same...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How about this quickfix?
Now you can check the .dragscroll for .dragging and then prevent the click action.
My workaround using click status variable (better hide it in local scope):