Fix the bug where small wheel events would leak to cause unwanted scroll
This commit is contained in:
parent
ab8361d24a
commit
e12d495f29
1 changed files with 18 additions and 18 deletions
|
@ -152,23 +152,6 @@ function useHandlePanAndZoom(
|
||||||
if (!node) return
|
if (!node) return
|
||||||
|
|
||||||
const receiveWheelEvent = (event: WheelEvent) => {
|
const receiveWheelEvent = (event: WheelEvent) => {
|
||||||
if (Math.abs(event.deltaY) < Math.abs(event.deltaX)) {
|
|
||||||
// receiveVerticalWheelEvent(event)
|
|
||||||
event.preventDefault()
|
|
||||||
event.stopPropagation()
|
|
||||||
|
|
||||||
const scaledSpaceToUnitSpace = val(layoutP.scaledSpace.toUnitSpace)
|
|
||||||
const deltaPos = scaledSpaceToUnitSpace(event.deltaX * 1)
|
|
||||||
const oldRange = val(layoutP.clippedSpace.range)
|
|
||||||
const newRange = mapValues(oldRange, (p) => p + deltaPos)
|
|
||||||
|
|
||||||
const setRange = val(layoutP.clippedSpace.setRange)
|
|
||||||
|
|
||||||
setRange(newRange)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// pinch
|
// pinch
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -200,8 +183,9 @@ function useHandlePanAndZoom(
|
||||||
val(layoutP.clippedSpace.setRange)(
|
val(layoutP.clippedSpace.setRange)(
|
||||||
normalizeRange(newRange, [0, maxEnd]),
|
normalizeRange(newRange, [0, maxEnd]),
|
||||||
)
|
)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
// paning
|
// panning
|
||||||
else if (event.shiftKey) {
|
else if (event.shiftKey) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
@ -220,6 +204,22 @@ function useHandlePanAndZoom(
|
||||||
)
|
)
|
||||||
|
|
||||||
val(layoutP.clippedSpace.setRange)(newRange)
|
val(layoutP.clippedSpace.setRange)(newRange)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
receiveVerticalWheelEvent(event)
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
|
||||||
|
const scaledSpaceToUnitSpace = val(layoutP.scaledSpace.toUnitSpace)
|
||||||
|
const deltaPos = scaledSpaceToUnitSpace(event.deltaX * 1)
|
||||||
|
const oldRange = val(layoutP.clippedSpace.range)
|
||||||
|
const newRange = mapValues(oldRange, (p) => p + deltaPos)
|
||||||
|
|
||||||
|
const setRange = val(layoutP.clippedSpace.setRange)
|
||||||
|
|
||||||
|
setRange(newRange)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue