diff --git a/src/tools/RotateTool.js b/src/tools/RotateTool.js index 4bf75930c..e837b2f6f 100644 --- a/src/tools/RotateTool.js +++ b/src/tools/RotateTool.js @@ -56,7 +56,10 @@ 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; + + const initialRotation = viewport.initialRotation + ? viewport.initialRotation + : viewport.rotation; // Calculate the center of the image const rect = element.getBoundingClientRect(element); 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(); + }); }); });