timer.jquery icon indicating copy to clipboard operation
timer.jquery copied to clipboard

Countdown timer with negative remaining time

Open naXa777 opened this issue 6 years ago • 1 comments

Try to initialize countdown with negative remaining time (i.e. seconds > duration):

let timeLimit = 10;
let timeElapsed = 15;
let $countdown = $("#countdown").timer({
        countdown: true,
        duration: timeLimit + 's',
        seconds: timeElapsed
    });

Expected result: -5 sec Actual result: -1:0-5 min

Demo: https://jsfiddle.net/naXa/gmcbfd4w (v0.7.1) and https://jsfiddle.net/naXa/gmcbfd4w/9 (v0.9.0)

jquery-timer-bug

It would be nice to have an endless countdown which:

  1. doesn't stop when reached 0.
  2. looks nice with negative time values.
  3. can be initialized with negative duration.

naXa777 avatar Jan 16 '19 20:01 naXa777

Thanks for submitting this issue.

By default maybe we can have the timer stop on encountering such a situation and we can bypass it by a property that says something like allowNegativeCountdown. Or We could implement it and set this to be true by default and have users explicitly set it to false if they dont want this behavior.

Either ways, this is a good to have feature.. Feel free to implement it and send a PR (assign it to yourself if you are interested).. if not I ll try to squeeze in some time to add this unless somebody else picks it up and assigns to themselves in the mean time.

walmik avatar Jan 20 '19 07:01 walmik