From 214f687c2e90f541dad19dc55518b0886ed1ffe7 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 22 Jan 2025 16:52:24 +0800 Subject: [PATCH] feat(webui): add page margin option in webtoon reader Closes: #1512 --- .../components/readers/ContinuousReader.vue | 6 +++- .../functions/shortcuts/continuous-reader.ts | 3 ++ komga-webui/src/locales/en.json | 3 ++ komga-webui/src/plugins/persisted-state.ts | 4 +++ komga-webui/src/types/enum-reader.ts | 1 + komga-webui/src/views/DivinaReader.vue | 34 ++++++++++++++++++- 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/komga-webui/src/components/readers/ContinuousReader.vue b/komga-webui/src/components/readers/ContinuousReader.vue index 831cc2c5..99c3e924 100644 --- a/komga-webui/src/components/readers/ContinuousReader.vue +++ b/komga-webui/src/components/readers/ContinuousReader.vue @@ -10,7 +10,7 @@ :height="calcHeight(page)" :width="calcWidth(page)" :id="`page${page.number}`" - style="margin: 0 auto;" + :style="`margin: ${i === 0 ? 0 : pageMargin}px auto;`" v-intersect="onIntersect" /> @@ -72,6 +72,10 @@ export default Vue.extend({ type: Number, required: true, }, + pageMargin: { + type: Number, + required: true, + }, }, watch: { pages: { diff --git a/komga-webui/src/functions/shortcuts/continuous-reader.ts b/komga-webui/src/functions/shortcuts/continuous-reader.ts index 7f4a1ba6..1fb2a846 100644 --- a/komga-webui/src/functions/shortcuts/continuous-reader.ts +++ b/komga-webui/src/functions/shortcuts/continuous-reader.ts @@ -4,4 +4,7 @@ export const shortcutsSettingsContinuous = [ new Shortcut('bookreader.shortcuts.cycle_side_padding', (ctx: any) => ctx.cycleSidePadding() , 'p'), + new Shortcut('bookreader.shortcuts.cycle_page_margin', + (ctx: any) => ctx.cyclePageMargin() + , 'n'), ] diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index b744e8b7..4da548ca 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -95,6 +95,7 @@ "beginning_of_book": "You're at the beginning of the book.", "changing_reading_direction": "Changing Reading Direction to", "cycling_page_layout": "Cycling Page Layout", + "cycling_page_margin": "Cycling Page Margin", "cycling_scale": "Cycling Scale", "cycling_side_padding": "Cycling Side Padding", "download_current_page": "Download current page", @@ -137,6 +138,7 @@ "general": "General", "gestures": "Gestures", "page_layout": "Page layout", + "page_margin": "Page margin", "paged": "Paginated Reader Options", "reading_mode": "Reading mode", "scale_type": "Scale type", @@ -148,6 +150,7 @@ "close": "Close", "cycle_page_layout": "Cycle page layout", "cycle_scale": "Cycle scale", + "cycle_page_margin": "Cycle page margin", "cycle_side_padding": "Cycle side padding", "first_page": "First page", "fullscreen": "Enter/exit full screen", diff --git a/komga-webui/src/plugins/persisted-state.ts b/komga-webui/src/plugins/persisted-state.ts index d67472b4..d805a53b 100644 --- a/komga-webui/src/plugins/persisted-state.ts +++ b/komga-webui/src/plugins/persisted-state.ts @@ -13,6 +13,7 @@ export const persistedModule: Module = { continuous: { scale: '', padding: '', + margin: '', }, readingDirection: '', swipe: false, @@ -99,6 +100,9 @@ export const persistedModule: Module = { setWebreaderContinuousPadding(state, val) { state.webreader.continuous.padding = val }, + setWebreaderContinuousMargin(state, val) { + state.webreader.continuous.margin = val + }, setWebreaderReadingDirection(state, val) { state.webreader.readingDirection = val }, diff --git a/komga-webui/src/types/enum-reader.ts b/komga-webui/src/types/enum-reader.ts index 7cc07329..60fb625b 100644 --- a/komga-webui/src/types/enum-reader.ts +++ b/komga-webui/src/types/enum-reader.ts @@ -20,3 +20,4 @@ export enum PagedReaderLayout { } export const PaddingPercentage: number[] = [0, 5, 10, 15, 20, 25, 30, 35, 40] +export const MarginValues: number[] = [0, 5, 10, 15] diff --git a/komga-webui/src/views/DivinaReader.vue b/komga-webui/src/views/DivinaReader.vue index 292c7f93..eddb10ff 100644 --- a/komga-webui/src/views/DivinaReader.vue +++ b/komga-webui/src/views/DivinaReader.vue @@ -129,6 +129,7 @@ :animations="animations" :scale="continuousScale" :sidePadding="sidePadding" + :page-margin="pageMargin" @menu="toggleToolbars()" @jump-previous="jumpToPrevious()" @jump-next="jumpToNext()" @@ -221,6 +222,13 @@ :label="$t('bookreader.settings.side_padding')" /> + + +