Got a small script coded which increments left or right by 100px when clicking on the previous and next buttons.
Was wondering if there was a way to make the script stop increasing the value once it reaches a certain point (let's say -500px or +500px for example).
constructor(props) {
super();
this.state = {
bgColor: 0
};
this.handleClickRight = this.handleClickRight.bind(this);
this.handleClickLeft = this.handleClickLeft.bind(this);
}
handleClickRight(e) {
e.preventDefault();
this.setState({
bgColor: this.state.bgColor - 100
})
}
handleClickLeft(e) {
e.preventDefault();
this.setState({
bgColor: this.state.bgColor + 100
})
}
render() {
return (
<div>
<div className="slider-controls">
<a href="#" className="slider-control prev" onClick={this.handleClickLeft}>Prev</a>
<a href="#" className="slider-control next" onClick={this.handleClickRight}>Next</a>
</div>