Оптимизация (прекеширование) при скроллинге
This commit is contained in:
@@ -434,6 +434,7 @@ class TextPage extends Vue {
|
|||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
await sleep(50);
|
await sleep(50);
|
||||||
|
|
||||||
|
this.cachedPos = -1;
|
||||||
const page = this.$refs.scrollingPage;
|
const page = this.$refs.scrollingPage;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (!this.stopScrolling) {
|
while (!this.stopScrolling) {
|
||||||
@@ -470,10 +471,29 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
if (this.doingScrolling) {
|
if (this.doingScrolling) {
|
||||||
|
if (this.cachedPos == this.bookPos) {
|
||||||
|
this.linesDown = this.linesCached.linesDown;
|
||||||
|
this.linesUp = this.linesCached.linesUp;
|
||||||
|
this.page1 = this.pageCached;
|
||||||
|
} 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;
|
||||||
this.page1 = this.drawPage(lines.linesDown);
|
this.page1 = this.drawPage(lines.linesDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
//caching next
|
||||||
|
if (this.cachedPageTimer)
|
||||||
|
clearTimeout(this.cachedPageTimer);
|
||||||
|
this.cachedPageTimer = setTimeout(() => {
|
||||||
|
if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
|
||||||
|
this.cachedPos = this.linesDown[1].begin;
|
||||||
|
this.linesCached = this.getLines(this.cachedPos);
|
||||||
|
this.pageCached = this.drawPage(this.linesCached.linesDown);
|
||||||
|
}
|
||||||
|
this.cachedPageTimer = null;
|
||||||
|
}, 20);
|
||||||
|
|
||||||
this.debouncedDrawStatusBar();
|
this.debouncedDrawStatusBar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user