Skip to content

Commit 4c794cb

Browse files
ikkalakurkle
andauthored
Don't trigger the zoom on legends area (#772)
* 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]>
1 parent 7704540 commit 4c794cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/handlers.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {directionEnabled, debounce, keyNotPressed, getModifierKey, keyPressed} from './utils';
22
import {zoom, zoomRect} from './core';
3-
import {callback as call, getRelativePosition} from 'chart.js/helpers';
3+
import {callback as call, getRelativePosition, _isPointInArea} from 'chart.js/helpers';
44
import {getState} from './state';
55

66
function removeHandler(chart, type) {
@@ -61,6 +61,12 @@ function zoomStart(chart, event, zoomOptions) {
6161
}
6262

6363
export function mouseDown(chart, event) {
64+
if (chart.legend) {
65+
const point = getRelativePosition(event, chart);
66+
if (_isPointInArea(point, chart.legend)) {
67+
return;
68+
}
69+
}
6470
const state = getState(chart);
6571
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
6672
if (

0 commit comments

Comments
 (0)