Comments (3)
Gotcha. That's a fair use-case.
For the time being, you'd need knowledge of what type of overlay the associated active draggable id
is associated to. For now, you could do something like this: https://codesandbox.io/s/affectionate-carson-b9jif
In future versions of @dnd-kit
, it will be possible to add metadata for your draggable elements to make this easier.
from dnd-kit.
Hey @sscaff1, currently the <DragOverlay>
component assumes that there are no more than one defined per <DndContext>
provider. Try lifting the state up outside of your draggable components.
https://codesandbox.io/s/focused-thompson-5cxqv?file=/src/App.js
Having more than a single <DragOverlay>
component may be something that is supported in the future, but no immediate plans around this as use-cases seem limited.
I'm not familiar with the specifics of what the use-case you're building are, but my general advice would be that rendering the <DragOverlay>
component within the same component where you use useDraggable
is not a good idea.
The rationale being that if your draggable component is reparented, the drop animation will not work since your draggable component will unmount and re-mount (which will also cause the <DragOverlay>
component to unmount and re-mount). Further, if your draggable component is unmounted while dragging, for example, if it is reparented onDragOver
, the <DragOverlay>
component will also unmount and re-mount, which could lead to unexpected results.
from dnd-kit.
Thanks for explaining this. I want to render a different element depending in the DragOverlay on the type of the draggable. I'm guessing; however, I can just use over
and active
to do that.
from dnd-kit.
Related Issues (20)
- Drag down invalid HOT 1
- AutoScroll absolute thresholds and acceleration
- Drag Handle stops working when its visibility is toggled (hidden then shown) HOT 2
- Multiple containers : possibility of hitting minified error due to too many re-renders
- How do I get access to the Draggable data once it is over a Droppable? HOT 1
- Automatically generate id for components
- Sorting doesn't stay at it's position or moves somewhere else HOT 1
- Cannot auto-scroll back to first vertical list when used in a horizontally scrollable parent
- pnpm add @dnd-kit/sortable
- Click-and-drop?
- DND Kit / React Virtual Re-renders more with DndContent HOT 3
- @dnd-kit/react (beta). Wrong nested scrollable elements activating HOT 8
- [next] Feature Request: Apply different `activationConstraints` based on `pointerType` HOT 1
- Dragging object does not trigger scrolling in target scroll container (despite use of DragOverlay) HOT 3
- [next] controlled or cancellable useSortable HOT 5
- Nextjs with @dnd-kit/react HOT 4
- Trouble with nested droppables HOT 1
- Add `over` property to the DropAnimationFunctionArguments
- Trouble with " select "
- Code Sandbox for Experimental Docs HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dnd-kit.