project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
252 stars 58 forks source link

Candle flickering when scrolling with touchpad #14

Open C451 opened 2 years ago

C451 commented 2 years ago

The problem occurs only when using touchpad. The main reason: Math.floor() operation that applied to each candle. Resulting in this weird behavior (we should keep it coz it makes candles "crispy"):

https://user-images.githubusercontent.com/48596328/201541112-d598ead7-7ba6-4522-99dd-6e4a73f58f6e.mov

You may ask then, why it works ok when dagging with mouse? That's because the calculation is more precise, taking in the account the first candle position: https://github.com/project-nv/night-vision/blob/main/src/core/input/pointer.js#L332

But in the case of touchpad it just adds delta to each edge of the range: https://github.com/project-nv/night-vision/blob/main/src/core/input/pointer.js#L388

So the question is: how to correct the candle positions so they align as in the case with mouse.