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