Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stopAt attribute does not work for countdowns #417

Open
simeneilevstjonn opened this issue Apr 5, 2021 · 2 comments
Open

stopAt attribute does not work for countdowns #417

simeneilevstjonn opened this issue Apr 5, 2021 · 2 comments

Comments

@simeneilevstjonn
Copy link

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.

@ericchan3721
Copy link

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),
});
`

@simeneilevstjonn
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants