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

Add onEnd and triggerEnd options to trigger an event when the counter ends #7

Merged
merged 3 commits into from Dec 29, 2017

Conversation

CristianCantoro
Copy link
Contributor

@CristianCantoro CristianCantoro commented Dec 28, 2017

As per the commit title, I have added two options:

  • onEnd: expects a function that is triggered when the counter reaches the end. The default does nothing. A typical use is hiding the counter and showing a different - previously invisible - element of the page. This gives the effect of something appearing when the countdown ends. Here's an example:
$('#counter').countdownCube( {
  target: '2018-12-03T11:00:00Z',
  onEnd: function(e) {
           $('#counter').hide();
           $('#after').show();
         },
  } );
  • triggerEnd: the default is false, if set to true triggers the onEnd function even after the countdown has expired. Otherwise, the counter shows the word LOADING....

@CristianCantoro
Copy link
Contributor Author

I have also fixed an inconsistency in the behavior of the counter: when it reached zero it actually stopped at 00:00:01 (1 second) and did nothing if onEnd was not set. On the other end if the page was loaded and now > target (i.e. target is in the past), then the word LOADING... was displayed.

Now, in both cases, the counter is set to 0 when now > target. if onEnd and triggerEnd are set, the counter behaves accordingly.

@oofaish oofaish merged commit 12d4e93 into oofaish:master Dec 29, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants