diff --git a/node_modules/@miblanchard/react-native-slider/lib/index.d.ts b/node_modules/@miblanchard/react-native-slider/lib/index.d.ts index e32f8fd..808b3b4 100644 --- a/node_modules/@miblanchard/react-native-slider/lib/index.d.ts +++ b/node_modules/@miblanchard/react-native-slider/lib/index.d.ts @@ -22,6 +22,7 @@ export declare class Slider extends PureComponent { step: number; thumbTintColor: string; trackClickable: boolean; + onlyTracksClickable: boolean; value: number; vertical: boolean; }; diff --git a/node_modules/@miblanchard/react-native-slider/lib/index.js b/node_modules/@miblanchard/react-native-slider/lib/index.js index 074bd84..8d7b941 100644 --- a/node_modules/@miblanchard/react-native-slider/lib/index.js +++ b/node_modules/@miblanchard/react-native-slider/lib/index.js @@ -119,6 +119,7 @@ export class Slider extends PureComponent { step: 0, thumbTintColor: '#343434', trackClickable: true, + onlyTracksClickable: false, value: 0, vertical: false, }; @@ -185,10 +186,16 @@ export class Slider extends PureComponent { return false; }; _handlePanResponderEnd = (_e, gestureState) => { + let trackMarks = [...this.props.trackMarks] + trackMarks.unshift(0) + let currentState = this._getValue(gestureState) + var nearestTrack = trackMarks.reduce(function (prev, curr) { + return (Math.abs(curr - currentState) < Math.abs(prev - currentState) ? curr : prev); + }); if (this.props.disabled) { return; } - this._setCurrentValue(this._getValue(gestureState), this._activeThumbIndex, () => { + this._setCurrentValue(this.props.onlyTracksClickable ? nearestTrack : currentState, this._activeThumbIndex, () => { if (this.props.trackClickable) { this.props?.onValueChange?.(this._getRawValues(this.state.values)); }