react-native-multi-slider icon indicating copy to clipboard operation
react-native-multi-slider copied to clipboard

create lables on given positions?

Open deep-link opened this issue 6 years ago • 1 comments

is there a way to add lables on given positions? and steps seperators?

deep-link avatar Mar 08 '19 09:03 deep-link

Hi! Not a direct solution to your question about given positions, but if you are interested in displaying the value with the markers as they move, you can create a custom marker similar to the given marker in DefaultMarker.js. You would only need to make one change to the render function inside DefaultMarker.js to show the values like so:

render() {
    return (
      <View> // WRAP ENTIRE THING IN ANOTHER VIEW
        <Text style = {{flex: 0.3}}>{this.props.currentValue}</Text> // NEW LINE
        <TouchableHighlight style = {{flex: 0.7}}>
          <View
            style={this.props.enabled ? [
              styles.markerStyle,
              this.props.markerStyle,
              this.props.pressed && styles.pressedMarkerStyle,
              this.props.pressed && this.props.pressedMarkerStyle,
            ] : [styles.markerStyle, styles.disabled]}
          />
        </TouchableHighlight>
      </View>
    );
  }

I chose the flex values to keep the marker centered on the track. Finally, you would specify the customMarker prop on your MultiSlider component:

<MultiSlider
   ...                
   customMarker = {myMarker}
/>   

Hope this helps in some way!

nquaz avatar Mar 12 '19 03:03 nquaz