From a3f12db6269dc1b77f56138a12b0360cec0b073b Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 19 Jan 2019 01:39:17 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BA=D1=80=D1=83=D1=82=D0=BA=D1=83=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=B7=D0=B0=D0=B6=D0=B0=D1=82=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=BC=D1=8B=D1=88=D0=B8?= =?UTF-8?q?\=D1=82=D0=B0=D1=87=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 64 +++++++++++++++++-- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index 109fb110..cb574775 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -1,7 +1,9 @@ @@ -10,6 +12,7 @@ import Vue from 'vue'; import Component from 'vue-class-component'; import _ from 'lodash'; +import {sleep} from '../../../share/utils'; import bookManager from '../share/bookManager'; @@ -119,6 +122,7 @@ class TextPage extends Vue { this.p = 50;// px, отступ параграфа this.indent = 15;// px, отступ всего текста слева и справа this.wordWrap = true; + this.statusBar = 'none'; //'none', 'top', 'bottom' this.calcDrawProps(); this.drawPage();// пока не загрузили, очистим канвас @@ -327,22 +331,70 @@ class TextPage extends Vue { } } - onTouchStart(event) { - if (event.touches.length == 1) { - const touch = event.touches[0]; - this.handleClick(touch.clientX, touch.clientY) + async startClickRepeat(pointX, pointY) { + if (!this.repInit) { + this.repInit = true; + + this.repStart = true; + + await sleep(1000); + + if (this.debouncedRepStart) { + this.debouncedRepStart = false; + this.repInit = false; + await this.startClickRepeat(pointX, pointY); + } + + if (this.repStart) { + this.repDoing = true; + + let delay = 500; + while (this.repDoing) { + this.handleClick(pointX, pointY); + await sleep(delay); + if (delay > 20) + delay *= 0.7; + } + } + + this.repInit = false; + } else { + this.debouncedRepStart = true; } } + endClickRepeat() { + this.repStart = false; + this.repDoing = false; + } + + onTouchStart(event) { + this.endClickRepeat(); + if (event.touches.length == 1) { + const touch = event.touches[0]; + this.handleClick(touch.clientX, touch.clientY); + this.startClickRepeat(touch.clientX, touch.clientY); + } + } + + onTouchEnd() { + this.endClickRepeat(); + } onMouseDown(event) { + this.endClickRepeat(); if (event.button == 0) { this.handleClick(event.clientX, event.clientY); + this.startClickRepeat(event.clientX, event.clientY); } else if (event.button == 2) { this.doToolBarToggle(); } } + onMouseUp() { + this.endClickRepeat(); + } + onMouseWheel(event) { if (event.deltaY > 0) { this.doDown();