Skip to content

Commit

Permalink
Fix: add stopPropagation to draggable
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 26, 2023
1 parent e9cd82c commit 03e0abc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ export function makeDraggable(
onStart?: (x: number, y: number) => void,
onEnd?: () => void,
threshold = 5,
mouseButton = 0,
): () => void {
if (!element) return () => void 0

let unsubscribeDocument = () => void 0

const onPointerDown = (event: PointerEvent) => {
if (event.button !== 0) return
if (event.button !== mouseButton) return

event.preventDefault()
event.stopPropagation()

let startX = event.clientX
let startY = event.clientY
let isDragging = false

const onPointerMove = (event: PointerEvent) => {
event.preventDefault()
event.stopPropagation()

const x = event.clientX
const y = event.clientY
const dx = x - startX
Expand Down

0 comments on commit 03e0abc

Please sign in to comment.