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.

Hi, I’m having problem with isDragging - it stays on original position instead of moving with dragged element (red border). This probably is not a bug, just me not knowing how this works.

I’m updating data via flux, doing nothing with isDragging.

http://fluid.cz/projects/react-dnd/

http://fluid.cz/projects/react-dnd/code.zip

Thanks for help

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
gaearoncommented, Mar 4, 2015

Oh, I see your point now. The problem in your example is fixed by giving your items a unique key each. (It may be some global ID, just not the index.) There’s a warning in console about that. If you give them keys, React will move the original component, so isDragging will be relevant.

It’s not perfect we can’t handle the situation gracefully without keys. This will be a good stress case for whatever API we implement in #64 but we don’t support this yet.

2reactions
gaearoncommented, Mar 4, 2015

isDragging only reflects the state of dragging. The item won’t move “by itself” because we’re not touching the DOM in React DnD—we’re letting you do it.

You have two options:

  • Let the browser draw drag preview (happens by default) and hide the “real” component when isDragging is true by either returning null from render or using opacity: 0. Sortable example covers this technique.
  • Give the browser an empty image as drag preview (note that this currently won’t work in IE). Use a custom drag layer to draw your own component as it moves across the screen. This way you can have any customization you want. Drag around custom example covers this technique.

Hope it helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

isDragging | Apple Developer Documentation
isDragging. A Boolean value that indicates whether the user has begun scrolling the content. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.0+ tvOS 9.0+ ......
Read more >
DraggableStateSnapshot.isDragging - Javascript - Tabnine
Best JavaScript code snippets using react-beautiful-dnd.DraggableStateSnapshot.isDragging(Showing top 15 results out of 315).
Read more >
DragSourceMonitor - React DnD
isDragging () : Returns true if a drag operation is in progress, and either the owner initiated the drag, or its isDragging() is...
Read more >
useDrag method of react-dnd , cannot get isDragging in ...
Got the answer from react-dnd TSX example. sandbox url const [{ isDragging }, drag] = useDrag({ type: "image", item: () => { return...
Read more >
Dragging Over An Element Without Triggering Hover State
isDragging () to set the isDragging state use !!monitor.getItem() , like so: const [{ opacity, isDragging } ...
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