Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ thumbImage | [source](http://facebook.github.io/react-native/docs/ima
debugTouchArea | bool | Yes | false | Set this to true to visually see the thumb touch rect in green.
animateTransitions | bool | Yes | false | Set to true if you want to use the default 'spring' animation
animationType | string | Yes | 'timing' | Set to 'spring' or 'timing' to use one of those two types of animations with the default [animation properties](https://facebook.github.io/react-native/docs/animations.html).
animationConfig | object | Yes | undefined | Used to configure the animation parameters. These are the same parameters in the [Animated library](https://facebook.github.io/react-native/docs/animations.html).
animationConfig | object | Yes | undefined | Used to configure the animation parameters. These are the same parameters in the [Animated library](https://facebook.github.io/react-native/docs/animations.html).
trackPressable | bool | Yes | false | Allow the value to be set at a specific position when the track is pressed


---
Expand Down
13 changes: 10 additions & 3 deletions src/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export default class Slider extends PureComponent {
* Used to configure the animation parameters. These are the same parameters in the Animated library.
*/
animationConfig: PropTypes.object,

/**
* Allow the value to be set at a specific position when the track is pressed
*/
trackPressable : PropTypes.bool,
};

static defaultProps = {
Expand All @@ -180,6 +185,7 @@ export default class Slider extends PureComponent {
thumbTouchSize: { width: 40, height: 40 },
debugTouchArea: false,
animationType: 'timing',
trackPressable: false,
};

state = {
Expand Down Expand Up @@ -322,6 +328,7 @@ export default class Slider extends PureComponent {
style,
trackStyle,
thumbStyle,
trackPressable,
...otherProps
} = props;

Expand All @@ -332,15 +339,15 @@ export default class Slider extends PureComponent {
e: Object /* gestureState: Object */,
): boolean =>
// Should we become active when the user presses down on the thumb?
this._thumbHitTest(e);
this.props.trackPressable || this._thumbHitTest(e);

_handleMoveShouldSetPanResponder(/* e: Object, gestureState: Object */): boolean {
// Should we become active when the user moves a touch over the thumb?
return false;
}

_handlePanResponderGrant = (/* e: Object, gestureState: Object */) => {
this._previousLeft = this._getThumbLeft(this._getCurrentValue());
_handlePanResponderGrant = (e: Object/*, gestureState: Object */) => {
this._previousLeft = this.props.trackPressable ? e.nativeEvent.locationX - (this.props.thumbTouchSize.width/2) : this._getThumbLeft(this._getCurrentValue());
this._fireChangeEvent('onSlidingStart');
};

Expand Down