From e2212ab2d0846ff5c438958bf697234ffd5df53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanc?= Date: Mon, 4 Mar 2024 16:58:35 +0100 Subject: [PATCH] Siplify code to get click coordinates --- plugins/ZoomButtons.jsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/ZoomButtons.jsx b/plugins/ZoomButtons.jsx index 96d8fa769..534e32dea 100644 --- a/plugins/ZoomButtons.jsx +++ b/plugins/ZoomButtons.jsx @@ -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;