Skip to content
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

Remove padding must be > 50% range test #865

Merged
merged 1 commit into from
Apr 2, 2018

Conversation

patrickarlt
Copy link
Contributor

I ran into an issue trying to create sliders like:

var slider = document.getElementById('slider');

noUiSlider.create(slider, {
  start: [14, 18],
  range: {
    min: 0,
    max: 18
  },
  padding: [12, 0],
  step: 1
});

Where padding exceeds half the range which causes the:

'padding' option must be less than half the range.

error. I tested removing this option in my application and didn't see any negative side effects and thought I would PR it. This doesn't seems to cause any tests to fail.

@leongersen
Copy link
Owner

leongersen commented Mar 1, 2018

Thanks for the pull request! This was in there to make sure the padding wasn't the full range (>50% * 2 = >100%). It wasn't properly updated when adding support for different paddings on either side of the slider. I think we could change the test to parsed.padding[0] + parsed.padding[1] >= 100. That'd resolve your case, too.

@patrickarlt
Copy link
Contributor Author

@leongersen sounds good. I'll update this PR to change the test to parsed.padding[0] + parsed.padding[1] >= 100 and add some new test. I should be able to get to this next week.

@gabrielDevlog
Copy link

Hi guyz
Is this MR going to be merged soon ? I ran on this error too, with the same use-case.

@leongersen leongersen merged commit a8b4e09 into leongersen:master Apr 2, 2018
@leongersen
Copy link
Owner

I just released noUiSlider 11.1.0 that has this fix. Thanks for reporting!

@bazineta
Copy link
Contributor

I'm curious if there's a non-negotiable reason for the test being >= 100, rather than > 100.

A sample use case is that I have n sliders that together comprise a total allocation, and a budget that that total is against. As the sliders are actuated, one can then apply padding to limit the sliders to how much of the budget remains.

In that scenario, if for example a given slider is at 0 and the budget has been completely allocated by the other sliders, then you'd want to set the padding on that slider to the full range; there's no budget left, so the slider can't leave 0.

However, that seems not to be possible at present. Should it be?

@bazineta bazineta mentioned this pull request Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants