leongersen / noUiSlider

noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. It is fully GPU animated: no reflows, so it is fast; even on older devices. It also fits wonderfully in responsive designs and has no dependencies.
https://refreshless.com/nouislider/
MIT License
5.67k stars 660 forks source link

Cannot slide while updating the data #1117

Closed mdhsl closed 3 years ago

mdhsl commented 3 years ago

First of all, Hi everyone and thank you for the great work done on this lib!

I have a problem trying to slide while updating the data.

If you have a loop continuously updating the data to move the handle using the "set" method, and you try to move the slider at the same time, it doesn't work every time. In fact, after investigation, the click on the handle is not always captured because the update execution is running.

Here is an example showing the problem: http://opensensorhub.github.io/osh-js/dev/showcase/range-slider.html

The code of my component: https://github.com/opensensorhub/osh-js/blob/dev/source/osh-ext/ui/view/rangeslider/RangeSliderView.js#L199

mdhsl commented 3 years ago

I have found a work around but I don't know if it doesn't cause any other problems.

My problem comes from this line: https://gist.github.com/mdhsl/01aee2a6ddf5a208e9706c6b5a8fe91e#file-nouislider-js-L1594

The event is not propagated any more because we enter this condition.

My work around is to use the doNotReject value on the 'mousedown' type by forcing it to true:

https://gist.github.com/mdhsl/01aee2a6ddf5a208e9706c6b5a8fe91e#file-nouislider-js-L2041

Can it cause edge effects?

leongersen commented 3 years ago

If the condition you've linked causes your issue, I think the fix you have applied probably won't have side effects, other than unexpected reactions when setting the slider value just after the user has tapped the slider to change it. You can also disable animation, which probably would also resolve your issue.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.