mlinquan/vue-awesome-countdown

Remaining time is not preserved on "switchCountdown" when "leftTime" is used.

Closed this issue · 6 comments

I am using this library on a project and I noticed that calling the stopCountdown() method stops the countdown. When I start the countdown again, the time passed is taken into account

This is observable also in the demo page https://vac.js.org/examples/methods/all-methods.html.
Just click on stop, wait for some time, and click start again.

I could just not render the component as a work around, e.g. v-if="isCounting" instead of using the stopCountdown() method

Originally posted by @bi6o in #8 (comment)

Thank you for your rp.
The issue was fixed in version 1.0.14.

I think line number 133 in src/vue-awesome-countdown.vue is causing the same issue, it should be

vm.remainingTime = new Date(vm.actualEndTime).getTime() - new Date().getTime()

what do you think?

I think line number 133 in src/vue-awesome-countdown.vue is causing the same issue, it should be

vm.remainingTime = new Date(vm.actualEndTime).getTime() - new Date().getTime()

what do you think?

I think both methods can be used.
Your code is more concise.
I may use your method in the next version.
Thanks again.

Your method doesn't take into account that the timer might be paused (i.e. stopped then started again after some time), because you're calculating the remainingTime based on the actualStartTime which never changes (once the timer has restarted), unlike the actualEndTime which is changed everytime the timer is started/resumed.. and that's the subject of this issue; to handle the pause feature.

bi6o commented

I can confirm that the issue is not resolved in the new version, and again it is observable only in the test page that you provide https://vac.js.org/examples/methods/all-methods.html.

Pause is added in the new version. You can try the new version 1.0.18.
vac.pauseCountdown()