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.66k stars 659 forks source link

Return previous slider value in Events #1168

Open hardnold opened 2 years ago

hardnold commented 2 years ago

This is more of a feature request rather than an issue.

It would be great if the slider would return also the previous value when an event gets triggered. Then one could check for a value change and only if values have changed, perform an action (like an ajax request) - similar to the state update procedure in react.

Currently one has to store and update the previous value in a global var to check the value in an event handler since the change event gets triggered even if the value hasn't changed.

leongersen commented 2 years ago

It might make sense to not fire change and set if the slider values did not change in an interaction. This already applies on calling the set method. (this would be a breaking change)

hardnold commented 2 years ago

From my perspective it would indeed make sense to always fire set (even if the value didn't change), since the value gets set no matter what the value is. But for the change event it would make sense to only fire it if the value actually has changed.

Dass1010 commented 1 year ago

There are two ways to return preivious value in events. That two way explained clearly in this article. Click here to see