From a170df2b370e31043193359be0f40d48e4b3b512 Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Mon, 21 Nov 2016 14:33:49 -0200 Subject: [PATCH] LT-40: Fixing issues with text box on top left position --- Packages/ohif-core/client/lib/cornerstone.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Packages/ohif-core/client/lib/cornerstone.js b/Packages/ohif-core/client/lib/cornerstone.js index 1ce58a4aa..5b7e83262 100644 --- a/Packages/ohif-core/client/lib/cornerstone.js +++ b/Packages/ohif-core/client/lib/cornerstone.js @@ -38,6 +38,10 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) = const handles = measurementData.handles; const textBox = handles.textBox; + const bounds = {}; + bounds.x = textBox.boundingBox.width; + bounds.y = textBox.boundingBox.height; + const getHandlePosition = key => _.pick(handles[key], ['x', 'y']); const start = getHandlePosition('start'); const end = getHandlePosition('end'); @@ -74,6 +78,13 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) = textBox[cornerAxis] = points[cornerAxis]; textBox[toolAxis] = tool[toolAxis]; + + if (directions[cornerAxis] < 0) { + const topLeft = cornerstone.pageToPixel(element, 0, 0); + const bottomRight = cornerstone.pageToPixel(element, bounds.x, bounds.y); + const boxSize = bottomRight[cornerAxis] - topLeft[cornerAxis]; + textBox[cornerAxis] -= boxSize; + } }; const mouseUpCallback = () => {