Skip to content

Commit b9b5165

Browse files
committed
Don't trigger the zoom on legends area
Fixes #256
1 parent bfd207d commit b9b5165

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) {
@@ -58,6 +58,12 @@ function zoomStart(chart, event, zoomOptions) {
5858
}
5959

6060
export function mouseDown(chart, event) {
61+
const rect = event.target.getBoundingClientRect();
62+
const offsetX = event.clientX - rect.left;
63+
const offsetY = event.clientY - rect.top;
64+
if (chart.legend && _isPointInArea({x: offsetX, y: offsetY}, chart.legend)) {
65+
return;
66+
}
6167
const state = getState(chart);
6268
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
6369
if (

0 commit comments

Comments
 (0)