From c3596d980cb9b531291e0c838ee867975fa27338 Mon Sep 17 00:00:00 2001 From: "smcyr@hotmail.comsmcyr@hotsmcyr@hotmail.commail.com" Date: Thu, 4 Jun 2020 14:17:32 -0400 Subject: [PATCH 1/4] timeout for two fingers overlay to prevent showing automatically when moving with 1 finger --- src/services/EventsHandler.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/services/EventsHandler.js b/src/services/EventsHandler.js index 2e5727503..10e77b0cb 100644 --- a/src/services/EventsHandler.js +++ b/src/services/EventsHandler.js @@ -54,6 +54,7 @@ export class EventsHandler extends AbstractService { dblclickData : null, dblclickTimeout : null, longtouchTimeout: null, + twofingersTimeout: null, }; /** @@ -330,6 +331,9 @@ export class EventsHandler extends AbstractService { } if (this.config.touchmoveTwoFingers) { + if (this.twofingersTimeout) { + clearTimeout(this.twofingersTimeout); + } this.psv.overlay.hide(IDS.TWO_FINGERS); } } @@ -346,11 +350,13 @@ export class EventsHandler extends AbstractService { if (evt.touches.length === 1) { if (this.config.touchmoveTwoFingers) { - this.psv.overlay.show({ - id : IDS.TWO_FINGERS, - image: gestureIcon, - text : this.config.lang.twoFingers[0], - }); + this.twofingersTimeout = setTimeout(() => { + this.psv.overlay.show({ + id : IDS.TWO_FINGERS, + image: gestureIcon, + text : this.config.lang.twoFingers[0], + }); + }, 200); } else { evt.preventDefault(); @@ -360,6 +366,9 @@ export class EventsHandler extends AbstractService { else if (evt.touches.length === 2) { evt.preventDefault(); this.__moveZoom(evt); + if (this.twofingersTimeout) { + clearTimeout(this.twofingersTimeout); + } } } From 3a6ef7c512853105dbce8e6f2d0211429e4ff24e Mon Sep 17 00:00:00 2001 From: "smcyr@hotmail.comsmcyr@hotsmcyr@hotmail.commail.com" Date: Thu, 4 Jun 2020 14:49:39 -0400 Subject: [PATCH 2/4] fixes to two fingers overlay --- src/data/constants.js | 8 ++++++++ src/services/EventsHandler.js | 27 +++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/data/constants.js b/src/data/constants.js index 02aeee4b2..c43abf141 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -26,6 +26,14 @@ export const DBLCLICK_DELAY = 300; */ export const LONGTOUCH_DELAY = 500; +/** + * @summary Delay in milliseconds to for the two fingers overlay to appear + * @memberOf PSV.constants + * @type {number} + * @constant + */ +export const TWOFINGERSOVERLAY_DELAY = 200; + /** * @summary Time size of the mouse position history used to compute inertia * @memberOf PSV.constants diff --git a/src/services/EventsHandler.js b/src/services/EventsHandler.js index 10e77b0cb..a8dbbf87a 100644 --- a/src/services/EventsHandler.js +++ b/src/services/EventsHandler.js @@ -6,6 +6,7 @@ import { IDS, INERTIA_WINDOW, LONGTOUCH_DELAY, + TWOFINGERSOVERLAY_DELAY, MOVE_THRESHOLD } from '../data/constants'; import { SYSTEM } from '../data/system'; @@ -109,6 +110,7 @@ export class EventsHandler extends AbstractService { clearTimeout(this.state.dblclickTimeout); clearTimeout(this.state.longtouchTimeout); + clearTimeout(this.state.twofingersTimeout); delete this.state; @@ -331,9 +333,7 @@ export class EventsHandler extends AbstractService { } if (this.config.touchmoveTwoFingers) { - if (this.twofingersTimeout) { - clearTimeout(this.twofingersTimeout); - } + this.__cancelTwoFingersOverlay(); this.psv.overlay.hide(IDS.TWO_FINGERS); } } @@ -349,14 +349,14 @@ export class EventsHandler extends AbstractService { } if (evt.touches.length === 1) { - if (this.config.touchmoveTwoFingers) { - this.twofingersTimeout = setTimeout(() => { + if (this.config.touchmoveTwoFingers && !this.prop.twofingersTimeout) { + this.prop.twofingersTimeout = setTimeout(() => { this.psv.overlay.show({ - id : IDS.TWO_FINGERS, + id: IDS.TWO_FINGERS, image: gestureIcon, - text : this.config.lang.twoFingers[0], + text: this.config.lang.twoFingers[0], }); - }, 200); + }, TWOFINGERSOVERLAY_DELAY); } else { evt.preventDefault(); @@ -366,8 +366,8 @@ export class EventsHandler extends AbstractService { else if (evt.touches.length === 2) { evt.preventDefault(); this.__moveZoom(evt); - if (this.twofingersTimeout) { - clearTimeout(this.twofingersTimeout); + if (this.config.touchmoveTwoFingers) { + this.__cancelTwoFingersOverlay(); } } } @@ -383,6 +383,13 @@ export class EventsHandler extends AbstractService { } } + __cancelTwoFingersOverlay() { + if (this.prop.twofingersTimeout) { + clearTimeout(this.prop.twofingersTimeout); + this.prop.twofingersTimeout = null; + } + } + /** * @summary Handles mouse wheel events * @param {MouseWheelEvent} evt From 38050493f265a0ab6be170c08e469d3b00db5f91 Mon Sep 17 00:00:00 2001 From: "smcyr@hotmail.comsmcyr@hotsmcyr@hotmail.commail.com" Date: Thu, 4 Jun 2020 14:55:03 -0400 Subject: [PATCH 3/4] small fix --- src/data/constants.js | 2 +- src/services/EventsHandler.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/data/constants.js b/src/data/constants.js index c43abf141..6c97b59ba 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -32,7 +32,7 @@ export const LONGTOUCH_DELAY = 500; * @type {number} * @constant */ -export const TWOFINGERSOVERLAY_DELAY = 200; +export const TWOFINGERSOVERLAY_DELAY = 100; /** * @summary Time size of the mouse position history used to compute inertia diff --git a/src/services/EventsHandler.js b/src/services/EventsHandler.js index a8dbbf87a..672809797 100644 --- a/src/services/EventsHandler.js +++ b/src/services/EventsHandler.js @@ -349,14 +349,16 @@ export class EventsHandler extends AbstractService { } if (evt.touches.length === 1) { - if (this.config.touchmoveTwoFingers && !this.prop.twofingersTimeout) { - this.prop.twofingersTimeout = setTimeout(() => { - this.psv.overlay.show({ - id: IDS.TWO_FINGERS, - image: gestureIcon, - text: this.config.lang.twoFingers[0], - }); - }, TWOFINGERSOVERLAY_DELAY); + if (this.config.touchmoveTwoFingers) { + if (!this.prop.twofingersTimeout) { + this.prop.twofingersTimeout = setTimeout(() => { + this.psv.overlay.show({ + id: IDS.TWO_FINGERS, + image: gestureIcon, + text: this.config.lang.twoFingers[0], + }); + }, TWOFINGERSOVERLAY_DELAY); + } } else { evt.preventDefault(); From fc4c6f40a22bcf13053f8e1a6ca95ebe38c85784 Mon Sep 17 00:00:00 2001 From: "smcyr@hotmail.comsmcyr@hotsmcyr@hotmail.commail.com" Date: Thu, 4 Jun 2020 15:04:48 -0400 Subject: [PATCH 4/4] method comment --- src/services/EventsHandler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/services/EventsHandler.js b/src/services/EventsHandler.js index 672809797..02d7007b6 100644 --- a/src/services/EventsHandler.js +++ b/src/services/EventsHandler.js @@ -385,6 +385,10 @@ export class EventsHandler extends AbstractService { } } + /** + * @summary Cancel the two fingers overlay timer if any + * @private + */ __cancelTwoFingersOverlay() { if (this.prop.twofingersTimeout) { clearTimeout(this.prop.twofingersTimeout);