Skip to content

Commit 65dbaaa

Browse files
authored
Only drag zoom on left mouse button (#671)
This makes drag act the same as pan (which is implemented by Hammer.js, which - as far as I can tell - automatically only listens to the left / primary mouse button). By default, right-click is intercepted by the browser to display a context menu, so this isn't noticeable, However, if `oncontextmenu` is used to disable that (e.g., to use JS to display a menu instead), then right-click can trigger zoom, which feels strange.
1 parent 0259d37 commit 65dbaaa

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/handlers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ function zoomStart(chart, event, zoomOptions) {
5252
export function mouseDown(chart, event) {
5353
const state = getState(chart);
5454
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
55-
if (keyPressed(getModifierKey(panOptions), event) || keyNotPressed(getModifierKey(zoomOptions.drag), event)) {
55+
if (
56+
event.button !== 0 ||
57+
keyPressed(getModifierKey(panOptions), event) ||
58+
keyNotPressed(getModifierKey(zoomOptions.drag), event)
59+
) {
5660
return call(zoomOptions.onZoomRejected, [{chart, event}]);
5761
}
5862

0 commit comments

Comments
 (0)