New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min = max #676

Closed
mr-simonski opened this Issue Aug 16, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@mr-simonski

mr-simonski commented Aug 16, 2016

Hello,
first of all: thank you for this great lib as it helped me to save a lot of dev time.

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:

noUiSlider.create(slider, {
    start: 0,
    stop: 100,
    step: 1,
    connect: true,
    range: {
        min: 30,
        max: 30
    }
});

This was already addressed in issues 236, 578 and 633 and you always replied that it makes no sense to setup a range slider with min = max for which I totally agree.

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 again,
best
Simon

@leongersen

This comment has been minimized.

Owner

leongersen commented Aug 16, 2016

You can set the range to 0 to 1 and set the disabled attribute.

I get that a dynamic form will have this issue, but to me it doesn't make sense to solve it in the control.

@mr-simonski

This comment has been minimized.

mr-simonski commented Aug 16, 2016

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.

Thanks
Simon

@leongersen

This comment has been minimized.

Owner

leongersen commented Sep 29, 2016

I've added a note to the docs, including a link to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment