You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So looking for how i can reject or cancel a drag/drop if the location where the drop is going to occur is invalid. I have looked through the source and tried various ways to edit the new or old Item in the callbacks. However, at the end of the day i am looking for a means to say "hey you cannot drop there" or restrict dragging on an axis like you can only drag items left and right or up and down. Which this seems harder than the first option.
The only way i have mildly gotten this to work is throwing an error which is not great cause it causes other problems. I have googled high and low and looked in a lot of different places.
In code this is what i would like to be able to do or least think i should
constonDrag=(layout,oldItem,newItem)=>{if(oldItem.x===newItem.x||oldItem.y===newItem.y){// drag is still good continue to let it continuereturntrue;}// drag is invalid since the item has moved diagonally essentially// show the drag/drop is not valid returnfalse;}return(<ResponsiveGridLayoutisDraggable={true}onDrag={onDrag}onDragStop={onDrag}>{children}</ResponsiveGridLayout>);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So looking for how i can reject or cancel a drag/drop if the location where the drop is going to occur is invalid. I have looked through the source and tried various ways to edit the new or old Item in the callbacks. However, at the end of the day i am looking for a means to say "hey you cannot drop there" or restrict dragging on an axis like you can only drag items left and right or up and down. Which this seems harder than the first option.
For example in the react-dnd API there is an canDrop method https://react-dnd.github.io/react-dnd/docs/api/use-drop you can define such that if the current drag operation can be dropped wherever it is.
The only way i have mildly gotten this to work is throwing an error which is not great cause it causes other problems. I have googled high and low and looked in a lot of different places.
In code this is what i would like to be able to do or least think i should
Beta Was this translation helpful? Give feedback.
All reactions