Add "scroll amount" setting
This commit is contained in:
@@ -18,7 +18,6 @@ import {
|
||||
AUTO_SCROLL_SPEED,
|
||||
CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION,
|
||||
READER_PAGE_SCALE_MODE_VALUES,
|
||||
ReaderScrollAmount,
|
||||
READING_DIRECTION_VALUES,
|
||||
READING_MODE_VALUES,
|
||||
} from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
||||
@@ -79,6 +78,7 @@ export const ReaderHotkeys = ({
|
||||
readingMode,
|
||||
readingDirection,
|
||||
autoScroll,
|
||||
scrollAmount,
|
||||
} = ReaderService.useSettings();
|
||||
const automaticScrolling = useReaderAutoScrollContext();
|
||||
const { setShowPreview } = useReaderTapZoneContext();
|
||||
@@ -106,10 +106,10 @@ export const ReaderHotkeys = ({
|
||||
openChapter,
|
||||
setIsOverlayVisible,
|
||||
setShowPreview,
|
||||
ReaderScrollAmount.SMALL,
|
||||
scrollAmount,
|
||||
),
|
||||
{ preventDefault: true },
|
||||
[readingMode.value, readingDirection.value, themeDirection, openChapter],
|
||||
[readingMode.value, readingDirection.value, themeDirection, openChapter, scrollAmount],
|
||||
);
|
||||
useHotkeys(
|
||||
hotkeys[ReaderHotkey.SCROLL_FORWARD],
|
||||
@@ -125,10 +125,10 @@ export const ReaderHotkeys = ({
|
||||
openChapter,
|
||||
setIsOverlayVisible,
|
||||
setShowPreview,
|
||||
ReaderScrollAmount.SMALL,
|
||||
scrollAmount,
|
||||
),
|
||||
{ preventDefault: true },
|
||||
[readingMode.value, readingDirection.value, themeDirection, openChapter],
|
||||
[readingMode.value, readingDirection.value, themeDirection, openChapter, scrollAmount],
|
||||
);
|
||||
useHotkeys(
|
||||
hotkeys[ReaderHotkey.PREVIOUS_CHAPTER],
|
||||
|
||||
@@ -18,6 +18,7 @@ import { isOffsetDoubleSpreadPagesEditable } from '@/modules/reader/utils/Reader
|
||||
import { SliderInput } from '@/modules/core/components/inputs/SliderInput.tsx';
|
||||
import { DEFAULT_READER_SETTINGS } from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
||||
import { ReaderSettingAutoScroll } from '@/modules/reader/components/settings/behaviour/ReaderSettingAutoScroll.tsx';
|
||||
import { ReaderSettingScrollAmount } from '@/modules/reader/components/settings/behaviour/ReaderSettingScrollAmount.tsx';
|
||||
|
||||
export const ReaderBehaviourSettings = ({
|
||||
settings,
|
||||
@@ -37,6 +38,10 @@ export const ReaderBehaviourSettings = ({
|
||||
exitMode={settings.exitMode}
|
||||
setExitMode={(value) => updateSetting('exitMode', value)}
|
||||
/>
|
||||
<ReaderSettingScrollAmount
|
||||
scrollAmount={settings.scrollAmount}
|
||||
setScrollAmount={(value) => updateSetting('scrollAmount', value)}
|
||||
/>
|
||||
<CheckboxInput
|
||||
label={t('reader.settings.label.skip_dup_chapters')}
|
||||
checked={settings.shouldSkipDupChapters}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { IReaderSettings } from '@/modules/reader/types/Reader.types.ts';
|
||||
import { ValueToDisplayData } from '@/modules/core/Core.types.ts';
|
||||
import { ButtonSelectInput } from '@/modules/core/components/inputs/ButtonSelectInput.tsx';
|
||||
import { ReaderScrollAmount } from '@/modules/reader/constants/ReaderSettings.constants.tsx';
|
||||
|
||||
const VALUE_TO_DISPLAY_DATA: ValueToDisplayData<ReaderScrollAmount> = {
|
||||
[ReaderScrollAmount.SMALL]: {
|
||||
title: 'global.label.small',
|
||||
icon: null,
|
||||
},
|
||||
[ReaderScrollAmount.MEDIUM]: {
|
||||
title: 'global.label.medium',
|
||||
icon: null,
|
||||
},
|
||||
[ReaderScrollAmount.LARGE]: {
|
||||
title: 'global.label.large',
|
||||
icon: null,
|
||||
},
|
||||
};
|
||||
|
||||
const READER_SCROLL_AMOUNT_VALUES = Object.values(ReaderScrollAmount).filter((value) => typeof value === 'number');
|
||||
|
||||
export const ReaderSettingScrollAmount = ({
|
||||
scrollAmount,
|
||||
setScrollAmount,
|
||||
}: Pick<IReaderSettings, 'scrollAmount'> & {
|
||||
setScrollAmount: (amount: ReaderScrollAmount) => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<ButtonSelectInput
|
||||
label={t('reader.settings.scroll_amount')}
|
||||
value={scrollAmount}
|
||||
values={READER_SCROLL_AMOUNT_VALUES}
|
||||
setValue={setScrollAmount}
|
||||
valueToDisplayData={VALUE_TO_DISPLAY_DATA}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user