Skip to content

ad-si/countdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Countdown

A flip-clock countdown to an arbitrary target date, written in dependency-free, modern JavaScript.

Screenshot of the countdown showing 232:10:26:55

Usage

Serve the directory with any static file server, e.g.:

python3 -m http.server 8765

then open http://localhost:8765/.

Change the target date by editing the data-target attribute on the <html> element in index.html:

<html lang="en" data-target="2027-01-01T00:00">

Any value accepted by new Date() works.

Programmatic use

countdown.js is an ES module that exports a Countdown class:

import { Countdown } from "./countdown.js"

const clock = new Countdown("2027-01-01T00:00", document.getElementById("countdown"))
clock.start()
// clock.stop()

The constructor builds the DOM inside the given container. The display is laid out as DDD:HH:MM:SS (days, hours, minutes, seconds).

Files

  • index.html — entry markup, loads index.js as a module
  • index.js — boots the countdown
  • countdown.jsCountdown class with the flip animation logic
  • style.css — visual styles
  • img/ — the digit images (up_0.pngup_9.png, down_0.pngdown_9.png), background, and favicon

About

Countdown animation in the style of a flip clock

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors