From 2dfa6aec82618425a62f9dc8c65691a1783f17f3 Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Mon, 25 Jul 2022 15:52:35 -0300 Subject: [PATCH 1/3] fix(moveNewHandler): Avoid ghost annotations on fast mouse events --- .../mouseEventHandlers/addNewMeasurement.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js index bec1ee1b8..86f5c82f6 100644 --- a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js +++ b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js @@ -32,6 +32,8 @@ export default function(evt, tool) { ? moveHandle : moveNewHandle; + const timestamp = new Date().getTime(); + handleMover( eventData, tool.name, @@ -44,7 +46,9 @@ export default function(evt, tool) { return; } - if (success) { + const isTooFast = new Date().getTime() - timestamp < 150; + + if (success && isTooFast === false) { const eventType = EVENTS.MEASUREMENT_COMPLETED; const eventData = { toolName: tool.name, From 568c1b261c90dd768250e62904c881803953001a Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Tue, 26 Jul 2022 08:49:29 -0300 Subject: [PATCH 2/3] fix(addNewMeasurement): Use new config property to optionally skip fast events --- src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js index 86f5c82f6..613eb8a8e 100644 --- a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js +++ b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js @@ -46,7 +46,10 @@ export default function(evt, tool) { return; } - const isTooFast = new Date().getTime() - timestamp < 150; + const isTooFast = + tool.configuration && tool.configuration.ignoreFastEvents === true + ? new Date().getTime() - timestamp < 150 + : false; if (success && isTooFast === false) { const eventType = EVENTS.MEASUREMENT_COMPLETED; From c0c1c13b562c338fb054a57e067ece66f603ab95 Mon Sep 17 00:00:00 2001 From: igoroctaviano Date: Tue, 26 Jul 2022 09:00:38 -0300 Subject: [PATCH 3/3] Use configurable threshold value --- .../mouseEventHandlers/addNewMeasurement.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js index 613eb8a8e..674e5bf35 100644 --- a/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js +++ b/src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js @@ -46,10 +46,16 @@ export default function(evt, tool) { return; } - const isTooFast = - tool.configuration && tool.configuration.ignoreFastEvents === true - ? new Date().getTime() - timestamp < 150 - : false; + const hasThreshold = + tool.configuration && + Object(tool.configuration).hasOwnProperty( + 'measurementCreationThreshold' + ); + + const isTooFast = hasThreshold + ? new Date().getTime() - timestamp < + tool.configuration.measurementCreationThreshold + : false; if (success && isTooFast === false) { const eventType = EVENTS.MEASUREMENT_COMPLETED;