plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

pan with mouse wheel pressed + box zoom on left button

Open mzechmeister opened this issue 5 years ago • 4 comments

I would like to have:

  • Panning when the mouse wheel is pressed. This zoom-mode is employed e.g. in AutoCAD.
  • Box zoom on left button
  • (faster) zooming with mouse wheel (#1085)

Currently, all three together do not work simultaneously. One needs to toggle the zoom/pan button, which is cumbersome. So, how can I get this behaviour?

mzechmeister avatar Jul 01 '19 07:07 mzechmeister

A quick hack in plotly.min.js is to force to pan mode on middle button (e.buttons==4). Modify

:o="pan"),St.minDrag="lasso"

to

:o="pan"),4==e.buttons && (o="pan"),St.minDrag="lasso"

If zooming is active, the left button has naturally box zoom.

Yet, one short coming is, that the mouse pointer does not change to the pan look.

mzechmeister avatar Jul 02 '19 22:07 mzechmeister

From the code I also noted that the shift key toggles temporary between pan/zoom. This is currently a built-in way to toggle the behaviour with a keypress (instead of going to the modebar buttons). But it does not work with ctrl, as requested here or implied by the code with e.ctrlKey checks.

mzechmeister avatar Jul 02 '19 23:07 mzechmeister

@mzechmeister did you manage to get pan using middle button working? Shift works (cursor has wrong icon however) but the middle button is more convenient.

Nic30 avatar Nov 28 '21 11:11 Nic30

@mzechmeister did you manage to get pan using middle button working? Shift works (cursor has wrong icon however) but the middle button is more convenient.

Yes, I have got it running. See here for a demo.

The code line with critical hack is here: https://github.com/mzechmeister/csvplotter/blob/88c60c1aaf386dc5b86be09d147eebff4e2c2a7b/zoom_pan.js#L155

mzechmeister avatar Nov 29 '21 13:11 mzechmeister