Skip to content

Commit

Permalink
Siplify code to get click coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitblanc committed Mar 4, 2024
1 parent 5e97b24 commit e2212ab
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions plugins/ZoomButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,14 @@ class ZoomButton extends React.Component {
if (this.props.currentTask !== null && this.props.currentTask === this.state.task && this.state.disabled) {
this.props.setCurrentTask(null);
}
if (this.props.currentTask === this.state.task && prevProps !== this.props) {
const point = this.clickPoint(prevProps);
if (this.props.currentTask === this.state.task && prevProps !== this.props && this.props.click !== prevProps.click) {
const point = this.props.click.coordinate;
if (point) {
const zoom = Math.max(0, this.props.currentZoom + this.props.direction);
this.props.zoomToPoint(point, zoom, this.mapCrs);
}
}
}
clickPoint = (prevProps) => {
if (this.props.click === prevProps.click) {
return null;
}
return this.props.click.coordinate;
};
render() {
if (!ThemeUtils.themFlagsAllowed(this.props.theme, this.props.themeFlagWhitelist, this.props.themeFlagBlacklist)) {
return null;
Expand Down

0 comments on commit e2212ab

Please sign in to comment.