1.1.0 • Published 7 years ago

count-js v1.1.0

Weekly downloads
2
License
GPL-2.0
Repository
github
Last release
7 years ago

CountJS

Build Status

Module to add counter to your website.

This module is a library to embed counter (count-up) on your website.

Install

How to get the module into your application

$ npm install --save count-js

Setup

The module is developed for in-browser usage and node module usage. For browser usage you just require the package as follows.

<script type="text/javascript" src="dist/counter.js"></script>
<script>
var counter = new Counter();
</script>

For programmatic usage you require the package as known from other node modules.

var counter = require('count-js');

Usage

The API usage is for both cases after that the same.

counter
    .animate() // set to have a count up shown
    .count(3) // the number to which to count
    .in(100) // in which timeframe the counting should be done
    .onUpdate(
        function (newNumber) {
            console.log(newNumber); 
        }
    )
    .onDone(
        function () {
            console.log('Done');
        }
    )
    .run(); // execute

Since the library is based on distribute-js the same limits apply here. The counting callback frequency can exceed the number of milliseconds set to be the timelimit, the time limit will then simply be ignored.

Also in case the result is rendered somewhere it can be that the set timeframe isn't to be seen as a fixed limit either, due to the fact that a paint process takes time aswell.

API

  • count({integer}) - Method to set the max number the counter should be counting to
  • in({integer}) - Method to set the timelimit in which the counting should be done (requires milliseconds)
  • animate() - Method to enable a visible up-counting process
  • onUpdate({function}) - Method to set the update callback, called after each countup (e.g. to handle visible elements)
  • onDone({function}) - Method to set the end callback, called after the counting is done
  • run() - Method to execute the counting up process
1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.4

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago