Skip to content

Commit

Permalink
fix: slider behavior when using multiple pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohlender committed Sep 3, 2024
1 parent 1db12ee commit 825b3b4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/kits/default/src/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const Slider: (props: SliderProperties & RefAttributes<ComponentInternals
onChange.current = onValueChange
const hasProvidedValue = providedValue != null
const handler = useMemo(() => {
let down: boolean = false
let downPointerId: number | undefined
function setValue(e: ThreeEvent<PointerEvent>) {
if (internalRef.current == null) {
return
Expand All @@ -58,21 +58,24 @@ export const Slider: (props: SliderProperties & RefAttributes<ComponentInternals
}
return {
onPointerDown(e) {
down = true
if (downPointerId != null) {
return
}
downPointerId = e.pointerId
setValue(e)
;(e.target as HTMLElement).setPointerCapture(e.pointerId)
},
onPointerMove(e) {
if (!down) {
if (downPointerId != e.pointerId) {
return
}
setValue(e)
},
onPointerUp(e) {
if (!down) {
if (downPointerId == null) {
return
}
down = false
downPointerId = undefined
e.stopPropagation()
},
} satisfies EventHandlers
Expand Down

0 comments on commit 825b3b4

Please sign in to comment.