Skip to content

Commit

Permalink
chore: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan committed May 24, 2021
1 parent e489c58 commit 7e378c6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lib/viewers/box3d/Box3DViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -326,7 +326,9 @@ class Box3DViewer extends BaseViewer {
* @return {void}
*/
handleShowVrButton() {
this.controls.showVrButton();
if (this.controls && !this.getViewerOption('useReactControls')) {
this.controls.showVrButton();
}
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/lib/viewers/box3d/image360/Image360Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 17 additions & 2 deletions src/lib/viewers/box3d/image360/__tests__/Image360Viewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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()', () => {
Expand Down

0 comments on commit 7e378c6

Please sign in to comment.