Skip to content

Commit

Permalink
ci: inverted sliders, honor inverted key down handler for horizontal …
Browse files Browse the repository at this point in the history
…sliders
  • Loading branch information
Ryan Haig authored and Ryan Haig committed Apr 5, 2023
1 parent 33a7898 commit bdb2292
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/components/ReactSlider/ReactSlider.jsx
Expand Up @@ -824,14 +824,28 @@ class ReactSlider extends React.Component {

moveUpByStep(step = this.props.step) {
const oldValue = this.state.value[this.state.index];
const newValue = trimAlignValue(oldValue + step, this.props);
this.move(Math.min(newValue, this.props.max));

// if the slider is inverted and horizontal we want to honor the inverted value
const newValue =
this.props.invert && this.props.orientation === 'horizontal'
? oldValue - step
: oldValue + step;

const trimAlign = trimAlignValue(newValue, this.props);
this.move(Math.min(trimAlign, this.props.max));
}

moveDownByStep(step = this.props.step) {
const oldValue = this.state.value[this.state.index];
const newValue = trimAlignValue(oldValue - step, this.props);
this.move(Math.max(newValue, this.props.min));

// if the slider is inverted and horizontal we want to honor the inverted value
const newValue =
this.props.invert && this.props.orientation === 'horizontal'
? oldValue + step
: oldValue - step;

const trimAlign = trimAlignValue(newValue, this.props);
this.move(Math.max(trimAlign, this.props.min));
}

move(newValue) {
Expand Down

0 comments on commit bdb2292

Please sign in to comment.