react-use-precision-timer icon indicating copy to clipboard operation
react-use-precision-timer copied to clipboard

Set paused timer value

Open sobocinski opened this issue 2 years ago • 0 comments

Hello @justinmahar, I'm preparing something like a timeline, where user can play/pause time, but also move "in time" (by click). I have edge case with my app - when user pause timer, but change position.

onTimlineClick(value:number) => {
  const startTime = Date.now() - value * 1000;
  timer.start(startTime); //start timer with clicked time
  if (isTimerRunning) {//hack to pause again 
         timer.pause();
     }
}

The code above is how I currently do it, which is to use .start(X) and then .puase() based on external state. But in this case, the timer will start for microseconds and I have a slightly different result than what the user set.

Generally, I would like to set a timer with any value and have it paused. Do you think it is possible?

sobocinski avatar Jul 11 '23 05:07 sobocinski