From 76bce31f86956c923af0306350053241770d1676 Mon Sep 17 00:00:00 2001 From: Luis Alberto Martinez Date: Fri, 21 May 2021 12:50:08 -0500 Subject: [PATCH 1/5] Fix - RotateTool for mobile devices --- src/tools/RotateTool.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tools/RotateTool.js b/src/tools/RotateTool.js index 4bf75930c..4fe487ddf 100644 --- a/src/tools/RotateTool.js +++ b/src/tools/RotateTool.js @@ -56,7 +56,15 @@ export default class RotateTool extends BaseTool { function defaultStrategy(evt) { const { roundAngles, rotateScale } = this.configuration; const { element, viewport, startPoints, currentPoints } = evt.detail; - const initialRotation = viewport.initialRotation; + + let prevInitialRotation; + + if (viewport.initialRotation) { + prevInitialRotation = viewport.initialRotation; + } else { + prevInitialRotation = viewport.rotation; + } + const initialRotation = prevInitialRotation; // Calculate the center of the image const rect = element.getBoundingClientRect(element); From 45b9ce87f3d86c1fd759057233b1266385de2c4a Mon Sep 17 00:00:00 2001 From: Luis Alberto Martinez Date: Fri, 21 May 2021 13:12:14 -0500 Subject: [PATCH 2/5] Refactor fix RotateTool --- src/tools/RotateTool.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/tools/RotateTool.js b/src/tools/RotateTool.js index 4fe487ddf..e837b2f6f 100644 --- a/src/tools/RotateTool.js +++ b/src/tools/RotateTool.js @@ -57,14 +57,9 @@ function defaultStrategy(evt) { const { roundAngles, rotateScale } = this.configuration; const { element, viewport, startPoints, currentPoints } = evt.detail; - let prevInitialRotation; - - if (viewport.initialRotation) { - prevInitialRotation = viewport.initialRotation; - } else { - prevInitialRotation = viewport.rotation; - } - const initialRotation = prevInitialRotation; + const initialRotation = viewport.initialRotation + ? viewport.initialRotation + : viewport.rotation; // Calculate the center of the image const rect = element.getBoundingClientRect(element); From 65e0f14332f8c0a87cc036d19912845bb755f5d3 Mon Sep 17 00:00:00 2001 From: Luis Alberto Martinez Date: Fri, 21 May 2021 13:35:48 -0500 Subject: [PATCH 3/5] Feature - testUnit for RotateTool on mobile devices --- src/tools/RotateTool.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tools/RotateTool.test.js b/src/tools/RotateTool.test.js index 06c110a97..92ee31500 100644 --- a/src/tools/RotateTool.test.js +++ b/src/tools/RotateTool.test.js @@ -13,6 +13,15 @@ const mockEvt = { }, }; +const forMobileMockEvt = { + detail: { + viewport: { + rotation: 50, + initialRotation: undefined, + }, + }, +}; + describe('RotateTool.js', () => { describe('default values', () => { it('has a default name of "Rotate"', () => { @@ -48,5 +57,15 @@ describe('RotateTool.js', () => { instantiatedTool.dragCallback(mockEvt); expect(external.cornerstone.setViewport).toHaveBeenCalled(); }); + + it('can be created on mobile device', () => { + const instantiatedTool = new RotateTool(); + + instantiatedTool.applyActiveStrategy = jest.fn(); + external.cornerstone.setViewport = jest.fn(); + + instantiatedTool.dragCallback(forMobileMockEvt); + expect(external.cornerstone.setViewport).toHaveBeenCalled(); + }); }); }); From db7680e6cf27efd083c2e6ba0add171c824811ae Mon Sep 17 00:00:00 2001 From: Luis Alberto Martinez Date: Mon, 24 May 2021 10:24:06 -0500 Subject: [PATCH 4/5] Refactor validation on RotateTool --- src/tools/RotateTool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/RotateTool.js b/src/tools/RotateTool.js index e837b2f6f..fd64b8ec8 100644 --- a/src/tools/RotateTool.js +++ b/src/tools/RotateTool.js @@ -57,9 +57,10 @@ function defaultStrategy(evt) { const { roundAngles, rotateScale } = this.configuration; const { element, viewport, startPoints, currentPoints } = evt.detail; - const initialRotation = viewport.initialRotation - ? viewport.initialRotation - : viewport.rotation; + const initialRotation = + viewport.initialRotation === undefined + ? viewport.rotation + : viewport.initialRotation; // Calculate the center of the image const rect = element.getBoundingClientRect(element); From ac7f9e12d96f9b5a10d3d1a86cacf17f9496dfa4 Mon Sep 17 00:00:00 2001 From: Luis Alberto Martinez Date: Mon, 24 May 2021 10:55:53 -0500 Subject: [PATCH 5/5] Change validation structure --- src/tools/RotateTool.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tools/RotateTool.js b/src/tools/RotateTool.js index fd64b8ec8..e837b2f6f 100644 --- a/src/tools/RotateTool.js +++ b/src/tools/RotateTool.js @@ -57,10 +57,9 @@ function defaultStrategy(evt) { const { roundAngles, rotateScale } = this.configuration; const { element, viewport, startPoints, currentPoints } = evt.detail; - const initialRotation = - viewport.initialRotation === undefined - ? viewport.rotation - : viewport.initialRotation; + const initialRotation = viewport.initialRotation + ? viewport.initialRotation + : viewport.rotation; // Calculate the center of the image const rect = element.getBoundingClientRect(element);