neodrag icon indicating copy to clipboard operation
neodrag copied to clipboard

Preventing elements being dragged on top of other elements

Open antony opened this issue 1 year ago • 1 comments

I guess this ties in a bit with a feature you've named obstacles. As commonly seen in website-builders, or todo-lists, it'd be really useful to have a feature that prevents elements being dragged on top of other elements.

I guess the slight divergence from the obstacles feature would be the behaviour here. I'd like to be able to choose to either prevent dropping of an object by changing the cursor/otherwise indicating that it isn't possible, but more importantly - and this works better if you've got a grid enabled, and if you're restricting movement to a single direction, but I'd like to be able to tell other elements to move out of the way, allowing me space to drop the element. In the case that I dropped it there, the elements would move completely out of the way to accommodate the dropped one.

It's useful when you have a set of blocks and you just want them to be re-arrange-able.

Hopefully this is clear enough but if not, I can find an example!

antony avatar Feb 03 '23 23:02 antony

Hey Antony 👋

Not sure if this is fully in the scope of the library. I could add an option beforeCollide which fires when it is about to hit the obstacle area, and you could perform your logic in that.

How does that sound?

PuruVJ avatar Mar 20 '23 10:03 PuruVJ