rn-range-slider
Advanced tools
Comparing version
83
index.js
import React, {PureComponent} from 'react'; | ||
import {requireNativeComponent} from 'react-native'; | ||
import PropTypes from 'prop-types' | ||
const NativeRangeSlider = requireNativeComponent('RangeSlider'); | ||
export default class RangeSlider extends PureComponent { | ||
class RangeSlider extends PureComponent { | ||
constructor(props) { | ||
@@ -21,4 +22,80 @@ super(props); | ||
render() { | ||
return <NativeRangeSlider {...this.props} onValueChanged={this._unboxEvent}/> | ||
let { initialHighValue, initialLowValue, min, max } = this.props; | ||
if (initialLowValue === undefined) { | ||
initialLowValue = min; | ||
} | ||
if (initialHighValue === undefined) { | ||
initialHighValue = max; | ||
} | ||
const sliderProps = {...this.props, initialLowValue, initialHighValue}; | ||
return <NativeRangeSlider | ||
{...sliderProps} | ||
ref={component => this._slider = component} | ||
onValueChanged={this._unboxEvent} | ||
/> | ||
} | ||
} | ||
setHighValue = value => { | ||
this._slider.setNativeProps({ highValue: value }); | ||
} | ||
setLowValue = value => { | ||
this._slider.setNativeProps({ lowValue: value }); | ||
} | ||
} | ||
RangeSlider.propTypes = { | ||
rangeEnabled: PropTypes.bool, | ||
gravity: PropTypes.string, | ||
min: PropTypes.number, | ||
max: PropTypes.number, | ||
step: PropTypes.number, | ||
initialLowValue: PropTypes.number, | ||
initialHighValue: PropTypes.number, | ||
lineWidth: PropTypes.number, | ||
thumbRadius: PropTypes.number, | ||
thumbBorderWidth: PropTypes.number, | ||
labelStyle: PropTypes.string, | ||
labelGapHeight: PropTypes.number, | ||
labelTailHeight: PropTypes.number, | ||
labelFontSize: PropTypes.number, | ||
labelBorderWidth: PropTypes.number, | ||
labelPadding: PropTypes.number, | ||
labelBorderRadius: PropTypes.number, | ||
textFormat: PropTypes.string, | ||
blankColor: PropTypes.string, | ||
selectionColor: PropTypes.string, | ||
thumbColor: PropTypes.string, | ||
thumbBorderColor: PropTypes.string, | ||
labelTextColor: PropTypes.string, | ||
labelBackgroundColor: PropTypes.string, | ||
labelBorderColor: PropTypes.string, | ||
} | ||
RangeSlider.defaultProps = { | ||
rangeEnabled: true, | ||
gravity: 'top', | ||
min: 0, | ||
max: 100, | ||
step: 1, | ||
lineWidth: 4, | ||
thumbRadius: 10, | ||
thumbBorderWidth: 2, | ||
labelStyle: 'bubble', | ||
labelGapHeight: 4, | ||
labelTailHeight: 8, | ||
labelFontSize: 16, | ||
labelBorderWidth: 2, | ||
labelPadding: 4, | ||
labelBorderRadius: 4, | ||
textFormat: '%d', | ||
blankColor: '#ffffff7f', | ||
selectionColor: '#4286f4', | ||
thumbColor: '#ffffff', | ||
thumbBorderColor: '#cccccc', | ||
labelTextColor: '#ffffff', | ||
labelBackgroundColor: '#ff60ad', | ||
labelBorderColor: '#d13e85', | ||
} | ||
export default RangeSlider |
{ | ||
"name": "rn-range-slider", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"author": "Tigran Sahakyan <mail.of.tigran@gmail.com>", | ||
"description": "React Native Range Slider for Android and iOS", | ||
"homepage": "https://github.com/githuboftigran/rn-range-slider", | ||
@@ -31,2 +32,2 @@ "main": "index.js", | ||
"license": "ISC" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
976181
1.15%26
8.33%709
14.54%