How to position rc-slider-dots uniformly on rc-slider-track
Is there a way where I can pass left style to dots on rc slider track?
My requirement is to have uniform spacing between different dots. For example, if I have
min = 100 max = 1000 marks = [100,105,110... 800, 900 ,1000]
I want to equal spacing between all the dots being created by marks.
Any updates on this? Just ran into the same want/wish 😁
++
@tonymaibox, @kcgunn I didn't find a solution for passing the left style to the dots. But if you are looking to have uniform spacing between different dots, following is what I have implemented and it worked fine for me.
so for the slider, I have created object like this
const sliderObj = {
min: 0,
max: 10
values: {
0: 100,
1: 105,
2: 110,
3: 120,
4: 130,
5: 140,
6: 160,
7: 200,
8: 240,
9: 280,
10: 320
}
}
Idea is to have uniform increment in the marks but keeping slider actual value in non-uniform increment. Marks will now be created by the keys from sliderObj.values. When slide event will occur, we can read actual value by mapping to sliderObj.values.
and for the slider then we can use
<Range value={[sliderObj.min, sliderObj.max]}
min={sliderObj.min}
max={sliderObj.max}
marks={sliderObj.values}
onChange={this._onSliderChange}
/>
and when you slide then
_onSliderChange(value) {
const minValueSelected = sliderObj.values[value[0]];
const maxValueSelected = sliderObj.values[value[1]];
// use updated slide value
}
Hope this will help. :)