mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
fix: lowerBound should be smaller than upperBound
This commit is contained in:
+17
-4
@@ -156,10 +156,23 @@ class Slider extends React.Component {
|
||||
this.startPosition = position;
|
||||
|
||||
const {upperBound, lowerBound} = this.state;
|
||||
const isUpperBoundCloser = Math.abs(upperBound - value) < Math.abs(lowerBound - value);
|
||||
let valueNeedChanging = (!this.props.range || isUpperBoundCloser) ? 'upperBound' : 'lowerBound';
|
||||
const isAtTheSamePoint = (upperBound === lowerBound);
|
||||
valueNeedChanging = isAtTheSamePoint ? this.state.recent : valueNeedChanging;
|
||||
|
||||
let valueNeedChanging = 'upperBound';
|
||||
if (this.props.range) {
|
||||
const isLowerBoundCloser = Math.abs(upperBound - value) > Math.abs(lowerBound - value);
|
||||
if (isLowerBoundCloser) {
|
||||
valueNeedChanging = 'lowerBound';
|
||||
}
|
||||
|
||||
const isAtTheSamePoint = (upperBound === lowerBound);
|
||||
if (isAtTheSamePoint) {
|
||||
valueNeedChanging = this.state.recent;
|
||||
}
|
||||
|
||||
if (isAtTheSamePoint && (value !== upperBound)) {
|
||||
valueNeedChanging = value < upperBound ? 'lowerBound' : 'upperBound';
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({
|
||||
handle: valueNeedChanging,
|
||||
|
||||
Reference in New Issue
Block a user