fix: properly calculate setDragImage position
This commit is contained in:
@@ -82,8 +82,12 @@ export class NodeView<
|
|||||||
const domBox = this.dom.getBoundingClientRect()
|
const domBox = this.dom.getBoundingClientRect()
|
||||||
const handleBox = dragHandle.getBoundingClientRect()
|
const handleBox = dragHandle.getBoundingClientRect()
|
||||||
|
|
||||||
x = handleBox.x - domBox.x + event.offsetX
|
// In React, we have to go through nativeEvent to reach offsetX/offsetY.
|
||||||
y = handleBox.y - domBox.y + event.offsetY
|
const offsetX = event.offsetX ?? (event as any).nativeEvent?.offsetX
|
||||||
|
const offsetY = event.offsetY ?? (event as any).nativeEvent?.offsetY
|
||||||
|
|
||||||
|
x = handleBox.x - domBox.x + offsetX
|
||||||
|
y = handleBox.y - domBox.y + offsetY
|
||||||
}
|
}
|
||||||
|
|
||||||
event.dataTransfer?.setDragImage(this.dom, x, y)
|
event.dataTransfer?.setDragImage(this.dom, x, y)
|
||||||
|
|||||||
Reference in New Issue
Block a user