rc-slider
Advanced tools
Comparing version 3.1.4 to 3.2.0
@@ -124,3 +124,3 @@ 'use strict'; | ||
if (nextProps.range) { | ||
var value = nextProps.value; | ||
var value = nextProps.value || [lowerBound, upperBound]; | ||
var nextUpperBound = this.trimAlignValue(value[1], nextProps); | ||
@@ -138,3 +138,4 @@ var nextLowerBound = this.trimAlignValue(value[0], nextProps); | ||
} else { | ||
var nextValue = this.trimAlignValue(nextProps.value, nextProps); | ||
var value = 'value' in nextProps ? nextProps.value : upperBound; | ||
var nextValue = this.trimAlignValue(value, nextProps); | ||
if (nextValue === upperBound && lowerBound === nextProps.min) return; | ||
@@ -153,15 +154,12 @@ | ||
key: 'onChange', | ||
value: function onChange(handle, value) { | ||
value: function onChange(state) { | ||
var props = this.props; | ||
var isNotControlled = !('value' in props); | ||
if (isNotControlled) { | ||
this.setState(_defineProperty({}, handle, value)); | ||
this.setState(state); | ||
} else if (state.handle) { | ||
this.setState({ handle: state.handle }); | ||
} | ||
var state = this.state; | ||
var data = { | ||
upperBound: state.upperBound, | ||
lowerBound: state.lowerBound | ||
}; | ||
data[handle] = value; | ||
var data = (0, _objectAssign3['default'])({}, this.state, state); | ||
var changedValue = props.range ? [data.lowerBound, data.upperBound] : data.upperBound; | ||
@@ -201,3 +199,20 @@ props.onChange(changedValue); | ||
this.onChange(state.handle, value); | ||
if (props.allowCross && value < state.lowerBound && state.handle === 'upperBound') { | ||
this.onChange({ | ||
handle: 'lowerBound', | ||
lowerBound: value, | ||
upperBound: this.state.lowerBound | ||
}); | ||
return; | ||
} | ||
if (props.allowCross && value > state.upperBound && state.handle === 'lowerBound') { | ||
this.onChange({ | ||
handle: 'upperBound', | ||
upperBound: value, | ||
lowerBound: this.state.upperBound | ||
}); | ||
return; | ||
} | ||
this.onChange(_defineProperty({}, state.handle, value)); | ||
} | ||
@@ -261,3 +276,3 @@ }, { | ||
this.onChange(valueNeedChanging, value); | ||
this.onChange(_defineProperty({}, valueNeedChanging, value)); | ||
} | ||
@@ -321,2 +336,3 @@ }, { | ||
var max = _objectAssign.max; | ||
var allowCross = _objectAssign.allowCross; | ||
@@ -330,6 +346,6 @@ var val = v; | ||
} | ||
if (handle === 'upperBound' && val <= lowerBound) { | ||
if (!allowCross && handle === 'upperBound' && val <= lowerBound) { | ||
val = lowerBound; | ||
} | ||
if (handle === 'lowerBound' && val >= upperBound) { | ||
if (!allowCross && handle === 'lowerBound' && val >= upperBound) { | ||
val = upperBound; | ||
@@ -492,3 +508,4 @@ } | ||
dots: _react2['default'].PropTypes.bool, | ||
range: _react2['default'].PropTypes.bool | ||
range: _react2['default'].PropTypes.bool, | ||
allowCross: _react2['default'].PropTypes.bool | ||
}; | ||
@@ -510,3 +527,4 @@ | ||
dots: false, | ||
range: false | ||
range: false, | ||
allowCross: true | ||
}; | ||
@@ -513,0 +531,0 @@ |
{ | ||
"name": "rc-slider", | ||
"version": "3.1.4", | ||
"version": "3.2.0", | ||
"description": "slider ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -110,2 +110,8 @@ # rc-slider | ||
<tr> | ||
<td>allowCross</td> | ||
<td>boolean</td> | ||
<td>true</td> | ||
<td>When `range` is `true`, `allowCross` could be set as `true` to allow those two handles cross.</td> | ||
</tr> | ||
<tr> | ||
<td>defaultValue</td> | ||
@@ -112,0 +118,0 @@ <td>number or [number, number]</td> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41331
900
196