From 5c9cfe5e6f3a9cd178b7a7cd742ae1a89690a14d Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 21:15:45 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/ContentsPage/ContentsPage.vue | 19 +++++++++++++------ client/components/Reader/Reader.vue | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index c90cde27..bb0a0bea 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -103,7 +103,8 @@ import * as utils from '../../../share/utils'; const ContentsPageProps = Vue.extend({ props: { - bookPos: Number + bookPos: Number, + isVisible: Boolean, } }); @@ -112,8 +113,8 @@ export default @Component({ Window, }, watch: { - bookPos: function(newValue) { - this.updateBookPosSelection(newValue); + bookPos: function() { + this.updateBookPosSelection(); } }, }) @@ -134,6 +135,7 @@ class ContentsPage extends ContentsPageProps { //проверим, надо ли обновлять списки if (this.parsed == parsed) { + this.updateBookPosSelection(); return; } @@ -231,7 +233,7 @@ class ContentsPage extends ContentsPageProps { this.selectedTab = 'images'; //выделим на bookPos - this.updateBookPosSelection(currentBook.bookPos); + this.updateBookPosSelection(); //асинхронная загрузка изображений this.imageSrc = []; @@ -251,8 +253,13 @@ class ContentsPage extends ContentsPageProps { })(); } - async updateBookPosSelection(bp) { - await utils.sleep(100); + async updateBookPosSelection() { + if (!this.isVisible) + return; + + await utils.sleep(50); + const bp = this.bookPos; + for (let i = 0; i < this.contents.length; i++) { const item = this.contents[i]; const nextOffset = (i < this.contents.length - 1 ? this.contents[i + 1].offset : this.parsed.textLength); diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index ec93ca48..e2142eac 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -99,7 +99,7 @@ - +