fix: properly calculate setDragImage position

This commit is contained in:
David Ilizarov 2022-05-09 01:03:13 -07:00 committed by bdbch
parent 07e8c522ea
commit 7401d45b7e

View File

@ -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)