Оптимизация отрисовки страницы
This commit is contained in:
@@ -88,10 +88,21 @@ class TextPage extends Vue {
|
|||||||
this.drawStatusBar();
|
this.drawStatusBar();
|
||||||
}, 60);
|
}, 60);
|
||||||
|
|
||||||
this.debouncedLoadSettings = _.throttle(() => {
|
this.debouncedLoadSettings = _.debounce(() => {
|
||||||
this.loadSettings();
|
this.loadSettings();
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
|
this.debouncedUpdatePage = _.debounce((lines) => {
|
||||||
|
this.toggleLayout = !this.toggleLayout;
|
||||||
|
|
||||||
|
if (this.toggleLayout)
|
||||||
|
this.page1 = this.drawPage(lines);
|
||||||
|
else
|
||||||
|
this.page2 = this.drawPage(lines);
|
||||||
|
|
||||||
|
this.doPageTransition();
|
||||||
|
}, 10);
|
||||||
|
|
||||||
this.$root.$on('resize', () => {this.$nextTick(this.onResize)});
|
this.$root.$on('resize', () => {this.$nextTick(this.onResize)});
|
||||||
this.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
|
this.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
|
||||||
|
|
||||||
@@ -354,21 +365,34 @@ class TextPage extends Vue {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleLayout = !this.toggleLayout;
|
|
||||||
|
|
||||||
if (this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
if (this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
||||||
|
this.toggleLayout = !this.toggleLayout;
|
||||||
this.linesDown = this.linesDownNext;
|
this.linesDown = this.linesDownNext;
|
||||||
this.linesUp = this.linesUpNext;
|
this.linesUp = this.linesUpNext;
|
||||||
|
this.doPageTransition();
|
||||||
} else {
|
} else {
|
||||||
const lines = this.getLines(this.bookPos);
|
const lines = this.getLines(this.bookPos);
|
||||||
this.linesDown = lines.linesDown;
|
this.linesDown = lines.linesDown;
|
||||||
this.linesUp = lines.linesUp;
|
this.linesUp = lines.linesUp;
|
||||||
if (this.toggleLayout)
|
|
||||||
|
/*if (this.toggleLayout)
|
||||||
this.page1 = this.drawPage(lines.linesDown);
|
this.page1 = this.drawPage(lines.linesDown);
|
||||||
else
|
else
|
||||||
this.page2 = this.drawPage(lines.linesDown);
|
this.page2 = this.drawPage(lines.linesDown);*/
|
||||||
|
|
||||||
|
this.debouncedUpdatePage(lines.linesDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pagePrepared = false;
|
||||||
|
this.debouncedPrepareNextPage();
|
||||||
|
this.debouncedDrawStatusBar();
|
||||||
|
|
||||||
|
if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount)
|
||||||
|
this.doEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
doPageTransition() {
|
||||||
if (this.currentTransition) {
|
if (this.currentTransition) {
|
||||||
//this.currentTransition
|
//this.currentTransition
|
||||||
//this.pageChangeTransitionSpeed
|
//this.pageChangeTransitionSpeed
|
||||||
@@ -380,13 +404,6 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
this.currentTransition = '';
|
this.currentTransition = '';
|
||||||
this.pageChangeDirectionDown = false;//true только если PgDown
|
this.pageChangeDirectionDown = false;//true только если PgDown
|
||||||
|
|
||||||
this.pagePrepared = false;
|
|
||||||
this.debouncedPrepareNextPage();
|
|
||||||
this.debouncedDrawStatusBar();
|
|
||||||
|
|
||||||
if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount)
|
|
||||||
this.doEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLines(bookPos) {
|
getLines(bookPos) {
|
||||||
|
|||||||
Reference in New Issue
Block a user