fix: less sensitive magic trackpad and mouse when flipping page, closes #1165 (#1172)

This commit is contained in:
Huang Xin
2025-05-17 14:56:22 +08:00
committed by GitHub
parent 5373b67aae
commit b7c1f5703c
@@ -12,13 +12,20 @@ export const useMouseEvent = (
const throttledScroll = throttle(handleContinuousScroll, 500, {
emitLast: false,
});
const throttledFlip = throttle(handlePageFlip, 1000, {
emitLast: false,
});
const handleMouseEvent = (msg: MessageEvent | React.MouseEvent<HTMLDivElement, MouseEvent>) => {
if (msg instanceof MessageEvent) {
if (msg.data && msg.data.bookKey === bookKey) {
if (msg.data.type === 'iframe-wheel') {
throttledScroll('mouse', -msg.data.deltaY, 0);
}
handlePageFlip(msg);
if (msg.data.type === 'iframe-wheel') {
throttledFlip(msg);
} else {
handlePageFlip(msg);
}
}
} else if (msg.type === 'wheel') {
const event = msg as React.WheelEvent<HTMLDivElement>;