Skip to content

Changing an option always resets relative countdowns. #96

Description

@bzurmaar

Using the option function causes relative countdowns to restart. This can be reproduced with the following steps:

  1. Visit the demo page at http://keith-wood.name/countdownBasics.html. Open the browser's developer console to enter JS.
  2. Stop the running countdown with
    $('#defaultCountdown').countdown('destroy');
  3. Start a new countdown with a relative expiry with
    $('#defaultCountdown').countdown({until: '+1m'});
  4. Change anything in the configuration with e.g.
    $('#defaultCountdown').countdown('option', 'format', 'MS');

You'll see that the countdown starts counting down again from 1 minute although that option wasn't changed. After a brief inspection of the code I pinned the error down to https://github.com/kbwood/countdown/blob/master/src/js/jquery.countdown.js#L384. There is a check if the timezone changed. It is assume changed, if the two timezones are not equal. As the new config option does not have a timezone set the test always concludes that the timezone changed an the countdown has to be restarted.

There is also a workaround for this. You can grab the current timezone from the options and reapply that together with the actual change intended like this:

let timezone = $('#defaultCountdown').countdown('option', 'timezone');
$('#defaultCountdown').countdown('option', { format: 'YODHMS', timezone: timezone });

Thanks for the great component! My team is using it in an E-Assessment system at the university of Duisburg-Essen and it works great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions