Closed olitomas closed 8 years ago
https://github.com/JackDanielsAndCode/react-native-multi-slider/pull/18 should enable you to set the slider values programmatically. Right now without an animation but maybe there will be a future implementation.
@l-urence This merge doesn't seem to have been released in a new npm version... I couldn't see it in 0.2.1 or 0.2.2 at least.
@jrans I think the npm needs an update/new release. @gudmundurmar In the mean time you can install the package from github.
$ npm install --save JackDanielsAndCode/react-native-multi-slider
@l-urence Yes, that's what I ended up doing :) It's just not a nice solutions in case there are any breaking changes introduced to the master. When that's done I think this issue can be closed @olitomas @jrans
@l-urence @gudmundurmar npm version updated, sorry for teh delay and thanks for your patience!
@jrans Great :)
I have a question regarding this issue, since we're now allowing to send down props. Doesn't the arrayValue/optionsArray need to update as soon as the new props are received?
Otherwise it becomes a problem if you create an initial arrayValues/optionsArray that has [1,2,3], but then receive new values through props like 4.
I get Invalid value, array does not contain: 4
because a new arrayValues/optionsArray wasn't made with the new values from props
According to the README:
Note these must be possible values from your set up.
Maybe you can can update the optionsArray
prop with your new value(s)? As far as I can see the slider will then use your new optionsArray
(https://github.com/JackDanielsAndCode/react-native-multi-slider/blob/master/Slider.js#L101).
@l-urence Had a better look at this and found the problem... Not only the values could be changing in componentWillReceiveProps, but also the min, max, and step. Causing the slider to malfunction when the new values don't fit the steps or exceed the old min-max bounds. To fix this the set(values) from https://github.com/JackDanielsAndCode/react-native-multi-slider/blob/master/Slider.js#L101 should also receive set(values, min, max, step). Otherwise making a new optionsArray will just use the old this.props.min, this.props.max and then the optionsArray will be wrong. I made pull request that addresses this problem. https://github.com/JackDanielsAndCode/react-native-multi-slider/pull/22 @jrans
Fixed with #22.
It would be great if I could set the slider value with coding (not my finger). On the same note it would be good to have a "Reset filters" function that resets the filters to their original state.