Skip to content

Commit

Permalink
fix: properly calculate setDragImage position
Browse files Browse the repository at this point in the history
  • Loading branch information
dilizarov authored and bdbch committed May 11, 2022
1 parent 07e8c52 commit 7401d45
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/NodeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7401d45

Please sign in to comment.