diff --git a/komga-webui/src/components/readers/PagedReader.vue b/komga-webui/src/components/readers/PagedReader.vue
index 363c4f21..527d1b13 100644
--- a/komga-webui/src/components/readers/PagedReader.vue
+++ b/komga-webui/src/components/readers/PagedReader.vue
@@ -7,37 +7,36 @@
down: () => {if(swipe) {verticalPrev()}}
}"
>
-
-
-
-
-
-
![]()
-
-
-
-
+
+
+
+
+
![]()
+
+
+
+
(),
}
},
props: {
@@ -126,6 +126,7 @@ export default Vue.extend({
pages: {
handler(val) {
this.spreads = buildSpreads(val, this.pageLayout)
+ this.buildPageToSpreadIndexMap()
},
immediate: true,
},
@@ -149,6 +150,7 @@ export default Vue.extend({
handler(val) {
const current = this.page
this.spreads = buildSpreads(this.pages, val)
+ this.buildPageToSpreadIndexMap()
this.carouselPage = this.toSpreadIndex(current)
},
immediate: true,
@@ -161,6 +163,16 @@ export default Vue.extend({
window.removeEventListener('keydown', this.keyPressed)
},
computed: {
+ visibleSpreads(): Array<{ spread: PageDtoWithUrl[], index: number }> {
+ const range = 2
+ const start = Math.max(0, this.carouselPage - range)
+ const end = Math.min(this.spreads.length - 1, this.carouselPage + range)
+ const visible = []
+ for (let i = start; i <= end; i++) {
+ visible.push({ spread: this.spreads[i], index: i })
+ }
+ return visible
+ },
shortcuts(): any {
const shortcuts = []
switch (this.readingDirection) {
@@ -199,6 +211,14 @@ export default Vue.extend({
},
},
methods: {
+ buildPageToSpreadIndexMap() {
+ this.pageToSpreadIndex.clear()
+ for (let i = 0; i < this.spreads.length; i++) {
+ for (let j = 0; j < this.spreads[i].length; j++) {
+ this.pageToSpreadIndex.set(this.spreads[i][j].number, i)
+ }
+ }
+ },
keyPressed(e: KeyboardEvent) {
this.shortcuts[e.key]?.execute(this)
},
@@ -260,12 +280,9 @@ export default Vue.extend({
this.$debug('[toSpreadIndex]', `i:${i}`, `isDoublePages:${this.isDoublePages}`)
if (this.spreads.length > 0) {
if (this.isDoublePages) {
- for (let j = 0; j < this.spreads.length; j++) {
- for (let k = 0; k < this.spreads[j].length; k++) {
- if (this.spreads[j][k].number === i) {
- return j
- }
- }
+ const spreadIndex = this.pageToSpreadIndex.get(i)
+ if (spreadIndex !== undefined) {
+ return spreadIndex
}
} else {
return i - 1