Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
min = max #676
We use your lib to show filter sliders in a ecommerce setup to filter products by price, width, height, weight, etc. Sometimes it occurs that a user filters so many attributes that there are only a few products left which have the same value for a slider filter. Our setup of noUiSlider looks then like this:
BUT: as I mentioned before in our use case there is no proper way to handle this by the backend. We can't remove a slider filter if the user filtered so much that only one value is left for a certain property as this is very confusing for the user. They ask themselfs where the slider is gone.
What we would need is with this setup is a range slider with fixed handles to the min/max value. It shouldn't have any functionality in this case but only show up in the same way as the other sliders.
Otherwise I would have to rebuild the slider ui just for this case which doesn't make sense.
Thanks for the comment.
I solved this issue externally now. So when the min equals the max value in the range object I check before I initialize the noUiSlider if min == max - if so, I subtract the step value from the min and add the step value to the max. Additionally I set the start and stop value to the initial min/max value and I disable the slider by setting "behaviour" to "fixed".
That way I get a slider rendered which has its handles fixed to the middle and doesn't to anything than staying there.
Maybe that would be a good default behaviour for the noUiSlider lib when min == max.