Рефакторинг
This commit is contained in:
@@ -250,7 +250,7 @@ class TextPage extends Vue {
|
|||||||
this.pageChangeTransitionSpeed = 50; //0-100%
|
this.pageChangeTransitionSpeed = 50; //0-100%
|
||||||
|
|
||||||
this.calcDrawProps();
|
this.calcDrawProps();
|
||||||
this.draw(true);// пока не загрузили, очистим канвас
|
this.draw();// пока не загрузили, очистим канвас
|
||||||
|
|
||||||
if (this.lastBook) {
|
if (this.lastBook) {
|
||||||
(async() => {
|
(async() => {
|
||||||
@@ -280,14 +280,14 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
await this.loadFonts();
|
await this.loadFonts();
|
||||||
|
|
||||||
this.draw(true);
|
this.draw();
|
||||||
this.refreshTime();
|
this.refreshTime();
|
||||||
|
|
||||||
// шрифты хрен знает когда подгружаются, поэтому
|
// шрифты хрен знает когда подгружаются, поэтому
|
||||||
let i = 0;
|
let i = 0;
|
||||||
this.parsed.force = true;
|
this.parsed.force = true;
|
||||||
while (i < 10) {
|
while (i < 10) {
|
||||||
this.draw(true);
|
this.draw();
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
onResize() {
|
onResize() {
|
||||||
this.calcDrawProps();
|
this.calcDrawProps();
|
||||||
this.draw(true);
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
get font() {
|
get font() {
|
||||||
@@ -309,7 +309,7 @@ class TextPage extends Vue {
|
|||||||
return `${style.italic ? 'italic' : ''} ${style.bold ? 'bold' : ''} ${this.fontSize}px ${this.fontName}`;
|
return `${style.italic ? 'italic' : ''} ${style.bold ? 'bold' : ''} ${this.fontSize}px ${this.fontName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw(immediate) {
|
draw() {
|
||||||
if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
|
if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
|
||||||
this.doEnd();
|
this.doEnd();
|
||||||
return;
|
return;
|
||||||
@@ -317,39 +317,30 @@ class TextPage extends Vue {
|
|||||||
|
|
||||||
this.toggleLayout = !this.toggleLayout;
|
this.toggleLayout = !this.toggleLayout;
|
||||||
|
|
||||||
if (immediate || (this.parsed && this.parsed.force)) {
|
if (this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
||||||
|
this.linesDown = this.linesDownNext;
|
||||||
|
this.linesUp = this.linesUpNext;
|
||||||
|
} else {
|
||||||
if (this.toggleLayout)
|
if (this.toggleLayout)
|
||||||
this.page1 = this.drawPage(this.bookPos);
|
this.page1 = this.drawPage(this.bookPos);
|
||||||
else
|
else
|
||||||
this.page2 = this.drawPage(this.bookPos);
|
this.page2 = this.drawPage(this.bookPos);
|
||||||
} else {
|
|
||||||
if (this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
|
|
||||||
this.linesDown = this.linesDownNext;
|
|
||||||
this.linesUp = this.linesUpNext;
|
|
||||||
this.pagePrepared = false;
|
|
||||||
this.debouncedPrepareNextPage();
|
|
||||||
} else {
|
|
||||||
if (this.toggleLayout)
|
|
||||||
this.page1 = this.drawPage(this.bookPos);
|
|
||||||
else
|
|
||||||
this.page2 = this.drawPage(this.bookPos);
|
|
||||||
this.pagePrepared = false;
|
|
||||||
this.debouncedPrepareNextPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.currentTransition) {
|
|
||||||
//this.currentTransition
|
|
||||||
//this.pageChangeTransitionSpeed
|
|
||||||
//this.pageChangeDirectionDown
|
|
||||||
|
|
||||||
//curr to next transition
|
|
||||||
//пока заглушка
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentTransition = '';
|
|
||||||
this.pageChangeDirectionDown = false;//true только если PgDown
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.currentTransition) {
|
||||||
|
//this.currentTransition
|
||||||
|
//this.pageChangeTransitionSpeed
|
||||||
|
//this.pageChangeDirectionDown
|
||||||
|
|
||||||
|
//curr to next transition
|
||||||
|
//пока заглушка
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentTransition = '';
|
||||||
|
this.pageChangeDirectionDown = false;//true только если PgDown
|
||||||
|
|
||||||
|
this.pagePrepared = false;
|
||||||
|
this.debouncedPrepareNextPage();
|
||||||
this.debouncedDrawStatusBar();
|
this.debouncedDrawStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user