fix: wheel event handled twice issue (#1050)
This commit is contained in:
parent
d155ac5968
commit
8404528aa6
1 changed files with 4 additions and 1 deletions
|
@ -12,6 +12,7 @@ export function useZoomEvents<T extends HTMLElement>(
|
|||
const rOriginPoint = React.useRef<number[] | undefined>(undefined)
|
||||
const rPinchPoint = React.useRef<number[] | undefined>(undefined)
|
||||
const rDelta = React.useRef<number[]>([0, 0])
|
||||
const rWheelLastTimeStamp = React.useRef<number>(0)
|
||||
|
||||
const { inputs, bounds, callbacks } = useTLContext()
|
||||
|
||||
|
@ -32,7 +33,9 @@ export function useZoomEvents<T extends HTMLElement>(
|
|||
const handleWheel = React.useCallback<Handler<'wheel', WheelEvent>>(
|
||||
({ event: e }) => {
|
||||
e.preventDefault()
|
||||
if (inputs.isPinching) return
|
||||
if (inputs.isPinching || e.timeStamp <= rWheelLastTimeStamp.current) return
|
||||
|
||||
rWheelLastTimeStamp.current = e.timeStamp
|
||||
|
||||
const [x, y, z] = normalizeWheel(e)
|
||||
|
||||
|
|
Loading…
Reference in a new issue