diff --git a/src/lib/viewers/box3d/Box3DViewer.js b/src/lib/viewers/box3d/Box3DViewer.js index 7aa9039e5..2358b16ae 100644 --- a/src/lib/viewers/box3d/Box3DViewer.js +++ b/src/lib/viewers/box3d/Box3DViewer.js @@ -313,7 +313,7 @@ class Box3DViewer extends BaseViewer { * @return {void} */ handleSceneLoaded() { - if (this.controls) { + if (this.controls && !this.getViewerOption('useReactControls')) { this.controls.addUi(); } this.emit(EVENT_LOAD); @@ -326,7 +326,9 @@ class Box3DViewer extends BaseViewer { * @return {void} */ handleShowVrButton() { - this.controls.showVrButton(); + if (this.controls && !this.getViewerOption('useReactControls')) { + this.controls.showVrButton(); + } } /** diff --git a/src/lib/viewers/box3d/image360/Image360Viewer.js b/src/lib/viewers/box3d/image360/Image360Viewer.js index 010107f65..ff6381917 100644 --- a/src/lib/viewers/box3d/image360/Image360Viewer.js +++ b/src/lib/viewers/box3d/image360/Image360Viewer.js @@ -45,14 +45,20 @@ class Image360Viewer extends Box3DViewer { handleSceneLoaded() { super.handleSceneLoaded(); - this.renderUI(); + if (this.getViewerOption('useReactControls')) { + this.renderUI(); + } } /** * @inheritdoc */ handleShowVrButton() { - if (this.controls && this.getViewerOption('useReactControls')) { + if (!this.controls) { + return; + } + + if (this.getViewerOption('useReactControls')) { this.showVrButton = true; this.renderUI(); } else { diff --git a/src/lib/viewers/box3d/image360/__tests__/Image360Viewer-test.js b/src/lib/viewers/box3d/image360/__tests__/Image360Viewer-test.js index f12bf172a..db011f833 100644 --- a/src/lib/viewers/box3d/image360/__tests__/Image360Viewer-test.js +++ b/src/lib/viewers/box3d/image360/__tests__/Image360Viewer-test.js @@ -2,7 +2,7 @@ import Image360Viewer from '../Image360Viewer'; import BaseViewer from '../../../BaseViewer'; import Box3DControls from '../../Box3DControls'; -import ControlsRoot from '../../../controls/controls-root'; +import ControlsRoot from '../../../controls'; import Image360Renderer from '../Image360Renderer'; import { SELECTOR_BOX_PREVIEW_CONTENT } from '../../../../constants'; @@ -77,11 +77,26 @@ describe('lib/viewers/box3d/image360/Image360Viewer', () => { }); describe('handleSceneLoaded()', () => { - test('should render the react UI', () => { + beforeEach(() => { + jest.spyOn(viewer, 'getViewerOption').mockImplementation(() => true); jest.spyOn(viewer, 'renderUI'); + }); + + test('should render the react UI', () => { viewer.handleSceneLoaded(); expect(viewer.renderUI).toBeCalled(); }); + + describe('Without react controls', () => { + beforeEach(() => { + jest.spyOn(viewer, 'getViewerOption').mockImplementation(() => false); + }); + + test('should render the react UI', () => { + viewer.handleSceneLoaded(); + expect(viewer.renderUI).not.toBeCalled(); + }); + }); }); describe('handleShowVrButton()', () => {