Теоретическое улучшение производительности при листании

This commit is contained in:
Book Pauk
2019-02-05 17:22:31 +07:00
parent 48deee8233
commit a5ac4b726e

View File

@@ -4,12 +4,12 @@
<div v-html="background"></div> <div v-html="background"></div>
<!-- img --> <!-- img -->
</div> </div>
<div v-show="toggleLayout" ref="scrollBox1" class="layout" style="overflow: hidden"> <div ref="scrollBox1" class="layout" style="overflow: hidden">
<div ref="scrollingPage" class="layout" @transitionend="onScrollingTransitionEnd"> <div ref="scrollingPage" class="layout" @transitionend="onScrollingTransitionEnd">
<div v-html="page1"></div> <div v-html="page1"></div>
</div> </div>
</div> </div>
<div v-show="!toggleLayout" ref="scrollBox2" class="layout" style="overflow: hidden"> <div ref="scrollBox2" class="layout" style="overflow: hidden">
<div v-html="page2"></div> <div v-html="page2"></div>
</div> </div>
<div v-show="showStatusBar" ref="statusBar" class="layout"> <div v-show="showStatusBar" ref="statusBar" class="layout">
@@ -50,6 +50,9 @@ export default @Component({
settings: function() { settings: function() {
this.debouncedLoadSettings(); this.debouncedLoadSettings();
}, },
toggleLayout: function() {
this.updateLayout();
},
}, },
}) })
class TextPage extends Vue { class TextPage extends Vue {
@@ -315,6 +318,7 @@ class TextPage extends Vue {
this.$refs.main.focus(); this.$refs.main.focus();
this.toggleLayout = false; this.toggleLayout = false;
this.updateLayout();
this.book = null; this.book = null;
this.meta = null; this.meta = null;
this.fb2 = null; this.fb2 = null;
@@ -371,6 +375,16 @@ class TextPage extends Vue {
} }
} }
updateLayout() {
if (this.toggleLayout) {
this.$refs.scrollBox1.style.visibility = 'visible';
this.$refs.scrollBox2.style.visibility = 'hidden';
} else {
this.$refs.scrollBox1.style.visibility = 'hidden';
this.$refs.scrollBox2.style.visibility = 'visible';
}
}
setBackground() { setBackground() {
this.background = `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` + this.background = `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
` background-color: ${this.backgroundColor}"></div>`; ` background-color: ${this.backgroundColor}"></div>`;