-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slider to be be responsive to click #92
base: master
Are you sure you want to change the base?
Changes from 1 commit
e3aebc5
3e86e38
8ea357e
48c3395
7f4ee41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
||
/** | ||
* Set to true to update the value whilst clicking the Slider | ||
*/ | ||
trackClickable : PropTypes.bool, | ||
}; | ||
|
||
static defaultProps = { | ||
|
@@ -179,7 +184,8 @@ export default class Slider extends PureComponent { | |
thumbTintColor: '#343434', | ||
thumbTouchSize: {width: 40, height: 40}, | ||
debugTouchArea: false, | ||
animationType: 'timing' | ||
animationType: 'timing', | ||
trackClickable: false, | ||
}; | ||
|
||
state = { | ||
|
@@ -228,6 +234,7 @@ export default class Slider extends PureComponent { | |
trackStyle, | ||
thumbStyle, | ||
debugTouchArea, | ||
trackClickable, | ||
...other | ||
} = this.props; | ||
var {value, containerSize, trackSize, thumbSize, allMeasured} = this.state; | ||
|
@@ -296,6 +303,7 @@ export default class Slider extends PureComponent { | |
style, | ||
trackStyle, | ||
thumbStyle, | ||
trackClickable, | ||
...otherProps, | ||
} = props; | ||
|
||
|
@@ -304,8 +312,7 @@ export default class Slider extends PureComponent { | |
|
||
_handleStartShouldSetPanResponder = (e: Object, /*gestureState: Object*/): boolean => { | ||
// Should we become active when the user presses down on the thumb? | ||
// return this._thumbHitTest(e); | ||
return true; | ||
return this.props.trackClickable ? true : this._thumbHitTest(e); | ||
}; | ||
|
||
_handleMoveShouldSetPanResponder(/*e: Object, gestureState: Object*/): boolean { | ||
|
@@ -315,7 +322,7 @@ export default class Slider extends PureComponent { | |
|
||
_handlePanResponderGrant = (e: Object, gestureState: Object) => { | ||
// this._previousLeft = this._getThumbLeft(this._getCurrentValue()); | ||
this._previousLeft = gestureState.x0 - (this.state.thumbSize.width/2); | ||
this._previousLeft = this.props.trackClickable ? gestureState.x0 - (this.state.thumbSize.width/2) : this._getThumbLeft(this._getCurrentValue()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also need to change: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
this._fireChangeEvent('onSlidingStart'); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react-native-slider is still not clickable
Does anyone have a solution for this?
I made the above changes to the Slider.js file. It still does not work for Android or IOS.
Slider.txt