GithubHelp home page GithubHelp logo

Comments (3)

clauderic avatar clauderic commented on June 27, 2024 2

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.

clauderic avatar clauderic commented on June 27, 2024

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.

sscaff1 avatar sscaff1 commented on June 27, 2024

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)

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.