From 1365628cf65780987fcaebb026f03b2977a503b9 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 22 Jan 2019 05:02:25 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=81=D1=82=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=86=D0=B5=20=D1=82=D0=B5=D0=BA=D1=81=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index f89e799f..4cc2e97d 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -277,13 +277,13 @@ class TextPage extends Vue { context.fillStyle = this.textColor; const spaceWidth = context.measureText(' ').width; - const lines = this.parsed.getLines(bookPos, this.pageLineCount + 1); + const lines = this.parsed.getLines(bookPos, 2*this.pageLineCount); if (!nextChangeLines) { this.linesDown = lines; - this.linesUp = this.parsed.getLines(bookPos, -(this.pageLineCount + 1)); + this.linesUp = this.parsed.getLines(bookPos, -2*this.pageLineCount); } else { this.linesDownNext = lines; - this.linesUpNext = this.parsed.getLines(bookPos, -(this.pageLineCount + 1)); + this.linesUpNext = this.parsed.getLines(bookPos, -2*this.pageLineCount); } let y = -this.lineInterval/2 + (this.h - this.pageLineCount*this.lineHeight)/2; @@ -403,7 +403,7 @@ class TextPage extends Vue { } doDown() { - if (this.linesDown && this.linesDown.length > 1) { + if (this.linesDown && this.linesDown.length > this.pageLineCount) { this.bookPos = this.linesDown[1].begin; } } @@ -419,11 +419,12 @@ class TextPage extends Vue { let i = this.pageLineCount; if (this.keepLastToFirst) i--; - if (i >= 0 && this.linesDown.length > i) { + if (i >= 0 && this.linesDown.length >= 2*i) { this.currentTransition = this.pageChangeTransition; this.pageChangeDirectionDown = true; this.bookPos = this.linesDown[i].begin; - } + } else + this.doEnd(); } } @@ -447,8 +448,12 @@ class TextPage extends Vue { doEnd() { if (this.parsed.para.length) { - const lastPara = this.parsed.para[this.parsed.para.length - 1]; - this.bookPos = lastPara.offset + lastPara.length - 1; + let i = this.parsed.para.length - 1; + let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1; + const lines = this.parsed.getLines(lastPos, -this.pageLineCount); + i = this.pageLineCount - 1; + i = (i > lines.length - 1 ? lines.length - 1 : i); + this.bookPos = lines[i].begin; } }