Add "increase/decrease auto scroll speed" hotkeys
This commit is contained in:
@@ -881,6 +881,8 @@
|
|||||||
"exit_mode": "Open page on exit",
|
"exit_mode": "Open page on exit",
|
||||||
"hotkey": {
|
"hotkey": {
|
||||||
"auto_scroll": "Toggle auto scroll",
|
"auto_scroll": "Toggle auto scroll",
|
||||||
|
"auto_scroll_speed_decrease": "Decrease auto scroll speed",
|
||||||
|
"auto_scroll_speed_increase": "Increase auto scroll speed",
|
||||||
"menu": "Toggle menu",
|
"menu": "Toggle menu",
|
||||||
"next_chapter": "Next chapter",
|
"next_chapter": "Next chapter",
|
||||||
"next_page": "Next page",
|
"next_page": "Next page",
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { IReaderSettings, ReaderHotkey } from '@/modules/reader/types/Reader.typ
|
|||||||
import { useReaderOverlayContext } from '@/modules/reader/contexts/ReaderOverlayContext.tsx';
|
import { useReaderOverlayContext } from '@/modules/reader/contexts/ReaderOverlayContext.tsx';
|
||||||
import { getNextRotationValue } from '@/modules/core/utils/ValueRotationButton.utils.ts';
|
import { getNextRotationValue } from '@/modules/core/utils/ValueRotationButton.utils.ts';
|
||||||
import {
|
import {
|
||||||
|
AUTO_SCROLL_SPEED,
|
||||||
CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION,
|
CONTINUOUS_READING_MODE_TO_SCROLL_DIRECTION,
|
||||||
READER_PAGE_SCALE_MODE_VALUES,
|
READER_PAGE_SCALE_MODE_VALUES,
|
||||||
ReaderScrollAmount,
|
ReaderScrollAmount,
|
||||||
@@ -69,8 +70,15 @@ export const ReaderHotkeys = ({
|
|||||||
const { enableScope, disableScope } = useHotkeysContext();
|
const { enableScope, disableScope } = useHotkeysContext();
|
||||||
const { manga } = useReaderStateMangaContext();
|
const { manga } = useReaderStateMangaContext();
|
||||||
const { isVisible, setIsVisible: setIsOverlayVisible } = useReaderOverlayContext();
|
const { isVisible, setIsVisible: setIsOverlayVisible } = useReaderOverlayContext();
|
||||||
const { hotkeys, pageScaleMode, shouldStretchPage, shouldOffsetDoubleSpreads, readingMode, readingDirection } =
|
const {
|
||||||
ReaderService.useSettings();
|
hotkeys,
|
||||||
|
pageScaleMode,
|
||||||
|
shouldStretchPage,
|
||||||
|
shouldOffsetDoubleSpreads,
|
||||||
|
readingMode,
|
||||||
|
readingDirection,
|
||||||
|
autoScroll,
|
||||||
|
} = ReaderService.useSettings();
|
||||||
const automaticScrolling = useReaderAutoScrollContext();
|
const automaticScrolling = useReaderAutoScrollContext();
|
||||||
|
|
||||||
const openChapter = ReaderControls.useOpenChapter();
|
const openChapter = ReaderControls.useOpenChapter();
|
||||||
@@ -184,9 +192,26 @@ export const ReaderHotkeys = ({
|
|||||||
[updateSetting, deleteSetting, readingDirection.value, readingDirection.isDefault],
|
[updateSetting, deleteSetting, readingDirection.value, readingDirection.isDefault],
|
||||||
);
|
);
|
||||||
useHotkeys(hotkeys[ReaderHotkey.TOGGLE_AUTO_SCROLL], automaticScrolling.toggleActive, { preventDefault: true }, [
|
useHotkeys(hotkeys[ReaderHotkey.TOGGLE_AUTO_SCROLL], automaticScrolling.toggleActive, { preventDefault: true }, [
|
||||||
updateSetting,
|
|
||||||
automaticScrolling.toggleActive,
|
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(() => {
|
useEffect(() => {
|
||||||
enableScope(HotkeyScope.READER);
|
enableScope(HotkeyScope.READER);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ const READER_HOTKEY_TO_TITLE: Record<ReaderHotkey, TranslationKey> = {
|
|||||||
[ReaderHotkey.CYCLE_READING_MODE]: 'reader.settings.hotkey.reading_mode',
|
[ReaderHotkey.CYCLE_READING_MODE]: 'reader.settings.hotkey.reading_mode',
|
||||||
[ReaderHotkey.CYCLE_READING_DIRECTION]: 'reader.settings.hotkey.reading_direction',
|
[ReaderHotkey.CYCLE_READING_DIRECTION]: 'reader.settings.hotkey.reading_direction',
|
||||||
[ReaderHotkey.TOGGLE_AUTO_SCROLL]: 'reader.settings.hotkey.auto_scroll',
|
[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 = ({
|
export const ReaderSettingHotkey = ({
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ export const DEFAULT_READER_SETTINGS: IReaderSettings = {
|
|||||||
[ReaderHotkey.CYCLE_READING_MODE]: ['r'],
|
[ReaderHotkey.CYCLE_READING_MODE]: ['r'],
|
||||||
[ReaderHotkey.CYCLE_READING_DIRECTION]: ['t'],
|
[ReaderHotkey.CYCLE_READING_DIRECTION]: ['t'],
|
||||||
[ReaderHotkey.TOGGLE_AUTO_SCROLL]: ['space'],
|
[ReaderHotkey.TOGGLE_AUTO_SCROLL]: ['space'],
|
||||||
|
[ReaderHotkey.AUTO_SCROLL_SPEED_INCREASE]: ['b'],
|
||||||
|
[ReaderHotkey.AUTO_SCROLL_SPEED_DECREASE]: ['v'],
|
||||||
},
|
},
|
||||||
imagePreLoadAmount: 5,
|
imagePreLoadAmount: 5,
|
||||||
shouldUseAutoWebtoonMode: true,
|
shouldUseAutoWebtoonMode: true,
|
||||||
|
|||||||
@@ -217,6 +217,8 @@ export enum ReaderHotkey {
|
|||||||
CYCLE_READING_MODE,
|
CYCLE_READING_MODE,
|
||||||
CYCLE_READING_DIRECTION,
|
CYCLE_READING_DIRECTION,
|
||||||
TOGGLE_AUTO_SCROLL,
|
TOGGLE_AUTO_SCROLL,
|
||||||
|
AUTO_SCROLL_SPEED_INCREASE,
|
||||||
|
AUTO_SCROLL_SPEED_DECREASE,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReaderPagerProps
|
export interface ReaderPagerProps
|
||||||
|
|||||||
Reference in New Issue
Block a user