Giter Site home page Giter Site logo

Inplace placeholder about dnd HOT 3 OPEN

karesztrk avatar karesztrk commented on May 26, 2024
Inplace placeholder

from dnd.

Comments (3)

staticshock avatar staticshock commented on May 26, 2024 1

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.

staticshock avatar staticshock commented on May 26, 2024

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.

karesztrk avatar karesztrk commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.