Package Exports
- bill-counter-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bill-counter-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Description
The bill counter effect is expressed in JavaScript.
See API Docs for details.
Required
This library does not require any other libraries in production.
In development, we bundled with webpack.
Installation
Local
CDN
NPM
yarn add bill-counter-js
or
npm install bill-counter-js -S
How to use
NOTE
You must run the function after 'DOMContentLoaded' event.
Similar to jquery's $(document).ready().
DOMContentLoaded is a web standard and jQuery is not a web standard.
Browser
<script src="{path}/bill-counter.min.js"></script>
$B.countByN('selector-id', targetMoney, N, interval);
see example source
ESM
import { $B } from '{path}/bill-counter.esm.min.js';
$B.countByN('selector-id', targetMoney, N, interval);
see example source
Common JS
const { $B } = require('bill-counter-js');
$B.countByN('selector-id', targetMoney, N, interval);
API Documents
1. Count by N
$B.countByN(id, end, n, interval = 0.1);
Count the numbers by n.
Perhaps most similar to the counter.
2. Fast counting
$B.countFast(id, end, duration = 100);
Count any number in a certain amount of time.
I think it will be very effective as an animation.
3. Locale Setting (Formatting)
// default
$B.localeOptions = {
format: true,
locale: 'en-US',
currency: 'USD',
}
format: Do you format in currency? (true = yes)
locale: What language do you speak? (Learn More)
currency: What currency are you using? (Learn More)
4. Define your formatter
The default formatter uses the ECMAScript Internationalization API. (INTL) If you don't like this, define your own formatter.
$B.formatStyler = (number) => {
// your formatter!
}
If you want to change back to the default style,
run $B.formatStyler = $B.defaultFormatStyler;
Library demo
Try the demo here.