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

Allow count down timer to go negative #94

Closed
jfloodnet opened this issue Sep 11, 2020 · 2 comments · Fixed by #100
Closed

Allow count down timer to go negative #94

jfloodnet opened this issue Sep 11, 2020 · 2 comments · Fixed by #100

Comments

@jfloodnet
Copy link

Current behaviour: once the timer is complete, the values passed to renderer remain at 0.

I have a use case that would essentially need the timer to go into "overtime" e.g. imagine a timer counting down to full time in the football, if the game goes in to overtime, I'd like to display a negative counter e.g. -1m 23s. Essentially this means the counter is now counting "up" passed end date.

    <Countdown date={game.fullTime)}
                    renderer={({minutes, seconds, completed}) => {
                      return <span class="timer"> {!game.inplay? "Whistle blown" : `${minutes}m ${seconds}s`}</span>
                    }
                  }/>
@ndresx
Copy link
Owner

ndresx commented Oct 3, 2020

Thanks for your message and this suggestion. I like the idea and will consider adding this at some point in v3, but for now, I don't think it's possible to do that given how the countdown currently works.

You might be able to customize the renderer function in a way to go into this "overtime", but you would have to implement that logic on your own, where your previous end date would essentially become your new start date (e.g. an interval could be started to update it on a second-basis). You could then use one of the util functions to calculate the time parts to display it in your preferred way.

PS: If you or someone else wants to see this functionality in v2 already, we could discuss the details of how to implement it in a more generic way and you could try to add it, otherwise, this will be something for v3+!

@ndresx ndresx self-assigned this Oct 10, 2020
@ndresx ndresx mentioned this issue Oct 11, 2020
@ndresx
Copy link
Owner

ndresx commented Oct 13, 2020

This option is now available in the latest version, thanks for the idea and your input on it!

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

Successfully merging a pull request may close this issue.

2 participants