zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
883 stars 231 forks source link

fix: marks calculation when boolean or number is passed #303

Open Pareder opened 10 months ago

Pareder commented 10 months ago

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.

msf-caesar commented 10 months ago

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.

Pareder commented 10 months ago

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

zachmerrill commented 7 months ago

Would love to see this get merged