Skip to content

Commit e966f0f

Browse files
committed
fix: pointer-events for persistent touch devices (e.g. a pen)
1 parent 99f33e9 commit e966f0f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

packages/pointer-events/src/pointer.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class Pointer {
127127
private buttonsDownTime: ButtonsTime = new Map()
128128
private readonly buttonsDown = new Set<number>()
129129

130-
//to handle interaction before first move
130+
//to handle interaction before first move (after exit)
131131
private wasMoved = false
132132
private onFirstMove: Array<(camera: PerspectiveCamera | OrthographicCamera) => void> = []
133133

@@ -392,18 +392,17 @@ export class Pointer {
392392
}
393393

394394
exit(nativeEvent: NativeEvent): void {
395-
if (!this.wasMoved) {
396-
this.onFirstMove.push(this.exit.bind(this, nativeEvent))
397-
return
398-
}
399-
400-
//reset state
401-
if (this.pointerCapture != null) {
402-
this.parentReleasePointerCapture?.()
403-
this.pointerCapture = undefined
395+
if (this.wasMoved) {
396+
//reset state
397+
if (this.pointerCapture != null) {
398+
this.parentReleasePointerCapture?.()
399+
this.pointerCapture = undefined
400+
}
401+
this.intersection = undefined
402+
this.commit(nativeEvent)
404403
}
405-
this.intersection = undefined
406-
this.commit(nativeEvent)
404+
this.onFirstMove.length = 0
405+
this.wasMoved = false
407406
}
408407
}
409408

0 commit comments

Comments
 (0)