Animates a number in the DOM by counting up or down.
npm install --save @surveyplanet/animation_counter
import 'animationCounter' from '@surveyplanet/animation_counter
const el = document.getElementById('#counter');
animationCounter(el, {
startVal: 5,
endVal: 1000000,
interval: 1,
step: 3000,
localize: 'de-DE',
});
Param | Type | Description |
---|---|---|
el | HTMLElement | String |
The element you want to update. You may pass in an HTMLElement or an ID or class name. |
options | options |
Counter options. |
optinos.step | Number |
The amount that the number will increase by each interval. |
optinos.startVal | Number |
The number that the counter will start at. |
optinos.endVal | Number |
The number that the counter will end at. |
optinos.interval | Number |
The time in millisecond between each step. |
optinos.localize | Number |
The language code for the number to be localized to. For example, 'en-US' for US English, 'de-de' for German, 'fr-fr' for French, etc. The default for this parameter is empty, meaning that your dots and comas won't be displayed at all. Leave this empty if you want the number to be displayed as is. |
npm install
npm run test