slider icon indicating copy to clipboard operation
slider copied to clipboard

How to position rc-slider-dots uniformly on rc-slider-track

Open Shardendu-kantha opened this issue 8 years ago • 3 comments

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.

Shardendu-kantha avatar Apr 24 '18 08:04 Shardendu-kantha

Any updates on this? Just ran into the same want/wish 😁

tonymaibox avatar Aug 30 '18 19:08 tonymaibox

++

kcgunn avatar Sep 04 '18 21:09 kcgunn

@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. :)

Shardendu-kantha avatar Sep 05 '18 05:09 Shardendu-kantha