GithubHelp home page GithubHelp logo

countup's Introduction

CountUp npm

Easily animate numbers.

Installation

npm install --save @firstandthird/countup

Usage

CountUp has two exports. default one is a Domodule library and there's a named export by animateNumber which the Domodule library leverages.

animateNumber

This function takes an object with the following keys:

Option Type Default Description
target Number N/A The number you intend to reach by the end of the animation.
start Number 0 The number the animation starts from.
duration Number N/A The amount of ms the animation should take.
callback Function Noop Function Function to be called once the animation finishes.
interval Function N/A Function to be called with every interval. Useful to update the DOM.

Example

import { animateNumber } from '@firstandthird/countup';

animateNumber({
  target: 20,
  interval: value => {
    someElement.innerHTML = value;
  }
});

CountUp module

CountUp has a module that can be used in the DOM and that also plays nice with ScrollTriggers.

Option Default Description
target N/A Has to be defined The number you intend to reach by the end of the animation.
start 0 The number the animation starts from.
duration N/A The amount of ms the animation should take.
template '$D' Template to be used to format the number. $D will be replaced with the number. You could use $D% to animate a percent for example.

Example

<div data-module="Countup"
     data-module-target="20"
     data-module-template="$D%"></div>

See examples for more usage examples.

countup's People

Contributors

alejandroperezmartin avatar antonio-laguna avatar

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.