react-range-slider
Advanced tools
Comparing version 0.0.7 to 0.0.8
15
index.js
@@ -24,7 +24,7 @@ var React = require('react/addons'); | ||
*/ | ||
function valureFormat(value, range) { | ||
function valueFormat(value, max, min) { | ||
value = typeof value === 'number' ? [value] : value; | ||
return value.map(function (v, i) { | ||
return typeof v === 'object' ? v : { | ||
value: typeof v === 'number' ? v : parseInt((i + 1) * range / value.length, 10), | ||
value: typeof v === 'number' ? v : (parseInt((i + 1) * (max - min) / value.length, 10) + min), | ||
color: typeof v === 'string' ? v : '' | ||
@@ -238,3 +238,3 @@ }; | ||
maxProp: this.isHorizontal() ? 'right' : 'bottom', | ||
value: valureFormat(this.props.value, this.props.max - this.props.min) | ||
value: valueFormat(this.props.value, max, min) | ||
}; | ||
@@ -254,3 +254,3 @@ }, | ||
this.setState({ | ||
value: valureFormat(nextProps.value, this.props.max - this.props.min) | ||
value: valueFormat(nextProps.value, this.props.max, this.props.min) | ||
}, function () { | ||
@@ -387,5 +387,9 @@ // Calculate the bound size again, if the bound size less than 0 | ||
zIndex = 0; | ||
child = child || React.createElement('span', null, this.state.min); | ||
} else if (i === l + 1) { | ||
ref = 'tailer'; | ||
zIndex = 0; | ||
child = child || React.createElement('span', null, this.state.max); | ||
} else { | ||
child = child || React.createElement('span', null, this.state.value[i - 1] ? this.state.value[i - 1].value : null); | ||
} | ||
@@ -412,4 +416,3 @@ return Cursor({ | ||
if (this.state.header) { | ||
cursors.splice(0, 0, this.renderCursor(this.calcOffset(this.state.min), 0, | ||
React.createElement('span', null, this.state.min))); | ||
cursors.splice(0, 0, this.renderCursor(this.calcOffset(this.state.min), 0)); | ||
} | ||
@@ -416,0 +419,0 @@ if (this.state.tailer) { |
{ | ||
"name": "react-range-slider", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A flexible slider for reactjs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
22879
624