# js-number-animation

> 数字变化动画

Latest version **1.1.1** (published 2021-11-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install js-number-animation
pnpm add js-number-animation
yarn add js-number-animation
bun add js-number-animation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-11-23 |
| First published | 2021-11-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zhangjicheng |
| Maintainers | zhangjicheng |
| Keywords | number, animation, javascript |

## Links

- npm: https://www.npmjs.com/package/js-number-animation
- Repository: https://github.com/zhangjichengcc/jsTools
- Homepage: https://github.com/zhangjichengcc/jsTools/tree/main/packages/js-number-animation#readme
- Issues: https://github.com/zhangjichengcc/jsTools/issues
- npm.io page: https://npm.io/package/js-number-animation

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-11-23
- 1.1.0 — 2021-11-23
- 1.0.0 — 2021-11-22

## README

<h2 align="center" style="margin: 30px 0 35px;">Number Animation</h2>

<p align="center">
  <a href="https://www.npmjs.com/package/js-number-animation"><img alt="npm" src="https://img.shields.io/npm/v/js-number-animation"></a>
  <a href="https://github.com/zhangjichengcc/jsTools/tree/main/packages/js-number-animation"><img alt="NPM" src="https://img.shields.io/npm/l/js-number-animation"></a>
</p>

<p align="center">
  <a href="./README.md">English</a> | <a href="./README.zh-CN.md">中文</a>
</p>

> Digital change animation

---

## Usage

``` js
const numberAnimation = require('js-number-animation');

import NumberAnimation from 'js-number-animation';

// use

const numAmt = new NumberAnimation({
  begin = 100;
  during = 300;
})

numAmt.change(function(value) {
  console.log(value);
})

numAmt.finally(function(obj) {

})

numAmt.start(200);

```

## description

### NumberAnimation config

|name|description|default|type|
|-|-|-|-|
|begin|begin number|0|number|
|during|during time|300(ms)|number|
|step|Variable Delta|'auto'|'auto'/number|
|decimals|decimal digit|-|number|

### methods

``` js
numberAnimation.onChange(fn: Function) // Triggered on change

numberAnimation.setBegin(num: number) // Set begin number

numberAnimation.getValue() // Get current end value

numberAnimation.finally(obj: NumberAnimation) // Trigger at end

numberAnimation.start(num: number) // Specify the end value and execute the method
```

## tips

- ~~Value must be an integer~~

- We have calculated the optimal configuration based on the value,Unnecessary, don't customize step

- At the end, the start of the object is the end value, which can be called in a chain.

``` js
var numberAnimation = new NumberAnimation();
numberAnimation.onChange(v => console.log(v));
numberAnimation.finally(obj => {
  let value = obj.getValue();
  if (value < 1000) {
    obj.start(value += 100);
  }
})
numberAnimation.start(100);
```

## Historical version

- v1.0.0:
  - Basic version

- v1.1.0:
  - Solve known problems
  - Supports negative numbers and decimals

---
_Source: https://npm.io/package/js-number-animation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
