mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
fix: properly calculate setDragImage position
This commit is contained in:
parent
07e8c522ea
commit
7401d45b7e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user