Skip to content
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

add minimumTrackStyle and maximumTrackStyle props #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ disabled | bool | Yes | false | If tru
minimumValue | number | Yes | 0 | Initial minimum value of the slider
maximumValue | number | Yes | 1 | Initial maximum value of the slider
step | number | Yes | 0 | Step value of the slider. The value should be between 0 and maximumValue - minimumValue)
minimumTrackStyle | object | Yes | {} | Custom style for the track to the left of the button
maximumTrackStyle | object | Yes | {} | Custom style for the track to the right of the button
minimumTrackTintColor | string | Yes | '#3f3f3f' | The color used for the track to the left of the button
maximumTrackTintColor | string | Yes | '#b3b3b3' | The color used for the track to the right of the button
thumbTintColor | string | Yes | '#343434' | The color used for the thumb
Expand All @@ -94,7 +96,7 @@ 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).


---
Expand Down
19 changes: 17 additions & 2 deletions src/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export default class Slider extends PureComponent {
*/
step: PropTypes.number,

/**
* The style used for the track to the left of the button.
*/
minimumTrackStyle: PropTypes.object,

/**
* The style used for the track to the right of the button.
*/
maximumTrackStyle: PropTypes.object,

/**
* The color used for the track to the left of the button. Overrides the
* default blue gradient image.
Expand Down Expand Up @@ -174,6 +184,8 @@ export default class Slider extends PureComponent {
minimumValue: 0,
maximumValue: 1,
step: 0,
minimumTrackStyle: {},
maximumTrackStyle: {},
minimumTrackTintColor: '#3f3f3f',
maximumTrackTintColor: '#b3b3b3',
thumbTintColor: '#343434',
Expand Down Expand Up @@ -218,6 +230,8 @@ export default class Slider extends PureComponent {
const {
minimumValue,
maximumValue,
minimumTrackStyle,
maximumTrackStyle,
minimumTrackTintColor,
maximumTrackTintColor,
thumbTintColor,
Expand Down Expand Up @@ -258,7 +272,7 @@ export default class Slider extends PureComponent {
valueVisibleStyle.opacity = 0;
}

const minimumTrackStyle = {
const defaultMinimumTrackStyle = {
position: 'absolute',
width: Animated.add(minimumTrackWidth, thumbSize.width / 2),
backgroundColor: minimumTrackTintColor,
Expand All @@ -278,13 +292,14 @@ export default class Slider extends PureComponent {
{ backgroundColor: maximumTrackTintColor },
mainStyles.track,
trackStyle,
maximumTrackStyle,
]}
renderToHardwareTextureAndroid
onLayout={this._measureTrack}
/>
<Animated.View
renderToHardwareTextureAndroid
style={[mainStyles.track, trackStyle, minimumTrackStyle]}
style={[mainStyles.track, trackStyle, defaultMinimumTrackStyle, minimumTrackStyle]}
/>
<Animated.View
onLayout={this._measureThumb}
Expand Down