Git Product home page Git Product logo

angular-countdown's Introduction

angular-countdown Build Status

Radial countdown component for Angular built with SVG.

angular-countdown example with terrible frame rate

Installing

# npm
npm install angular-countdown
# bower
bower install angular-countdown
angular.module('myApp', [
  require('angular-countdown')
]);
// or with script tags
angular.module('myApp', [
  'countdown'
]);

API

angular-countdown provides two interfaces designed to be used together:

  1. A CountdownTimer service which you'll typically inject into your controllers to create new timers
  2. A <countdown> directive which consumes the CountdownTimer instances you'll create

CountdownTimer

new CountdownTimer(length [, options])

Creates a new countdown timer with the given length (milliseconds). options may include:

tickInterval: a Number that specifies how often to update the radial countdown in milliseconds. Defaults to 15.

A CountdownTimer is an EventEmitter.

timer.start() -> timer

Starts the timer. At each interval (as defined by options.tickInterval), the timer will emit a 'tick' event with one argument: the proportion of the tick to the length. So if you start a timer for 1.5 seconds, ticking every 15ms, each tick is 15/1500 or 1/100.

When the length has passed, the timer will emit a 'done' event.

timer.cancel() -> timer

Cancels the timer and cleans up the $interval backing it. Emits a 'done' event.

<countdown>

<countdown timer="timer" radius="15" stroke="5"></countdown>

The <countdown> directive accepts three parameters: the timer to bind to, the radius of the timer circle, and the width of the stroke. It builds the SVG needed to create the radial timer effect.

For an example, run npm run example.

Credits

Inspired by svgPieTimer.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.