react-input-range
react-input-range copied to clipboard
Implement new step algorithm
The current step algorithm has a weird behavior when used with minValue
& maxValue
values that are not multiples of step
. (as reported by https://github.com/davidchin/react-input-range/issues/46)
This PR introduces a new step algorithm which:
- rounds the initial value to the next step.
- starts the steps at
minValue
. - threats
maxValue
as a valid step even if it isn't a multiple ofstep
.
eg. with minValue = 2, maxValue = 14, step = 5
Using the current algorithm the steps are: 5, 10
(and a broken initial step of 0
)
Using the new algorithm the steps would be: 2, 7, 12, 14
This should be considered a breaking change.
@davidchin Have you had time to look into this PR yet? We'd love to have this in our app
This makes so much more sense. I just put spent time trying to figure out what I was doing wrong. Please consider merging this.
I don't think I agree with "Round the initial value to the next step" by default. I think that it should be placed exactly where it would be given a random number outside of the step, and on first drag be placed in an actual step.
I think it makes sense to add roundInitialStep={true}
or similar as an option though, so designs using notches could look nice.