react-input-range icon indicating copy to clipboard operation
react-input-range copied to clipboard

Implement new step algorithm

Open ephys opened this issue 7 years ago • 3 comments

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 of step.

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.

ephys avatar Apr 14 '17 13:04 ephys

@davidchin Have you had time to look into this PR yet? We'd love to have this in our app

FreeCaribou avatar Aug 03 '17 07:08 FreeCaribou

This makes so much more sense. I just put spent time trying to figure out what I was doing wrong. Please consider merging this.

williamboman avatar Feb 21 '18 15:02 williamboman

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.

johnrom avatar Jun 28 '18 21:06 johnrom