I contain a slider which uses an input range the current numbers are
12, 24, 36, 48, 60
I need to add the ability to contain
24, 36, 48, 60, 120
<input type="range" data-id='slider1RangePicker' name="range"
class="form-range slider range" min="24" max="120" step="12"
id="slider1">
<ul class="range-labels">
<li class="active selected">24</li>
<li>36</li>
<li>48</li>
<li>60</li>
<li>120</li>
</ul>
previously I would set the min as 12 max as 60 and then a step of 12 which allows it to range correctly.
However with adding 120 and removing 24 and setting the min max accordingly the step number no longer works because of the 60-120 jump.
How would I solve this?
2
Answers
You should have a contiguous range from 0..max. You no longer have a linear axis, it it essentially a category axis now.
You can use JavaScript to synchronize the labels to the slider like so:
Note: To get the current value, you can use
getSlider($rangeSlider).dataset.value
.The list attribute and
datalist
element can be used to specify the values.You will also need a small script to block the intermediate positions.