Добавил возможность переключения fullScreen
This commit is contained in:
@@ -90,12 +90,14 @@ export default @Component({
|
|||||||
if (newValue !== '' && newValue !== this.lastOpenedBook.url) {
|
if (newValue !== '' && newValue !== this.lastOpenedBook.url) {
|
||||||
this.loadBook({url: newValue, bookPos: this.routeParamPos});
|
this.loadBook({url: newValue, bookPos: this.routeParamPos});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
class Reader extends Vue {
|
class Reader extends Vue {
|
||||||
loaderActive = false;
|
loaderActive = false;
|
||||||
progressActive = false;
|
progressActive = false;
|
||||||
|
fullScreenActive = false;
|
||||||
|
|
||||||
bookPos = null;
|
bookPos = null;
|
||||||
allowUrlParamBookPos = true;
|
allowUrlParamBookPos = true;
|
||||||
|
|
||||||
@@ -161,10 +163,6 @@ class Reader extends Vue {
|
|||||||
this.updateRoute();
|
this.updateRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
get fullScreenActive() {
|
|
||||||
return this.reader.fullScreenActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
get toolBarActive() {
|
get toolBarActive() {
|
||||||
return this.reader.toolBarActive;
|
return this.reader.toolBarActive;
|
||||||
}
|
}
|
||||||
@@ -178,11 +176,37 @@ class Reader extends Vue {
|
|||||||
this.$root.$emit('resize');
|
this.$root.$emit('resize');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fullScreenToggle(newValue) {
|
||||||
|
this.fullScreenActive = !this.fullScreenActive;
|
||||||
|
if (this.fullScreenActive) {
|
||||||
|
const element = document.documentElement;
|
||||||
|
if (element.requestFullscreen) {
|
||||||
|
element.requestFullscreen();
|
||||||
|
} else if (element.webkitrequestFullscreen) {
|
||||||
|
element.webkitRequestFullscreen();
|
||||||
|
} else if (element.mozRequestFullscreen) {
|
||||||
|
element.mozRequestFullScreen();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (document.cancelFullScreen) {
|
||||||
|
document.cancelFullScreen();
|
||||||
|
} else if (document.mozCancelFullScreen) {
|
||||||
|
document.mozCancelFullScreen();
|
||||||
|
} else if (document.webkitCancelFullScreen) {
|
||||||
|
document.webkitCancelFullScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buttonClick(button) {
|
buttonClick(button) {
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case 'loader': this.loaderActive = !this.loaderActive; break;
|
case 'loader':
|
||||||
case 'fullScreen': this.commit('reader/setFullScreenActive', !this.fullScreenActive); break;
|
this.loaderActive = !this.loaderActive;
|
||||||
case 'refresh':
|
break;
|
||||||
|
case 'fullScreen':
|
||||||
|
this.fullScreenToggle();
|
||||||
|
break;
|
||||||
|
case 'refresh':
|
||||||
if (this.lastOpenedBook) {
|
if (this.lastOpenedBook) {
|
||||||
this.loadBook({url: this.lastOpenedBook.url, force: true});
|
this.loadBook({url: this.lastOpenedBook.url, force: true});
|
||||||
}
|
}
|
||||||
@@ -241,6 +265,11 @@ class Reader extends Vue {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.page)
|
||||||
|
this.$refs.page.fullScreenToggle = this.fullScreenToggle;
|
||||||
|
});
|
||||||
|
|
||||||
this.lastActivePage = result;
|
this.lastActivePage = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,9 +454,10 @@ class TextPage extends Vue {
|
|||||||
if (this.keepLastToFirst)
|
if (this.keepLastToFirst)
|
||||||
i--;
|
i--;
|
||||||
i = (i > lines.length - 1 ? lines.length - 1 : i);
|
i = (i > lines.length - 1 ? lines.length - 1 : i);
|
||||||
|
if (i >= 0) {
|
||||||
this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight,
|
this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight,
|
||||||
lines[i].end, this.parsed.textLength, this.title);
|
lines[i].end, this.parsed.textLength, this.title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,6 +568,7 @@ class TextPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyHook(event) {
|
keyHook(event) {
|
||||||
|
//console.log(event.code);
|
||||||
if (event.type == 'keydown') {
|
if (event.type == 'keydown') {
|
||||||
switch (event.code) {
|
switch (event.code) {
|
||||||
case 'ArrowDown':
|
case 'ArrowDown':
|
||||||
@@ -577,7 +579,6 @@ class TextPage extends Vue {
|
|||||||
break;
|
break;
|
||||||
case 'PageDown':
|
case 'PageDown':
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
case 'Enter':
|
|
||||||
case 'Space':
|
case 'Space':
|
||||||
this.doPageDown();
|
this.doPageDown();
|
||||||
break;
|
break;
|
||||||
@@ -592,6 +593,12 @@ class TextPage extends Vue {
|
|||||||
case 'End':
|
case 'End':
|
||||||
this.doEnd();
|
this.doEnd();
|
||||||
break;
|
break;
|
||||||
|
case 'Enter':
|
||||||
|
case 'Backquote'://`
|
||||||
|
case 'KeyF':
|
||||||
|
if (this.fullScreenToggle)
|
||||||
|
this.fullScreenToggle();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import Vue from 'vue';
|
|||||||
|
|
||||||
// initial state
|
// initial state
|
||||||
const state = {
|
const state = {
|
||||||
fullScreenActive: false,
|
|
||||||
toolBarActive: true,
|
toolBarActive: true,
|
||||||
openedBook: {},
|
openedBook: {},
|
||||||
};
|
};
|
||||||
@@ -28,9 +27,6 @@ const actions = {};
|
|||||||
|
|
||||||
// mutations
|
// mutations
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setFullScreenActive(state, value) {
|
|
||||||
state.fullScreenActive = value;
|
|
||||||
},
|
|
||||||
setToolBarActive(state, value) {
|
setToolBarActive(state, value) {
|
||||||
state.toolBarActive = value;
|
state.toolBarActive = value;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user