Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

countup.js

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

countup.js

Animates a numerical value by counting to it

  • 1.9.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is countup.js?

countup.js is a lightweight JavaScript library that allows you to create animated counting numbers. It is useful for creating dynamic and engaging number displays in web applications, such as statistics, counters, and other numerical data visualizations.

What are countup.js's main functionalities?

Basic Count Up

This feature allows you to animate a number counting up from zero to a specified value. In this example, the number will count up to 1000 and display in the element with the ID 'targetElement'.

const countUp = new CountUp('targetElement', 1000);
if (!countUp.error) {
  countUp.start();
} else {
  console.error(countUp.error);
}

Custom Start and End Values

This feature allows you to specify custom start and end values for the count up animation. In this example, the number will count up from 500 to 2000.

const countUp = new CountUp('targetElement', 2000, { startVal: 500 });
if (!countUp.error) {
  countUp.start();
} else {
  console.error(countUp.error);
}

Formatting Options

This feature allows you to format the number with options such as decimal places, prefixes, and suffixes. In this example, the number will be formatted with two decimal places and display as currency (e.g., $1000.00 USD).

const countUp = new CountUp('targetElement', 1000, { decimalPlaces: 2, prefix: '$', suffix: ' USD' });
if (!countUp.error) {
  countUp.start();
} else {
  console.error(countUp.error);
}

Easing Functions

This feature allows you to apply custom easing functions to the count up animation. In this example, a quadratic easing function is used to create a smooth animation effect.

const countUp = new CountUp('targetElement', 1000, { easingFn: function (t, b, c, d) { return c * (t /= d) * t + b; } });
if (!countUp.error) {
  countUp.start();
} else {
  console.error(countUp.error);
}

Other packages similar to countup.js

FAQs

Package last updated on 07 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc