Implement a controller to toggle flip animation

This commit is contained in:
Leeingnyo
2021-08-18 23:38:29 +09:00
parent 1e7d6ba5b1
commit 83b122ab75
2 changed files with 22 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ const readerComponent = () => {
alertClass: 'uk-alert-primary',
items: [],
curItem: {},
enableFlipAnimation: true,
flipAnimation: null,
longPages: false,
lastSavedPage: page,
@@ -60,6 +61,9 @@ const readerComponent = () => {
for (let idx = page + 1; idx <= limit; idx++) {
this.preloadImage(this.items[idx - 1].url);
}
const savedFlipAnimation = localStorage.getItem('enableFlipAnimation');
this.enableFlipAnimation = savedFlipAnimation === null || savedFlipAnimation === 'true';
})
.catch(e => {
const errMsg = `Failed to get the page dimensions. ${e}`;
@@ -131,10 +135,12 @@ const readerComponent = () => {
this.toPage(newIdx);
if (isNext)
this.flipAnimation = 'right';
else
this.flipAnimation = 'left';
if (this.enableFlipAnimation) {
if (isNext)
this.flipAnimation = 'right';
else
this.flipAnimation = 'left';
}
setTimeout(() => {
this.flipAnimation = null;
@@ -309,6 +315,10 @@ const readerComponent = () => {
preloadLookaheadChanged() {
localStorage.setItem('preloadLookahead', this.preloadLookahead);
}
},
enableFlipAnimationChanged() {
localStorage.setItem('enableFlipAnimation', this.enableFlipAnimation);
},
};
}