Support e.preventDefault() and e.stopPropagation() in tap/drag events
See original GitHub issue- In my app I have
<Link>
elements inside a draggable<motion.div>
element. When the user clicks those, I don’t want the drag/whileTap
styles to activate. - I tried to achieve this by blocking propagation of the
onMouseDown
event, but this doesn’t seem to have any effect. - In fact, the
onMouseDown
event is never fired at all on any of the childs of the draggable element.
See: https://codesandbox.io/s/framer-motion-block-mousedown-inside-draggable-item-3ecgd
Expected/Desired behaviour: when clicking the white box, the colored <motion.div>
element should not scale up and/or follow the cursor when dragging.
Is there a way to do this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:22
Top Results From Across the Web
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 >How to correctly use preventDefault(), stopPropagation(), or ...
event.preventDefault(). Prevents the browsers default behaviour (such as opening a link), but does not stop the event from bubbling up the DOM.
Read more >What's the difference between event.stopPropagation and ...
preventDefault() – It stops the browsers default behaviour. event.stopPropagation() – It prevents the event from propagating (or “bubbling up”) the DOM.
Read more >PreventDefault vs StopPropagation | by Gapur Kassym - ITNEXT
stopPropagation() method stops the propagation of an event from occurring in the bubbling or capturing phase. The event on a href element id=” ......
Read more >Difference between preventDefault() and stopPropagation ...
preventDefault() Method: It is a method present in the event interface. ... for applying both methods with the help of the examples.
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
Scratch that, found a way using
useDragControls()
.Works great.
I think with these slightly more advanced use-cases you’re better off handling gesture animation states yourself with
useState
. I’m going to leave the ticket open though as I think the request itself is a fair one.