From e12d495f29363558aec21a1f49677e6d7a4a036e Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Tue, 10 May 2022 15:27:43 +0200 Subject: [PATCH] Fix the bug where small wheel events would leak to cause unwanted scroll --- .../Right/HorizontallyScrollableArea.tsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/HorizontallyScrollableArea.tsx b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/HorizontallyScrollableArea.tsx index 096fef6..c6b38d0 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/HorizontallyScrollableArea.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/DopeSheet/Right/HorizontallyScrollableArea.tsx @@ -152,23 +152,6 @@ function useHandlePanAndZoom( if (!node) return 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 if (event.ctrlKey) { event.preventDefault() @@ -200,8 +183,9 @@ function useHandlePanAndZoom( val(layoutP.clippedSpace.setRange)( normalizeRange(newRange, [0, maxEnd]), ) + return } - // paning + // panning else if (event.shiftKey) { event.preventDefault() event.stopPropagation() @@ -220,6 +204,22 @@ function useHandlePanAndZoom( ) 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 } }