From e1cd506986ef410b12d7de9381b9ac5ec40ef27e Mon Sep 17 00:00:00 2001 From: Tuukka Ikkala <10980802+ikkala@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:21:59 +0200 Subject: [PATCH] Make cleaner, suggested by @kurkle Co-authored-by: Jukka Kurkela --- src/handlers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handlers.js b/src/handlers.js index 5d699f5c..224f72eb 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -58,12 +58,12 @@ function zoomStart(chart, event, zoomOptions) { } export function mouseDown(chart, event) { - const rect = event.target.getBoundingClientRect(); - const offsetX = event.clientX - rect.left; - const offsetY = event.clientY - rect.top; - if (chart.legend && _isPointInArea({x: offsetX, y: offsetY}, chart.legend)) { + if (chart.legend) { + const point = getRelativePosition(event, chart); + if (_isPointInArea(point, chart.legend)) { return; - } + } + } const state = getState(chart); const {pan: panOptions, zoom: zoomOptions = {}} = state.options; if (