From 7f330ec5421dbcded673408cf3519650f43a5a0d Mon Sep 17 00:00:00 2001 From: BrutuZ Date: Sat, 14 Sep 2024 16:58:16 -0300 Subject: [PATCH] Rebind mouse scroll wheel on Continuous Horizontal reader (#800) --- src/components/reader/pager/HorizontalPager.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/reader/pager/HorizontalPager.tsx b/src/components/reader/pager/HorizontalPager.tsx index c04fc3a2..02714dee 100644 --- a/src/components/reader/pager/HorizontalPager.tsx +++ b/src/components/reader/pager/HorizontalPager.tsx @@ -6,7 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { MouseEvent as ReactMouseEvent, useCallback, useEffect, useRef } from 'react'; +import { MouseEvent as ReactMouseEvent, WheelEvent as ReactWheelEvent, useCallback, useEffect, useRef } from 'react'; import Box from '@mui/material/Box'; import { IReaderProps } from '@/typings'; import { Page } from '@/components/reader/Page'; @@ -96,6 +96,12 @@ export function HorizontalPager(props: IReaderProps) { } } + function horizontalScroll(e: ReactWheelEvent) { + window.scrollBy({ + left: settings.readerType === 'ContinuesHorizontalLTR' ? e.deltaY : e.deltaY * -1, + }); + } + const handleLoadNextonEnding = () => { if (settings.readerType === 'ContinuesHorizontalLTR') { if (window.scrollX + window.innerWidth >= document.body.scrollWidth) { @@ -181,6 +187,7 @@ export function HorizontalPager(props: IReaderProps) { userSelect: 'none', }} onClick={clickControl} + onWheel={horizontalScroll} > {pages.map((page) => (