From 055aa5ff20b8a21dd107eecfa21a5d3ce3678e4c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 22 Jan 2019 05:26: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=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B2=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20=D0=B1=D0=B0?= =?UTF-8?q?=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/DrawHelper.js | 4 ++-- .../components/Reader/TextPage/TextPage.vue | 24 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index 0086e278..5242e01d 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -8,9 +8,9 @@ export default class DrawHelper { const fh = h - 2*pad; const fh2 = fh/2; - const t1 = `${Math.floor(bookPos/1000)}k/${Math.floor(textLength/1000)}k`; + const t1 = `${Math.floor((bookPos + 1)/1000)}k/${Math.floor(textLength/1000)}k`; const w1 = context.measureText(t1).width + fh2; - const read = bookPos/textLength; + const read = (bookPos + 1)/textLength; const t2 = `${(read*100).toFixed(2)}%`; const w2 = context.measureText(t2).width; let w3 = w - w1 - w2; diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index 3a5acf0d..77d27e05 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -274,10 +274,6 @@ class TextPage extends Vue { if (!this.book || !this.parsed.textLength) return; - if (this.showStatusBar) - this.drawHelper.drawStatusBar(context, this.statusBarTop, this.statusBarHeight, - this.statusBarColor, bookPos, this.parsed.textLength, this.title); - context.font = this.font; context.fillStyle = this.textColor; const spaceWidth = context.measureText(' ').width; @@ -354,6 +350,23 @@ class TextPage extends Vue { } } } + + this.drawStatusBar(context, lines); + } + + drawStatusBar(context, lines) { + if (!lines) + lines = this.linesDown; + + if (this.showStatusBar) { + let i = this.pageLineCount; + if (this.keepLastToFirst) + i--; + i = (i > lines.length - 1 ? lines.length - 1 : i); + + this.drawHelper.drawStatusBar(context, this.statusBarTop, this.statusBarHeight, + this.statusBarColor, lines[i].end, this.parsed.textLength, this.title); + } } async refreshTime() { @@ -362,8 +375,7 @@ class TextPage extends Vue { await sleep(60*1000); if (this.book && this.parsed.textLength) { - this.drawHelper.drawStatusBar(this.context, this.statusBarTop, this.statusBarHeight, - this.statusBarColor, this.bookPos, this.parsed.textLength, this.title); + this.drawStatusBar(this.context); } this.timeRefreshing = false; this.refreshTime();