Удаление более ненужного кода

This commit is contained in:
Book Pauk
2022-12-16 19:07:47 +07:00
parent 6b66acb2cf
commit 4efb3031de

View File

@@ -81,9 +81,6 @@ const componentOptions = {
settings: function() { settings: function() {
this.debouncedLoadSettings(); this.debouncedLoadSettings();
}, },
toggleLayout: function() {
this.updateLayout();
},
inAnimation: function() { inAnimation: function() {
this.updateLayout(); this.updateLayout();
}, },
@@ -92,7 +89,6 @@ const componentOptions = {
class TextPage { class TextPage {
_options = componentOptions; _options = componentOptions;
toggleLayout = false;
showStatusBar = false; showStatusBar = false;
clickControl = true; clickControl = true;
@@ -130,10 +126,6 @@ class TextPage {
this.startClickRepeat(x, y); this.startClickRepeat(x, y);
}, 800); }, 800);
this.debouncedPrepareNextPage = _.debounce(() => {
this.prepareNextPage();
}, 100);
this.debouncedDrawStatusBar = _.throttle(() => { this.debouncedDrawStatusBar = _.throttle(() => {
this.drawStatusBar(); this.drawStatusBar();
}, 60); }, 60);
@@ -147,17 +139,11 @@ class TextPage {
}, 50); }, 50);
this.debouncedUpdatePage = _.debounce(async(lines) => { this.debouncedUpdatePage = _.debounce(async(lines) => {
if (!this.pageChangeAnimation) if (this.pageChangeAnimation) {
this.toggleLayout = !this.toggleLayout;
else {
this.page2 = this.page1; this.page2 = this.page1;
this.toggleLayout = true;
} }
if (this.toggleLayout)
this.page1 = this.drawHelper.drawPage(lines); this.page1 = this.drawHelper.drawPage(lines);
else
this.page2 = this.drawHelper.drawPage(lines);
await this.doPageAnimation(); await this.doPageAnimation();
}, 10); }, 10);
@@ -430,7 +416,6 @@ class TextPage {
showBook() { showBook() {
this.$refs.main.focus(); this.$refs.main.focus();
this.toggleLayout = false;
this.updateLayout(); this.updateLayout();
this.book = null; this.book = null;
this.meta = null; this.meta = null;
@@ -488,12 +473,9 @@ class TextPage {
if (this.inAnimation) { if (this.inAnimation) {
this.$refs.scrollBox1.style.visibility = 'visible'; this.$refs.scrollBox1.style.visibility = 'visible';
this.$refs.scrollBox2.style.visibility = 'visible'; this.$refs.scrollBox2.style.visibility = 'visible';
} else if (this.toggleLayout) { } else {
this.$refs.scrollBox1.style.visibility = 'visible'; this.$refs.scrollBox1.style.visibility = 'visible';
this.$refs.scrollBox2.style.visibility = 'hidden'; this.$refs.scrollBox2.style.visibility = 'hidden';
} else {
this.$refs.scrollBox1.style.visibility = 'hidden';
this.$refs.scrollBox2.style.visibility = 'visible';
} }
} }
@@ -594,12 +576,6 @@ class TextPage {
const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling'); const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling');
if (!this.toggleLayout)
this.page1 = this.page2;
this.toggleLayout = true;
await this.$nextTick();
await utils.sleep(50);
this.cachedPos = -1; this.cachedPos = -1;
this.draw(); this.draw();
@@ -683,21 +659,11 @@ class TextPage {
return; return;
} }
//fast draw prepared
if (!this.pageChangeAnimation && this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
this.toggleLayout = !this.toggleLayout;
this.linesDown = this.linesDownNext;
this.linesUp = this.linesUpNext;
} else {//normal debounced draw
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.debouncedUpdatePage(lines.linesDown); this.debouncedUpdatePage(lines.linesDown);
}
this.pagePrepared = false;
if (!this.pageChangeAnimation)
this.debouncedPrepareNextPage();
this.debouncedDrawStatusBar(); this.debouncedDrawStatusBar();
this.debouncedDrawPageDividerAndOrnament(); this.debouncedDrawPageDividerAndOrnament();
@@ -912,30 +878,6 @@ class TextPage {
} }
} }
prepareNextPage() {
// подготовка следующей страницы заранее
if (!this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1)
return;
let i = this.pageLineCount;
if (this.keepLastToFirst)
i--;
if (i >= 0 && this.linesDown.length > i) {
this.bookPosPrepared = this.linesDown[i].begin;
const lines = this.getLines(this.bookPosPrepared);
this.linesDownNext = lines.linesDown;
this.linesUpNext = lines.linesUp;
if (this.toggleLayout)
this.page2 = this.drawHelper.drawPage(lines.linesDown);//наоборот
else
this.page1 = this.drawHelper.drawPage(lines.linesDown);
this.pagePrepared = true;
}
}
doDown() { doDown() {
if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) { if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
this.userBookPosChange = true; this.userBookPosChange = true;