I try to implement a multi-slider with two values. It worked fine until I wanted to process and update values after the change.
I started using onValuesChangeFinish(), tried the onValuesChange() as well. If I set these functions and keep them empty, it works. If I start to change my own variable (not used in the slider) as in setPeakStartDate(addDays(minDate, values[0])); it starts to jump back to the initial position after I release the slider. Tried setting the values manually through peakSliderValues variable, but it didn't help as well. Am I missing something?
<MultiSlider
containerStyle={{ paddingHorizontal: 16, backgroundColor: 'red' }}
sliderLength={width - 32} //minus the 2 * padding
snapped
step={1}
min={0}
max={steps}
enabledOne={true}
enabledTwo={true}
enableLabel={true}
smoothSnapped={true}
customLabel={props => <SliderLabel startDate={minDate} {...props} />}
/* HERE THE FUN BEGINS */
//values={[peakSliderValues[0], peakSliderValues[1]]}
values={[0, 10]}
// onValuesChange={values => {
// setPeakSliderValues(values);
// setPeakStartDate(addDays(minDate, values[0]));
// setPeakEndDate(addDays(minDate, values[1]));
// }}
onValuesChangeFinish={values => {
// setPeakSliderValues(values);
// setPeakStartDate(addDays(minDate, values[0]));
// setPeakEndDate(addDays(minDate, values[1]));
}}
Thanks
I try to implement a multi-slider with two values. It worked fine until I wanted to process and update values after the change.
I started using
onValuesChangeFinish(), tried theonValuesChange()as well. If I set these functions and keep them empty, it works. If I start to change my own variable (not used in the slider) as insetPeakStartDate(addDays(minDate, values[0]));it starts to jump back to the initial position after I release the slider. Tried setting the values manually throughpeakSliderValuesvariable, but it didn't help as well. Am I missing something?Thanks