score:2

Accepted answer

That's a really clever UI!

increaseStakeLimits() fires continuously the whole time the user holds the slider to the far right, so you're continually setting new setTimeouts to change this.stakeChangeTimeout to the shorter interval after two seconds (and continually setting new values for this.fasterChangeStake). These continue to fire even after handleRelease() tries to reset the interval to the longer value, which forces it back into fast mode until all of them have fired (the clearTimeout in handleRelease() only catches one of them.)

You can fix this by only setting that timeout once:

if (!this.fasterChangeStake) {
  this.fasterChangeStake = setTimeout(() => {
    this.stakeChangeTimeout = this.FAST_STAKE_CHANGE_TIMEOUT;
    this.fasterChangeStake = false; // <-- also do this in handleRelease() after clearing the timeout
  }, 2000);
}

https://codepen.io/anon/pen/OgmMNq?editors=0010


Related Query

More Query from same tag