Add Right to Left option to Paged viewing mode

This commit is contained in:
Robbo 2022-01-04 00:20:52 +11:00
parent 8d84a3c502
commit 4b302af2a1
2 changed files with 21 additions and 3 deletions

View File

@ -13,6 +13,7 @@ const readerComponent = () => {
selectedIndex: 0, // 0: not selected; 1: the first page
margin: 30,
preloadLookahead: 3,
enableRightToLeft: false,
/**
* Initialize the component by fetching the page dimensions
@ -64,6 +65,13 @@ const readerComponent = () => {
const savedFlipAnimation = localStorage.getItem('enableFlipAnimation');
this.enableFlipAnimation = savedFlipAnimation === null || savedFlipAnimation === 'true';
const savedRightToLeft = localStorage.getItem('enableRightToLeft');
if (savedRightToLeft === null) {
this.enableRightToLeft = false;
} else {
this.enableRightToLeft = savedRightToLeft;
}
})
.catch(e => {
const errMsg = `Failed to get the page dimensions. ${e}`;
@ -136,7 +144,7 @@ const readerComponent = () => {
this.toPage(newIdx);
if (this.enableFlipAnimation) {
if (isNext)
if (isNext ^ this.enableRightToLeft)
this.flipAnimation = 'right';
else
this.flipAnimation = 'left';
@ -320,5 +328,9 @@ const readerComponent = () => {
enableFlipAnimationChanged() {
localStorage.setItem('enableFlipAnimation', this.enableFlipAnimation);
},
enableRightToLeftChanged() {
localStorage.setItem('enableRightToLeft', this.enableRightToLeft);
},
};
}

View File

@ -55,8 +55,8 @@
object-fit: contain;
`" />
<div style="position:absolute;z-index:1; top:0;left:0; width:30%;height:100%;" @click="flipPage(false)"></div>
<div style="position:absolute;z-index:1; top:0;right:0; width:30%;height:100%;" @click="flipPage(true)"></div>
<div style="position:absolute;z-index:1; top:0;left:0; width:30%;height:100%;" @click="flipPage(false ^ enableRightToLeft)"></div>
<div style="position:absolute;z-index:1; top:0;right:0; width:30%;height:100%;" @click="flipPage(true ^ enableRightToLeft)"></div>
</div>
</div>
@ -114,6 +114,12 @@
</div>
</div>
<div class="uk-margin uk-form-horizontal" x-show="mode !== 'continuous'">
<label class="uk-form-label" for="enable-right-to-left">Right to Left</label>
<div class="uk-form-controls">
<input id="enable-right-to-left" class="uk-checkbox" type="checkbox" x-model="enableRightToLeft" @change="enableRightToLeftChanged()">
</div>
</div>
<hr class="uk-divider-icon">
<div class="uk-margin">