when I drag the button from the div on left, the target(drop) div, the button didn't stay where it was dropped and jump to somewhere near the top. It does work fine when I drag within the same div, the position is off only when I drag from the one from left. Like this:
this is the piece of code that deal with it:
const [, drop] = useDrop(
() => ({
accept: ItemTypes.BOX,
drop(item, monitor) {
const delta = monitor.getDifferenceFromInitialOffset();
let left = Math.round(item.left + delta.x);
let top = Math.round(item.top + delta.y);
moveBox(item, left, top);
return undefined;
}
}),
[moveBox]
);
this
is the full code. How do I calculate this properly? How do I fix this?