Skip to content

Commit

Permalink
fix(useDraggable): use clientX instead of pageX, close #2053 (#2054)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefnotch committed Dec 16, 2022
1 parent 161fdb0 commit c91867f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/useDraggable/index.ts
Expand Up @@ -104,8 +104,8 @@ export function useDraggable(target: MaybeComputedRef<HTMLElement | SVGElement |
return
const rect = resolveUnref(target)!.getBoundingClientRect()
const pos = {
x: e.pageX - rect.left,
y: e.pageY - rect.top,
x: e.clientX - rect.left,
y: e.clientY - rect.top,
}
if (options.onStart?.(pos, e) === false)
return
Expand All @@ -118,8 +118,8 @@ export function useDraggable(target: MaybeComputedRef<HTMLElement | SVGElement |
if (!pressedDelta.value)
return
position.value = {
x: e.pageX - pressedDelta.value.x,
y: e.pageY - pressedDelta.value.y,
x: e.clientX - pressedDelta.value.x,
y: e.clientY - pressedDelta.value.y,
}
options.onMove?.(position.value, e)
handleEvent(e)
Expand Down

0 comments on commit c91867f

Please sign in to comment.