FXL: ignore linear & default to odd pages right

This matches the behavior of other reading systems. See
https://github.com/johnfactotum/foliate/issues/1318#issuecomment-2349375230
This commit is contained in:
John Factotum
2024-09-14 01:21:54 +08:00
parent 327031aca1
commit b5d0453004
+6 -7
View File
@@ -183,10 +183,9 @@ export class FixedLayout extends HTMLElement {
if (rendition?.spread === 'none') if (rendition?.spread === 'none')
this.#spreads = book.sections.map(section => ({ center: section })) this.#spreads = book.sections.map(section => ({ center: section }))
else this.#spreads = book.sections.reduce((arr, section) => { else this.#spreads = book.sections.reduce((arr, section, i) => {
const last = arr[arr.length - 1] const last = arr[arr.length - 1]
const { linear, pageSpread } = section const { pageSpread } = section
if (linear === 'no') return arr
const newSpread = () => { const newSpread = () => {
const spread = {} const spread = {}
arr.push(spread) arr.push(spread)
@@ -197,21 +196,21 @@ export class FixedLayout extends HTMLElement {
spread.center = section spread.center = section
} }
else if (pageSpread === 'left') { else if (pageSpread === 'left') {
const spread = last.center || last.left || ltr ? newSpread() : last const spread = last.center || last.left || ltr && i ? newSpread() : last
spread.left = section spread.left = section
} }
else if (pageSpread === 'right') { else if (pageSpread === 'right') {
const spread = last.center || last.right || rtl ? newSpread() : last const spread = last.center || last.right || rtl && i ? newSpread() : last
spread.right = section spread.right = section
} }
else if (ltr) { else if (ltr) {
if (last.center || last.right) newSpread().left = section if (last.center || last.right) newSpread().left = section
else if (last.left) last.right = section else if (last.left || !i) last.right = section
else last.left = section else last.left = section
} }
else { else {
if (last.center || last.left) newSpread().right = section if (last.center || last.left) newSpread().right = section
else if (last.right) last.left = section else if (last.right || !i) last.left = section
else last .right = section else last .right = section
} }
return arr return arr