Skip to content

Commit

Permalink
Don't trigger the zoom on legends area (#772)
Browse files Browse the repository at this point in the history
* Don't trigger the zoom on legends area

Fixes #256

* Make cleaner, suggested by @kurkle

Co-authored-by: Jukka Kurkela <[email protected]>

* fix: lint

---------

Co-authored-by: Jukka Kurkela <[email protected]>
  • Loading branch information
ikkala and kurkle authored Nov 16, 2024
1 parent 7704540 commit 4c794cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/handlers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {directionEnabled, debounce, keyNotPressed, getModifierKey, keyPressed} from './utils';
import {zoom, zoomRect} from './core';
import {callback as call, getRelativePosition} from 'chart.js/helpers';
import {callback as call, getRelativePosition, _isPointInArea} from 'chart.js/helpers';
import {getState} from './state';

function removeHandler(chart, type) {
Expand Down Expand Up @@ -61,6 +61,12 @@ function zoomStart(chart, event, zoomOptions) {
}

export function mouseDown(chart, event) {
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 (
Expand Down

0 comments on commit 4c794cb

Please sign in to comment.