feat(book reader): vertical reading mode

move background-color to top container to avoid display glitch
This commit is contained in:
Gauthier Roebroeck 2020-03-18 15:14:00 +08:00
parent 8b1b7c1a99
commit ca03111b0b

View file

@ -1,9 +1,12 @@
<template> <template>
<v-container class="ma-0 pa-0 full-height" fluid v-if="pages.length > 0" style="width: 100%;" <v-container class="ma-0 pa-0 full-height" fluid v-if="pages.length > 0"
:style="`width: 100%; background-color: ${backgroundColor}`"
v-touch="{ v-touch="{
left: () => turnRight(), left: () => turnRight(),
right: () => turnLeft(), right: () => turnLeft(),
}" up: () => verticalNext(),
down: () => verticalPrev()
}"
> >
<div> <div>
<v-slide-y-transition> <v-slide-y-transition>
@ -122,6 +125,7 @@
:show-arrows="false" :show-arrows="false"
:continuous="false" :continuous="false"
:reverse="flipDirection" :reverse="flipDirection"
:vertical="vertical"
hide-delimiters hide-delimiters
touchless touchless
height="100%" height="100%"
@ -134,9 +138,7 @@
:transition="animations ? undefined : false" :transition="animations ? undefined : false"
:reverse-transition="animations ? undefined : false" :reverse-transition="animations ? undefined : false"
> >
<div class="full-height d-flex flex-column justify-center" <div class="full-height d-flex flex-column justify-center">
:style="`background-color: ${backgroundColor}`"
>
<div :class="`d-flex flex-row${flipDirection ? '-reverse' : ''} justify-center px-0 mx-0` "> <div :class="`d-flex flex-row${flipDirection ? '-reverse' : ''} justify-center px-0 mx-0` ">
<img :src="getPageUrl(p)" <img :src="getPageUrl(p)"
:height="maxHeight" :height="maxHeight"
@ -317,7 +319,8 @@ export default Vue.extend({
}, },
readingDirs: [ readingDirs: [
{ text: 'Left to right', value: ReadingDirection.LEFT_TO_RIGHT }, { text: 'Left to right', value: ReadingDirection.LEFT_TO_RIGHT },
{ text: 'Right to left', value: ReadingDirection.RIGHT_TO_LEFT } { text: 'Right to left', value: ReadingDirection.RIGHT_TO_LEFT },
{ text: 'Vertical', value: ReadingDirection.VERTICAL }
], ],
imageFits: [ imageFits: [
{ text: 'Fit to height', value: ImageFit.HEIGHT }, { text: 'Fit to height', value: ImageFit.HEIGHT },
@ -450,6 +453,9 @@ export default Vue.extend({
flipDirection (): boolean { flipDirection (): boolean {
return this.readingDirection === ReadingDirection.RIGHT_TO_LEFT return this.readingDirection === ReadingDirection.RIGHT_TO_LEFT
}, },
vertical (): boolean {
return this.readingDirection === ReadingDirection.VERTICAL
},
imageFit: { imageFit: {
get: function (): ImageFit { get: function (): ImageFit {
return this.settings.fit return this.settings.fit
@ -491,6 +497,12 @@ export default Vue.extend({
case 'ArrowLeft': case 'ArrowLeft':
this.flipDirection ? this.next() : this.prev() this.flipDirection ? this.next() : this.prev()
break break
case 'ArrowDown':
if (this.vertical) this.next()
break
case 'ArrowUp':
if (this.vertical) this.prev()
break
case 'Home': case 'Home':
this.goToFirst() this.goToFirst()
break break
@ -532,9 +544,11 @@ export default Vue.extend({
this.goToFirst() this.goToFirst()
} }
// set non-persistent reading direction if exists in metadata
switch (this.book.metadata.readingDirection) { switch (this.book.metadata.readingDirection) {
case ReadingDirection.LEFT_TO_RIGHT: case ReadingDirection.LEFT_TO_RIGHT:
case ReadingDirection.RIGHT_TO_LEFT: case ReadingDirection.RIGHT_TO_LEFT:
case ReadingDirection.VERTICAL:
// bypass setter so cookies aren't set // bypass setter so cookies aren't set
this.settings.readingDirection = this.book.metadata.readingDirection this.settings.readingDirection = this.book.metadata.readingDirection
this.snackReadingDirection = true this.snackReadingDirection = true
@ -560,11 +574,19 @@ export default Vue.extend({
} }
}, },
turnRight () { turnRight () {
if (this.vertical) return
return this.flipDirection ? this.prev() : this.next() return this.flipDirection ? this.prev() : this.next()
}, },
turnLeft () { turnLeft () {
if (this.vertical) return
return this.flipDirection ? this.next() : this.prev() return this.flipDirection ? this.next() : this.prev()
}, },
verticalPrev () {
if (this.vertical) this.prev()
},
verticalNext () {
if (this.vertical) this.next()
},
prev () { prev () {
if (this.canPrev) { if (this.canPrev) {
this.carouselPage-- this.carouselPage--