2.1.0 • Published 5 years ago

@codebet/react-native-multi-slider v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

react-native-multi-slider

Pure JS react native slider component with one or two markers. Options to customize track, touch area and provide customer markers and callbacks for touch events and value changes.

Examples

cd example
npm install
react-native run-ios
react-native run-android

Example

Getting Started

Installation

$ npm install --save @ptomasroos/react-native-multi-slider

Usage in a ScrollView

 enableScroll = () => this.setState({ scrollEnabled: true });
 disableScroll = () => this.setState({ scrollEnabled: false });

 render() {
   return (
     <ScrollView scrollEnabled={this.state.scrollEnabled}>
      <MultiSlider
        ...
        onValuesChangeStart={this.disableScroll}
        onValuesChangeFinish={this.enableScroll}
      />
    </ScrollView>
    );

shape up CustomMarker as left and right

In order to make different styles on markers you can set isMarkersSeparated to true, define customMarkerLeft and customMarkerRight in MultiSlider. for example:

<MultiSlider
     ...
      isMarkersSeparated={true}

      customMarkerLeft={(e) => {
         return (<CustomSliderMarkerLeft
          currentValue={e.currentValue}/>)
          }}

         customMarkerRight={(e) => {
         return (<CustomSliderMarkerRight
         currentValue={e.currentValue}/>)
         }}
     />

Partial report of the props

Feel free to contribute to this part of the documentation.

Prop nameDefault valueTypePurpouse
values0array of numbersPrefixed values of the slider.
onValuesChangeStart() => {}functionCallback when the value starts changing
onValuesChange() => {}functionCallback when the value changes
onValuesChangeFinish(values) => {}functionCallback when the value stops changing
sliderLength280numberLength of the slider (?)
touchDimensions{height: 50,width: 50,borderRadius: 15,slipDisplacement: 200}object(?)
customMarkerfunctionComponent used for the cursor.
customMarkerLeftfunctionComponent used for the left cursor.
customMarkerRightfunctionComponent used for the right cursor.
isMarkersSeparatedboolean(?)
min0numberMinimum value available in the slider.
max10numberMaximum value available in the slider.
step1numberStep value of the slider.
optionsArrayarray(?)
{container/track/selected/unselected/ markerContainer/marker/pressedMarker} Stylestyle objectStyles for the slider
valuePrefixstringPrefix added to the value.
valueSuffixstringSuffix added to the value.
enabledOnetruebooleanEnables the first cursor
enabledTwotruebooleanEnables the second cursor
onToggleOneundefinedfunction callbackListener when first cursor toggles.
onToggleTwoundefinedfunction callbackListener when second cursor toggles.
allowOverlapfalsebooleanAllow the overlap within the cursors.
snappedfalsebooleanUse this when you want a fixed position for your markers, this will split the slider in N specific positions
markerOffsetX0numberOffset first cursor.
markerOffsetY0numberOffset second cursor.