diff --git a/public/locales/en.json b/public/locales/en.json index e1520359..b2abb1c7 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -881,6 +881,8 @@ "exit_mode": "Open page on exit", "hotkey": { "auto_scroll": "Toggle auto scroll", + "auto_scroll_speed_decrease": "Decrease auto scroll speed", + "auto_scroll_speed_increase": "Increase auto scroll speed", "menu": "Toggle menu", "next_chapter": "Next chapter", "next_page": "Next page", diff --git a/src/modules/reader/components/ReaderHotkeys.tsx b/src/modules/reader/components/ReaderHotkeys.tsx index 2ebbbb7a..227aaa91 100644 --- a/src/modules/reader/components/ReaderHotkeys.tsx +++ b/src/modules/reader/components/ReaderHotkeys.tsx @@ -15,6 +15,7 @@ import { IReaderSettings, ReaderHotkey } from '@/modules/reader/types/Reader.typ import { useReaderOverlayContext } from '@/modules/reader/contexts/ReaderOverlayContext.tsx'; import { getNextRotationValue } from '@/modules/core/utils/ValueRotationButton.utils.ts'; import { + AUTO_SCROLL_SPEED, CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION, READER_PAGE_SCALE_MODE_VALUES, ReaderScrollAmount, @@ -69,8 +70,15 @@ export const ReaderHotkeys = ({ const { enableScope, disableScope } = useHotkeysContext(); const { manga } = useReaderStateMangaContext(); const { isVisible, setIsVisible: setIsOverlayVisible } = useReaderOverlayContext(); - const { hotkeys, pageScaleMode, shouldStretchPage, shouldOffsetDoubleSpreads, readingMode, readingDirection } = - ReaderService.useSettings(); + const { + hotkeys, + pageScaleMode, + shouldStretchPage, + shouldOffsetDoubleSpreads, + readingMode, + readingDirection, + autoScroll, + } = ReaderService.useSettings(); const automaticScrolling = useReaderAutoScrollContext(); const openChapter = ReaderControls.useOpenChapter(); @@ -184,9 +192,26 @@ export const ReaderHotkeys = ({ [updateSetting, deleteSetting, readingDirection.value, readingDirection.isDefault], ); useHotkeys(hotkeys[ReaderHotkey.TOGGLE_AUTO_SCROLL], automaticScrolling.toggleActive, { preventDefault: true }, [ - updateSetting, automaticScrolling.toggleActive, ]); + useHotkeys( + hotkeys[ReaderHotkey.AUTO_SCROLL_SPEED_INCREASE], + () => + updateSetting('autoScroll', { + ...autoScroll, + value: Math.min(AUTO_SCROLL_SPEED.max, autoScroll.value + AUTO_SCROLL_SPEED.step), + }), + [updateSetting, autoScroll.value], + ); + useHotkeys( + hotkeys[ReaderHotkey.AUTO_SCROLL_SPEED_DECREASE], + () => + updateSetting('autoScroll', { + ...autoScroll, + value: Math.max(AUTO_SCROLL_SPEED.min, autoScroll.value - AUTO_SCROLL_SPEED.step), + }), + [updateSetting, autoScroll.value], + ); useEffect(() => { enableScope(HotkeyScope.READER); diff --git a/src/modules/reader/components/settings/hotkeys/ReaderSettingHotkey.tsx b/src/modules/reader/components/settings/hotkeys/ReaderSettingHotkey.tsx index 18976e82..2e0817d7 100644 --- a/src/modules/reader/components/settings/hotkeys/ReaderSettingHotkey.tsx +++ b/src/modules/reader/components/settings/hotkeys/ReaderSettingHotkey.tsx @@ -34,6 +34,8 @@ const READER_HOTKEY_TO_TITLE: Record = { [ReaderHotkey.CYCLE_READING_MODE]: 'reader.settings.hotkey.reading_mode', [ReaderHotkey.CYCLE_READING_DIRECTION]: 'reader.settings.hotkey.reading_direction', [ReaderHotkey.TOGGLE_AUTO_SCROLL]: 'reader.settings.hotkey.auto_scroll', + [ReaderHotkey.AUTO_SCROLL_SPEED_INCREASE]: 'reader.settings.hotkey.auto_scroll_speed_increase', + [ReaderHotkey.AUTO_SCROLL_SPEED_DECREASE]: 'reader.settings.hotkey.auto_scroll_speed_decrease', }; export const ReaderSettingHotkey = ({ diff --git a/src/modules/reader/constants/ReaderSettings.constants.tsx b/src/modules/reader/constants/ReaderSettings.constants.tsx index 52a56e66..59544c2d 100644 --- a/src/modules/reader/constants/ReaderSettings.constants.tsx +++ b/src/modules/reader/constants/ReaderSettings.constants.tsx @@ -124,6 +124,8 @@ export const DEFAULT_READER_SETTINGS: IReaderSettings = { [ReaderHotkey.CYCLE_READING_MODE]: ['r'], [ReaderHotkey.CYCLE_READING_DIRECTION]: ['t'], [ReaderHotkey.TOGGLE_AUTO_SCROLL]: ['space'], + [ReaderHotkey.AUTO_SCROLL_SPEED_INCREASE]: ['b'], + [ReaderHotkey.AUTO_SCROLL_SPEED_DECREASE]: ['v'], }, imagePreLoadAmount: 5, shouldUseAutoWebtoonMode: true, diff --git a/src/modules/reader/types/Reader.types.ts b/src/modules/reader/types/Reader.types.ts index 6a9c7751..d8f9424f 100644 --- a/src/modules/reader/types/Reader.types.ts +++ b/src/modules/reader/types/Reader.types.ts @@ -217,6 +217,8 @@ export enum ReaderHotkey { CYCLE_READING_MODE, CYCLE_READING_DIRECTION, TOGGLE_AUTO_SCROLL, + AUTO_SCROLL_SPEED_INCREASE, + AUTO_SCROLL_SPEED_DECREASE, } export interface ReaderPagerProps