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.

Delay after mouse is released when drag source is unsuccessfully dropped

See original GitHub issue

Describe the bug I’m unable to detect when the user’s mouse is released when the dragged item is dropped outside of a drop target.

The end event for the drag source does not fire until the native “slide back into place” has completed (but I do not want to use the native one).

My goal is to reposition the dragging element myself using transform: translate(x,y) and then have it animate back when dropped somewhere that isn’t a target.

Reproduction

Live Reproduction

This codesandbox example from the docs shows this behavior in action for the custom drag layer.

Steps to reproduce the behavior:

  1. Select a draggable item in that sandbox
  2. Drag it outside of the box
  3. Release it
  4. Observe a ~1s delay before it snaps back to place

Expected behavior The end event of the Drag source should fire when the unsuccessful drag is complete (mouse released).

If this is not the intent of the end event, then another hook would be useful.

Screenshots dragDropBug

Desktop (please complete the following information):

  • OS: [e.g. Mac]
  • Browser [e.g. chrome]
  • Version [e.g. Version 89.0.4389.72 (Official Build) (x86_64)]

Additional context If this is a bug or lack of functionality of the browser, are there any workarounds?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:23
  • Comments:7

github_iconTop GitHub Comments

4reactions
salalicommented, Apr 15, 2021

The only way I’ve found to get rid of the delay is using the touch backend.

<DndProvider backend={TouchBackend} options={{ enableMouseEvents: true }}>

3reactions
YiyuanYincommented, Apr 26, 2021

I’ve encountered with the same problem when I use the drag preview of my own by using the code below.

  useEffect(() => {
    preview(getEmptyImage(), { captureDraggingState: true });
  }, [preview]);

After trying different ways of dragging, I found that the delay won’t disappear unless you are dragging items over a droppable wrapper, that means that you must wrap anywhere you can drag with

  const [, drop] = useDrop(() => ({ accept: 'file' }));

<div ref={drop} style={{ height: '100%' }}>
{element}
</div>

That is the only way I can figure out to solve this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Delay after mouse is released when drag source ...
Delay after mouse is released when drag source is unsuccessfully dropped · Select a draggable item in that sandbox · Drag it outside...
Read more >
React Beautiful DnD delay when dropping - Stack Overflow
I have it working, except when I drag and drag an item into one of my lists, the item is positioned incorrrectly, has...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Drag 'n'Drop is a great interface solution. Taking something and dragging and dropping it is a clear and simple way to do many...
Read more >
Docs Event Dragging & Resizing - FullCalendar
How to enable and control where the user can drag-n-drop and resize events. ... for an event to revert to its original position...
Read more >
JavaFX Drag and Drop Example - 2022
The dropping is accomplished by releasing the mouse button while the gesture source is still over the target. When the gesture source is...
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