Skip to content

onValuesChangeFinish() makes slider to stop after one date #278

Description

@asjustis

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions