From 757ed7878e0573b5a4c9848a674d0d3e2ad459ab Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 23 Jan 2019 18:43:45 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3,=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index d120bd33..20000db3 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -55,6 +55,10 @@ class TextPage extends Vue { this.$emit('book-pos-changed', {bookPos: newValue}); }, 1000); + this.debouncedStartClickRepeat = _.debounce((x, y) => { + this.startClickRepeat(x, y); + }, 800); + this.$root.$on('resize', () => {this.$nextTick(this.onResize)}); } @@ -512,46 +516,25 @@ class TextPage extends Vue { } } - async startClickRepeat(pointX, pointY, debounced) { + async startClickRepeat(pointX, pointY) { this.repX = pointX; this.repY = pointY; - if (!this.repInit) { - this.repInit = true; - - this.repStart = true; - - if (!debounced) - await sleep(800); - - if (this.debouncedRepStart) { - this.debouncedRepStart = false; - this.repInit = false; - await this.startClickRepeat(this.repX, this.repY, true); + if (!this.repDoing) { + this.repDoing = true; + let delay = 400; + while (this.repDoing) { + this.handleClick(pointX, pointY); + await sleep(delay); + if (delay > 15) + delay *= 0.8; } - - if (this.repStart) { - this.repDoing = true; - - let delay = 400; - while (this.repDoing) { - this.handleClick(pointX, pointY); - await sleep(delay); - if (delay > 15) - delay *= 0.8; - } - } - - this.repInit = false; - } else { - this.debouncedRepStart = true; + this.repDoing = false; } } endClickRepeat() { - this.repStart = false; this.repDoing = false; - this.debouncedRepStart = false; } onTouchStart(event) { @@ -561,7 +544,7 @@ class TextPage extends Vue { const x = touch.pageX - this.canvas.offsetLeft; const y = touch.pageY - this.canvas.offsetTop; if (this.handleClick(x, y)) - this.startClickRepeat(x, y); + this.debouncedStartClickRepeat(x, y); } } @@ -575,7 +558,7 @@ class TextPage extends Vue { const x = event.pageX - this.canvas.offsetLeft; const y = event.pageY - this.canvas.offsetTop; if (this.handleClick(x, y)) - this.startClickRepeat(x, y); + this.debouncedStartClickRepeat(x, y); } else if (event.button == 2) { this.doToolBarToggle(); }