question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] onDragOver

See original GitHub issue

2. Describe the bug

onDragOver of an element is not fired when a motion.div is dragged over the element. This works for native elements.

Repro: https://codesandbox.io/s/nostalgic-mendel-xmijk?file=/src/App.js:944-976

Bigger context: Implementing a drag and drop with framer-motion

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Drag the motion.div (blue) over “bucket” - nothing happens
  2. Drag the div without motion (grey) over “bucket” - fires onDragOver

5. Expected behavior

Both should fire onDragOver events.

7. Environment details

Chrome Version 80 on Mac OS Mojave 10.14.6

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:12
  • Comments:16

github_iconTop GitHub Comments

4reactions
anki247commented, Mar 18, 2022

Meanwhile a workaround I use:

  • As soon you start dragging set the pointer-events: none of the drag element
  • on the dropzone the events mouseenter and mouseleave will now fire, which enables you the possibility 😁 Hope this helps
3reactions
tpictcommented, Apr 14, 2022

This would be really helpful for complex reordering–presumably we could render some elements as drag targets with onDragEnter instead of manually checking for position overlap (which works great for 1D reordering).

I’m interested in writing a PR for this, but it would be good to get some conversation going about how this would work.

It seems that native ondragenter is fired when the mouse pointer enters the element’s bounding rect, which isn’t ideal. It feels much nicer to fire drag enter events on “is the dragged element’s center within the target bounds?”. This is what the Reorder component does. Do we want to enforce that behavior, even if it differs from the native equivalent?

Are simultaneous drag events on different elements supported? I’m not super clued in to touch gestures.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML ondragover Event Attribute - W3Schools
The ondragover attribute fires when a draggable element or text selection is being dragged over a valid ... Drag and drop is a...
Read more >
HTMLElement: dragover event - Web APIs | MDN
The dragover event is fired when an element or text selection is being dragged over a valid drop target (every few hundred milliseconds)....
Read more >
HTML | DOM ondragover Event - GeeksforGeeks
The HTML DOM ondragover event occurs when a draggable element is being dragged over a valid ... object.ondragover = function(){myScript};.
Read more >
ondragover Event - W3Schools Online Web Tutorials
Drag and drop is a very common feature in HTML5. It is when you "grab" an object and drag it to a different...
Read more >
ondragover event - W3big
preventDefault () method to achieve ondragover event. HTML5 Drag and Drop is a very common feature. For more information see our HTML tutorial...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found