Skip to content

The swiss army knife of lossless video/audio editing

Ignore wheel events without any net delta

Claude8eeeb08a58ea
diff --git a/src/renderer/src/hooks/useTimelineScroll.ts b/src/renderer/src/hooks/useTimelineScroll.ts
index 3e88402b..17b9d64f 100644
--- a/src/renderer/src/hooks/useTimelineScroll.ts
+++ b/src/renderer/src/hooks/useTimelineScroll.ts
@@ -64,6 +64,7 @@ function useTimelineScroll({ wheelSensitivity, mouseWheelZoomModifierKey, mouseW
const action = getTimelineWheelAction({ pixelX, pixelY, modifiers: { ctrlKey, shiftKey, altKey, metaKey }, isPinch, wheelSensitivity, mouseWheelZoomModifierKey, mouseWheelFrameSeekModifierKey, mouseWheelKeyframeSeekModifierKey, invertTimelineScroll });
switch (action.type) {
+ case 'none': { break; }
case 'zoom': { zoomRel(action.amount); break; }
case 'frameSeek': { shortStep(action.direction); break; }
case 'keyframeSeek': { seekClosestKeyframe(action.direction); break; }
diff --git a/src/renderer/src/timelineWheel.test.ts b/src/renderer/src/timelineWheel.test.ts
index aa2a58f0..17bb714d 100644
--- a/src/renderer/src/timelineWheel.test.ts
+++ b/src/renderer/src/timelineWheel.test.ts
@@ -49,6 +49,11 @@ describe('zoom', () => {
expect(getAction({ pixelY: -100, modifiers: { ctrlKey: true }, zoomKey: 'meta', frameSeekKey: 'ctrl' })).toEqual({ type: 'frameSeek', direction: 1 });
});
+ test('horizontal scroll with ctrl does not zoom', () => {
+ expect(getAction({ pixelX: 30, modifiers: { ctrlKey: true } })).toEqual({ type: 'none' });
+ expect(getAction({ pixelX: 30, modifiers: { ctrlKey: true, shiftKey: true } })).toEqual({ type: 'none' });
+ });
+
test('shift as zoom modifier, where shift+wheel arrives as horizontal scroll', () => {
expect(getAction({ pixelX: -100, modifiers: { shiftKey: true }, zoomKey: 'shift', keyframeSeekKey: 'meta' })).toEqual({ type: 'zoom', amount: 40 });
});
@@ -66,4 +71,10 @@ describe('seek', () => {
expect(getAction({ pixelX: -100, modifiers: { shiftKey: true } })).toEqual({ type: 'keyframeSeek', direction: 1 });
expect(getAction({ pixelX: -100, modifiers: { shiftKey: true }, invertTimelineScroll: true })).toEqual({ type: 'keyframeSeek', direction: -1 });
});
+
+ test('no action without any net delta', () => {
+ expect(getAction({ modifiers: { altKey: true } })).toEqual({ type: 'none' });
+ expect(getAction({ pixelX: 3, pixelY: -3, modifiers: { altKey: true } })).toEqual({ type: 'none' });
+ expect(getAction({})).toEqual({ type: 'none' });
+ });
});
diff --git a/src/renderer/src/timelineWheel.ts b/src/renderer/src/timelineWheel.ts
index 4c1b5592..db672b91 100644
--- a/src/renderer/src/timelineWheel.ts
+++ b/src/renderer/src/timelineWheel.ts
@@ -11,6 +11,7 @@ export const keyMap = {
const pinchSensitivityFactor = 5;
export type WheelAction =
+ | { type: 'none' }
| { type: 'zoom', amount: number }
| { type: 'frameSeek', direction: number }
| { type: 'keyframeSeek', direction: number }
@@ -32,7 +33,7 @@ export function getTimelineWheelAction({ pixelX, pixelY, modifiers, isPinch, whe
// Wheel up / pinch out (negative delta) zooms in, like ctrl+wheel in browsers. Not affected by invertTimelineScroll, which is for seeking only.
// https://github.com/mifi/lossless-cut/issues/2703 https://github.com/mifi/lossless-cut/issues/2962
- const getZoomAction = (delta: number, factor = 1): WheelAction => ({ type: 'zoom', amount: -delta * wheelSensitivity * 0.4 * factor });
+ const getZoomAction = (delta: number, factor = 1): WheelAction => (delta === 0 ? { type: 'none' } : { type: 'zoom', amount: -delta * wheelSensitivity * 0.4 * factor });
if (isPinch) return getZoomAction(pixelY, pinchSensitivityFactor);
@@ -40,6 +41,7 @@ export function getTimelineWheelAction({ pixelX, pixelY, modifiers, isPinch, whe
if (isPressed(mouseWheelZoomModifierKey)) return getZoomAction(mouseWheelZoomModifierKey === 'shift' && pixelY === 0 ? pixelX : pixelY);
const delta = pixelX + pixelY;
+ if (delta === 0) return { type: 'none' }; // e.g. macOS momentum end events
const direction = invertTimelineScroll ? 1 : -1;
const unit = direction * delta > 0 ? 1 : -1;