Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/Manga/actions/operate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { debounce } from 'throttle-debounce';
import { debounce, throttle } from 'throttle-debounce';

import { getKeyboardCode } from 'helper';
import { getKeyboardCode, isEqual } from 'helper';
import type { State } from '../store';
import { store, setState, refs, _setState } from '../store';
import { zoom } from './zoom';
@@ -151,6 +151,11 @@ const scrollModeScroll = (dir: 'next' | 'prev') => {
closeScrollLock();
};

let wheelDeltaY = 0;
const clearWheelDeltaY = debounce(1000, () => {
wheelDeltaY = 0;
});

export const handleWheel = (e: WheelEvent) => {
e.stopPropagation();
if (e.ctrlKey || e.altKey) e.preventDefault();
@@ -174,6 +179,11 @@ export const handleWheel = (e: WheelEvent) => {
return zoom(store.zoom.scale + (isWheelDown ? -25 : 25), e);
}

wheelDeltaY += e.deltaY;
clearWheelDeltaY();
if (Math.abs(wheelDeltaY) < 40) return;
wheelDeltaY = 0;

return turnPage(isWheelDown ? 'next' : 'prev');
};

0 comments on commit 141612a

Please sign in to comment.