Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: limit hotspot height in panorama #149

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion scripts/components/Interactions/HotspotNavButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ export default class HotspotNavButton extends React.Component {
});
}

/**
* React life-cycle handler: Component did update.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henriettemoe Thanks for adopting these comments. I'd agree that they are not required, but the goal is to make it as simple for newcomers as possible.

* @param {object} prevProps Previous props.
*/
componentDidUpdate(prevProps) {
// If changed to panorama, make sure the height does not exceed maximum
if (this.props.isPanorama && !prevProps.isPanorama && this.context.isEditor) {
if (this.state.sizeHeight > HotspotNavButton.MAX_HEIGHT_PANORAMA) {
this.setState({
sizeHeight: HotspotNavButton.MAX_HEIGHT_PANORAMA
});
}
}
}

/**
* Toggle drag state.
*/
Expand Down Expand Up @@ -122,9 +137,12 @@ export default class HotspotNavButton extends React.Component {
this.setState({ sizeHeight: (newSize / staticSceneHeight) * 100 });
}
else {
const isPanorma = this.props.isPanorama;
const newSizePanorama = Math.min(newSize, HotspotNavButton.MAX_HEIGHT_PANORAMA);

isHorizontalDrag ?
this.setState({ sizeWidth: newSize }) :
this.setState({ sizeHeight: newSize });
this.setState({ sizeHeight: isPanorma ? newSizePanorama : newSize });
}

this.props.resizeOnDrag(this.state.sizeWidth, this.state.sizeHeight);
Expand Down Expand Up @@ -254,3 +272,6 @@ HotspotNavButton.SIZE_MIN = 20;

/** @constant {number} SIZE_MAX Maximum size of 3D hotspot */
HotspotNavButton.SIZE_MAX = 2000;

/** @constant {number} MAX_HEIGHT_PANORAMA Maximum hotspot height in Panorama */
HotspotNavButton.MAX_HEIGHT_PANORAMA = 800;
1 change: 1 addition & 0 deletions scripts/components/Interactions/NavigationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ export default class NavigationButton extends React.Component {
setHotspotValues={this.setHotspotValues.bind(this)}
getHotspotValues={this.getHotspotValues.bind(this)}
staticScene={this.props.staticScene}
isPanorama={this.context.extras.isPanorama}
showHotspotOnHover={this.props.showHotspotOnHover}
isHotspotTabbable={this.props.isHotspotTabbable}
/>
Expand Down
Loading