stopAt attribute does not work for countdowns
simeneilevstjonn opened this issue · 2 comments
If the stopAt
attribute is present in a countdown instance, it will immediately stop. This is likely because the shouldStop
method looks at the value of the clock face, which itself is counting down from the originalValue
, which is the wanted stop time for a countdown. This means that the stopAt
time always will be greater than the face value, thus causing shouldStop
to return true.
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.