diff --git a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js index 53c1a488c..b233b3cd3 100644 --- a/src/tools/annotation/bidirectionalTool/addNewMeasurement.js +++ b/src/tools/annotation/bidirectionalTool/addNewMeasurement.js @@ -22,33 +22,6 @@ export default function(evt, interactionType) { const doneCallback = () => { measurementData.active = false; external.cornerstone.updateImage(element); - - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolName: this.name, - element, - measurementData, - }; - - calculateLongestAndShortestDiameters(eventData, measurementData); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); - }; - - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); }; // Associate this data with this imageId so we can render it and manipulate it @@ -89,6 +62,20 @@ export default function(evt, interactionType) { perpendicularStart.locked = false; external.cornerstone.updateImage(element); + + const modifiedEventData = { + toolType: this.name, + element, + measurementData, + }; + + calculateLongestAndShortestDiameters(eventData, measurementData); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData + ); }, }, interactionType diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js index 1e83fac22..2bed80861 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/moveHandle.js @@ -46,38 +46,13 @@ export default function( measurementData: data, }; + calculateLongestAndShortestDiameters(mouseEventData, data); + external.cornerstone.triggerEvent( element, EVENTS.MEASUREMENT_MODIFIED, modifiedEventData ); - - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolType, - element, - measurementData: data, - }; - - calculateLongestAndShortestDiameters(mouseEventData, data); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); - }; - - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); }; handle.active = true; diff --git a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js index 575184874..3738a5922 100644 --- a/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js +++ b/src/tools/annotation/bidirectionalTool/moveHandle/touchMoveHandle.js @@ -48,31 +48,18 @@ export default function( external.cornerstone.updateImage(element); - const measurementModifiedHandler = () => { - const modifiedEventData = { - toolType, - element, - measurementData: data, - }; - - calculateLongestAndShortestDiameters(mouseEventData, data); - - external.cornerstone.triggerEvent( - element, - EVENTS.MEASUREMENT_MODIFIED, - modifiedEventData - ); - - element.removeEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler - ); + const modifiedEventData = { + toolType, + element, + measurementData: data, }; - // Wait on image render before triggering the modified event - element.addEventListener( - external.cornerstone.EVENTS.IMAGE_RENDERED, - measurementModifiedHandler + calculateLongestAndShortestDiameters(mouseEventData, data); + + external.cornerstone.triggerEvent( + element, + EVENTS.MEASUREMENT_MODIFIED, + modifiedEventData ); };