uPlot icon indicating copy to clipboard operation
uPlot copied to clipboard

How to synchronize mouse wheel zoom/drag with zoom ranger

Open marc3lsk opened this issue 5 years ago • 1 comments

https://jsfiddle.net/3r5ap0kd/5/ here I combined two demos, https://leeoniya.github.io/uPlot/demos/zoom-ranger.html and https://leeoniya.github.io/uPlot/demos/zoom-wheel.html

Currently, the mouse wheel operations are not synced with zoom ranger. How could synchronization like this be achieved?

marc3lsk avatar Aug 24 '21 12:08 marc3lsk

change the x clamping to use uRanger's min/max:

[nxMin, nxMax] = clamp(nxRange, nxMin, nxMax, uRanger.scales.x.max - uRanger.scales.x.min, uRanger.scales.x.min, uRanger.scales.x.max);

and something like this after u.batch(...):

uRanger.setSelect({
  left: uRanger.valToPos(nxMin, 'x'),
  width: uRanger.valToPos(nxMax, 'x'),
});

https://jsfiddle.net/zsvebgj5/

hopefully you can finish/fix the rest ;)

leeoniya avatar Aug 24 '21 16:08 leeoniya