Skip to content

Commit

Permalink
Rebind mouse scroll wheel on Continuous Horizontal reader (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrutuZ authored Sep 14, 2024
1 parent 164d810 commit 7f330ec
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/reader/pager/HorizontalPager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -181,6 +187,7 @@ export function HorizontalPager(props: IReaderProps) {
userSelect: 'none',
}}
onClick={clickControl}
onWheel={horizontalScroll}
>
{pages.map((page) => (
<Page
Expand Down

0 comments on commit 7f330ec

Please sign in to comment.