simeydotme / svelte-range-slider-pips

Multi-Thumb, Accessible, Beautiful Range Slider with Pips
https://simeydotme.github.io/svelte-range-slider-pips/
Mozilla Public License 2.0
464 stars 44 forks source link

[feature] Lock values to a range #96

Closed henryjameslau closed 1 year ago

henryjameslau commented 1 year ago

Describe the feature I have slider using the range mode and I want to be able to set a handle to not go past a specific point. If this was not a range I'd be able to use min but since this is a range I cannot.

Explain it's value / reasoning I'm using a slider to filter an array of numbers and I need at least two numbers between the min and max set by the slider. In this particular example I'm calculating equal interval breaks which needs more than one number to do the calculations.

Additional context Here an image of the slider in use. image

simeydotme commented 1 year ago

Hi @henryjameslau .. I don't fully understand your description, is it like this?;

|---------◉------------------------◉--------------|
0    1    2    3    4    5    6    7    8    9    10

You want to block the left-thumb from going past the number 2? like a fake "min" ?

If that's the case, you can add this yourself with the on:start, on:change, or on:end events https://github.com/simeydotme/svelte-range-slider-pips#slider-events-dispatched and detect if the value is less than your desired "min" and then re-set the value to the min value.

henryjameslau commented 1 year ago

Yes that's what I was imagining. Thanks for pointing me to the events, I'll give them a go. Henry