Jump to content
Search Community

Simple countdown Timer class

swampthang test
Moderator Tag

Recommended Posts

I needed a simple countdown timer class and have seen a few posts here over the last few years, including the awesome timer animation by Greensock here - 

See the Pen qBjGZaE by GreenSock (@GreenSock) on CodePen

 

But I just needed something simple and reusable.

 

This community has been so good to me over the years and I've not been the most contributive member. I created this class yesterday and wanted to share it in case anyone needs this kind of thing. It could use some refactoring so it's probably a tad bloated but it's a good starter class.

 

You can pass the total number of seconds you want the timer to run, the container into which you want the timer to appear, a start callback and an end callback. 

 

I did use a few Bootstrap css classes so if you don't want to use that, just style the css as you like. I also used a google font for the timer text.

 

I hope this helps anyone in need of a simple timer.

 

Thanks again for all the help over the years.

See the Pen 07b7c57c6c2eaa6dd326924261682109 by swampthang (@swampthang) on CodePen

Edited by swampthang
forgot to mention the google font
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...