react-slider icon indicating copy to clipboard operation
react-slider copied to clipboard

fix: marks calculation when boolean or number is passed

Open Pareder opened this issue 1 year ago • 3 comments

Hi, I have found that marks property does not work correctly when min is not zero. You can open demo page and adjust the min property of "Slider with marks" example. In that case all marks are out of tracks. Of course I can calculate numbers by myself and pass an array of numbers but I think it is a good adjustment.

image

Also added tests for marks prop and covered marks logic by checking key property.

Pareder avatar Aug 23 '23 08:08 Pareder

Try with adjusting the step property to match the min value of the Slider. This will ensure that the marks are aligned with the track. Additionally, consider using the included property to determine if the marks should be displayed inside or outside the track.

msf-caesar avatar Sep 01 '23 04:09 msf-caesar

@msf-caesar Why do you think that displaying marks outside is an expected behavior? For me it seems that marks should be inside the track and it should be the default behavior. If user wants to display them outside he would pass an array of numbers:

<ReactSlider
  min={10}
  max={20}
  marks={[-10, 0, 10, 20]}
/>

I don't want to overcomplicate this logic with additional prop included.

Pareder avatar Sep 01 '23 10:09 Pareder

Would love to see this get merged

zachmerrill avatar Nov 08 '23 14:11 zachmerrill