Q
Q
qfrontend2019-02-26 22:57:35
JavaScript
qfrontend, 2019-02-26 22:57:35

How to make different slider step in React?

Please tell me how to make the slider move with different steps , for example (500, 1000, 5000, 10000)?
I can't do anything

class Range extends Component {
  state = {
    value: "0",
    step: "500"
  };
  handleChange = event => {
    let eValue = event.target.value;
    let step = this.stepRange(eValue);
    this.setState({ value: eValue, step: step });
  };
  stepRange = eValue => {
    if (eValue > 1000) {
      return 5000;
    }
    if (eValue > 5000) {
      return 10000;
    }
    return 500;
  };
  render() {
    return (
      <div>
        <input
          type="range"
          min="0"
          max="10000"
          value={this.state.value}
          onChange={this.handleChange}
          step={this.state.step}
          className={modRange.inputRange}
        />
        <p>{this.state.value}</p>
      </div>
    );
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-26
@qfrontend

So , right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question