Open simeneilevstjonn opened 3 years ago
Can you provide any reproduced cases?
I'm using the snippets for countdown, it's working fine for 2 seconds countdown to 0
` function date(offset = 0) { return new Date(new Date().setSeconds(new Date().getSeconds() + offset)); }
let clock = new FlipClock(el, () => date(2), { face: 'MinuteCounter', autoStart: true, countdown: true, stopAt: () => date(0), }); `
I have tried
const clock = new FlipClock(elem, new Date(new Date().getTime()+5000), {
face: "DayCounter",
countdown: true,
stopAt: new Date(new Date().getTime()+5000)
});
and
const clock = new FlipClock(elem, new Date(new Date().getTime()+5000), {
face: "DayCounter",
countdown: true,
stopAt: 0
});
Both of them stopped immediately. After having seen your code, I tried:
const clock = new FlipClock(elem, new Date(new Date().getTime()+5000), {
face: "DayCounter",
countdown: true,
stopAt: new Date()
});
This did work, but it is rather counter-intuitive. When it is named "stopAt", it makes the most sense that it is the date or face value when it stops, just like it is for non-countdowns.
If the
stopAt
attribute is present in a countdown instance, it will immediately stop. This is likely because theshouldStop
method looks at the value of the clock face, which itself is counting down from theoriginalValue
, which is the wanted stop time for a countdown. This means that thestopAt
time always will be greater than the face value, thus causingshouldStop
to return true.