Comments (3)
Ah, yes, I don't think that's possible with this library. From what I've seen in the source, the way DND works is that it adds an invisible placeholder at the bottom of the list, and then adds transform: translate(<x-offset>, <y-offset>)
to all the displaced DOM nodes to create the appearance of an empty spot under the element you're dragging. When you style the "placeholder", this becomes obvious, and sounds like exactly what you're running into.
from dnd.
Yes:
<Droppable droppableId={column.id}>
{(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef}>
{items.map((item, index) => (
<Draggable key={item.id} draggableId={item.id} index={index}>
{(provided) => (
<Item
key={item.id}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
/>
)}
</Draggable>
))}
{provided.placeholder}
</div>
)}
</Droppable>
{provided.placeholder}
is where the magic happens.
from dnd.
Yes:
<Droppable droppableId={column.id}> {(provided) => ( <div {...provided.droppableProps} ref={provided.innerRef}> {items.map((item, index) => ( <Draggable key={item.id} draggableId={item.id} index={index}> {(provided) => ( <Item key={item.id} ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps} /> )} </Draggable> ))} {provided.placeholder} </div> )} </Droppable>
{provided.placeholder}
is where the magic happens.
Hey. Thanks for this recommendation but I still don't get it. I render the placeholder as you suggested. The placeholder is there correctly. But it's always rendered at the end of the list. What I want is to be rendered exactly under the dragged item. So I can put an overlay there that shows that the item is being dragged/used.
It should be something similar that dndkit does: storybook
from dnd.
Related Issues (20)
- hello-pangea/dnd does not work with react-virtuoso if the rows are different heights HOT 1
- add support to granular control over which items can be combined with within the list HOT 1
- unable to get dnd to work with react-table v8
- Support overlapping Droppables via z-index prioritization HOT 1
- How to simulate Drag and Drop with JavaScript? HOT 1
- Laggy drop behaviour on NextJS 13 (App dir) HOT 3
- DND on table - React 18, NextJs, hello-pangea 16.3
- DND not firing the OnDragEnd function HOT 2
- No drag cursor on first render HOT 1
- Keep draggable in the home list when cloned HOT 4
- Migrate from CircleCI to GitHub Actions
- App could not compile due to optional chaining HOT 4
- Wrong behaivoir droppable HOT 1
- Support redux 5 HOT 6
- Allow to skip dragging on specified elements
- How do I handle elements that wrap lines? HOT 2
- Disable the keyboard for drag and drop
- Usage with React Flow
- Draggable item not displaying properly when dragging
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.