Skip to content

emn178/countUp.js-angular2

 
 

Repository files navigation

CountUp.js Angular ^2 Module

This is an Angular directive wrapper around the core functionality of CountUp which is maintained in the CountUp.js repo. MIT License.

Or see this angular version work by cloning this project and running ng serve.

Usage

Install the package in your project:

yarn add countup.js-angular2 or npm i countup.js-angular2

In app.module.ts, import the module:

import { CountUpModule } from 'countup.js-angular2';

@NgModule({
  imports: [
    ...
    CountUpModule
  ],
  ...
})

Use it in your markup. Since it's a directive, it can be added to any element:

<h1 [countUp]="345" (complete)="doSomethingOnComplete()">0</h1>

Defer animation

Bind the endVal to some property. Leave it undefined and the animation won't start until endVal has a value.

<h1 [countUp]="myEndVal" [options]="myOpts">0</h1>

Inputs:

  • countUp: number to count to
  • options: CountUpOptions - fine-grain control over CountUp
  • reanimateOnClick: pass false to disable (defaults to true)

Outputs:

  • complete: emits when the animation completes

Contributing

Before you make a pull request, please follow these instructions:

  1. Make your edits to ./projects/count-up/src/lib/count-up.directive.ts.
  2. Run ng s and test your changes in the demo app.

Publishing (you don't need to do this, it’s for my own reference):

  1. Increment the version number if necessary (and install-tarball script).
  2. Commit changes.
  3. Run yarn package:countup which builds and packs a tarball.
  4. Install the tarball in the test app: yarn install-tarball.
  5. Make app.module import from newly installed package.
  6. Run the test app with AOT compiler and make sure the demo works: ng serve --prod.
  7. Run npm publish dist/count-up
  8. Discard changes.

About

Animates a numerical value by counting to it - for Angular

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 71.3%
  • JavaScript 22.4%
  • HTML 5.6%
  • CSS 0.7%