ptomasroos / react-native-multi-slider

Android and iOS Pure JS react native multi slider
MIT License
775 stars 401 forks source link

[Feature Request] Disable tapping and moving slider #216

Open jparksecurity opened 3 years ago

jparksecurity commented 3 years ago

I want to disable the tapping and moving the slider, but I don't think there is any prop to do so.

I think this issue would be the opposite of https://github.com/ptomasroos/react-native-multi-slider/issues/57

Steps to Reproduce

Touch slider to move markers.

Screen Recording 2020-12-02 at 1 24 31 PM

Expected Behavior

I don't move markers by touching the slider.

Added on Dec. 21 2020------------

I don't want to move markers by touching a slider, but I still want to be able to move a marker in order to change the value.

Actual Behavior

There is no prop to disable this behavior.

anthlasserre commented 3 years ago

@jparksecurity @Donhv

I think it is a good idea to manage easily a disabled state.

But it can actually works by a different way waiting this feature request. With enabledOne and enabledTwo props. If you set theses props values to false it will disable the trigger on left and right markers.

In my case I created a useState and a useEffect that will set the disabled state value based on the toggle value.

Exemple:

<MultiSlider
  values={values}
  min={minValue}
  max={maxValue}
  containerStyle={styles.sliderContainer}
  trackStyle={styles.sliderTrack}
  selectedStyle={
    !disabled
      ? styles.sliderSelected
      : styles.sliderSelectedDisabled
  }
  sliderLength={WINDOW_WIDTH - 50}
  onValuesChange={_handleValuesChange}
  enabledOne={!disabled}
  enabledTwo={!disabled}
/>

Enregistrement de l’écran 2020-12-21 à 10 17 34

jparksecurity commented 3 years ago

@anthlasserre

Sorry, I wasn't clear about what I wanted.

I don't want to move the slider by touching the slider, but I still want to be able to move a marker in order to change the value.

If I set enabledOne and enabledTwo to false, I can't change any value at all.