Skip to content

Commit

Permalink
define different default values according to orientation + clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
CYB3RL1F3 committed Oct 28, 2017
1 parent f0a9859 commit 6eff2cb
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default class Slider extends PureComponent {

var touchOverflowStyle = this._getTouchOverflowStyle();
return (
<View {...other} style={[mainStyles.container, {
<View {...other} style={[this._isHorizontal() ? mainStyles.containerHorizontal : mainStyles.containerVertical, {
justifyContent: this._isHorizontal() ? 'center' : 'flex-end'
}, style]} onLayout={this._measureContainer}>
<View
Expand Down Expand Up @@ -479,22 +479,6 @@ export default class Slider extends PureComponent {
}
}

_getValueWithRatio (ratio) {
if (this.props.step) {
return Math.max(this.props.minimumValue,
Math.min(this.props.maximumValue,
this.props.minimumValue + Math.round(ratio * (this.props.maximumValue - this.props.minimumValue) / this.props.step) * this.props.step
)
);
} else {
return Math.max(this.props.minimumValue,
Math.min(this.props.maximumValue,
ratio * (this.props.maximumValue - this.props.minimumValue) + this.props.minimumValue
)
);
}
}

_getCurrentValue = () => {
return this.state.value.__getValue();
};
Expand Down Expand Up @@ -615,10 +599,15 @@ export default class Slider extends PureComponent {
}

var defaultStyles = StyleSheet.create({
container: {
height: 280,
containerHorizontal: {
height: 40,
justifyContent: 'center',
},
containerVertical: {
height: 280,
width: 30,
justifyContent: 'flex-end',
},
track: {
height: TRACK_SIZE,
borderRadius: TRACK_SIZE / 2,
Expand Down

0 comments on commit 6eff2cb

Please sign in to comment.