Rebind mouse scroll wheel on Continuous Horizontal reader (#800)
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* 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 Box from '@mui/material/Box';
|
||||||
import { IReaderProps } from '@/typings';
|
import { IReaderProps } from '@/typings';
|
||||||
import { Page } from '@/components/reader/Page';
|
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 = () => {
|
const handleLoadNextonEnding = () => {
|
||||||
if (settings.readerType === 'ContinuesHorizontalLTR') {
|
if (settings.readerType === 'ContinuesHorizontalLTR') {
|
||||||
if (window.scrollX + window.innerWidth >= document.body.scrollWidth) {
|
if (window.scrollX + window.innerWidth >= document.body.scrollWidth) {
|
||||||
@@ -181,6 +187,7 @@ export function HorizontalPager(props: IReaderProps) {
|
|||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
}}
|
}}
|
||||||
onClick={clickControl}
|
onClick={clickControl}
|
||||||
|
onWheel={horizontalScroll}
|
||||||
>
|
>
|
||||||
{pages.map((page) => (
|
{pages.map((page) => (
|
||||||
<Page
|
<Page
|
||||||
|
|||||||
Reference in New Issue
Block a user