Skip to content

Commit

Permalink
Merge pull request #1497 from cornerstonejs/fix/issue-1464
Browse files Browse the repository at this point in the history
fix(moveNewHandler): Avoid ghost annotations on fast mouse events
  • Loading branch information
igoroctaviano authored Aug 10, 2022
2 parents 9ea015d + c0c1c13 commit 925a3dd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/eventDispatchers/mouseEventHandlers/addNewMeasurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default function(evt, tool) {
? moveHandle
: moveNewHandle;

const timestamp = new Date().getTime();

handleMover(
eventData,
tool.name,
Expand All @@ -44,7 +46,18 @@ export default function(evt, tool) {
return;
}

if (success) {
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;
const eventData = {
toolName: tool.name,
Expand Down

0 comments on commit 925a3dd

Please sign in to comment.