Can't prevent click event after div dragEnd
See original GitHub issueI use Interact with angular and have ng-click handler on element. Click has called after my dragend event. How I can prevent that? Where I can add
.on('dragend', function (event) {
event.interactable.preventDefault(true); // doesn't work
event.interactable.options.preventDefault = true ; // doesn't work
event.preventDefault() ; // doesn't work
or smth else?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Prevent click event if dragged - javascript - Stack Overflow
I think how it works is that click fires after a mouseup and mousedown ... is by disabling pointer events for that element...
Read more >Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Use event delegation to track drag start: a single event handler on document for mousedown . If elements are dragged to top/bottom window...
Read more >An Essential Guide to JavaScript Drag and Drop By Examples
This tutorial introduces you to the JavaScript Drag and Drop API and shows you how to handle drag and drop events effectively.
Read more >ondrop Event - W3Schools
The ondrop event occurs when a draggable element or text selection is dropped on a valid drop target. Drag and drop is a...
Read more >Using A "Drag Shield" To Block Mouse Events ... - Ben Nadel
To prevent these unwanted interactions, I ended up using what I'm calling a "drag shield". This was a fixed-position DIV element that I...
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
I would think that this is really more of an Angular issue since interact.js’
tap
event exists to bypassclick
problems.There’s no default action from
InteractEvent
s so theirpreventDefault
method does nothing. Also, callingpreventDefault
onmousedown
ormouseup
events doesn’t stop clicks from happening. If you want to stop the click event then you should add aclick
event listener withuseCapture
that just callsevent.stopImmediatePropagation()
.I know this is an old issue, I just wanted to address the adding of the event every *end (resizeend, dragend etc) being a bad idea, simple add the
once
option to the Listener.