Skip to content

Commit

Permalink
Merge pull request #305 from Robin-front/bugfix/pushable-inaccuracy
Browse files Browse the repository at this point in the history
pushable inaccuracy
  • Loading branch information
yesmeck authored Feb 24, 2018
2 parents c67e422 + f02c9cd commit 138abd7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Range.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ class Range extends React.Component {
nextBounds[state.handle] = value;
let nextHandle = state.handle;
if (props.pushable !== false) {
const originalValue = state.bounds[nextHandle];
this.pushSurroundingHandles(nextBounds, nextHandle, originalValue);
this.pushSurroundingHandles(nextBounds, nextHandle);
} else if (props.allowCross) {
nextBounds.sort((a, b) => a - b);
nextHandle = nextBounds.indexOf(value);
Expand Down Expand Up @@ -204,9 +203,10 @@ class Range extends React.Component {
return this._getPointsCache.points;
}

pushSurroundingHandles(bounds, handle, originalValue) {
const { pushable: threshold } = this.props;
pushSurroundingHandles(bounds, handle) {
const value = bounds[handle];
let { pushable: threshold } = this.props;
threshold = Number(threshold);

let direction = 0;
if (bounds[handle + 1] - value < threshold) {
Expand All @@ -222,7 +222,7 @@ class Range extends React.Component {
const diffToNext = direction * (bounds[nextHandle] - value);
if (!this.pushHandle(bounds, nextHandle, direction, threshold - diffToNext)) {
// revert to original value if pushing is impossible
bounds[handle] = originalValue;
bounds[handle] = bounds[nextHandle] - (direction * threshold);
}
}

Expand Down

0 comments on commit 138abd7

Please sign in to comment.