Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,11 @@ A function that triggers when text state has updated.
#### `onFinish: () => void`(optional)

A function that triggers when animation completes.

#### `startAt: number`(optional, default to `0`)

Timeout in milliseconds to start animation after.

#### `initialValue: number`(optional, default to `0`)

A value to start animation from
49 changes: 49 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
declare module 'react-native-animate-number' {
export interface IAnimateNumberProps {
/**
* The value of AnimateNumber component.
*/
value: number;
/**
* Set this property to force the component's value increase/decrease by this number.
*/
countBy?: number;
/**
* Base interval of each animation frame, in ms. Default: `14`
*/
interval?: number;
/**
* Set total frame number of animation, say, if interval is 14 and steps is 30, the animation will take 14x30ms to finish when it uses linear timing function.
* Default: `45`
*/
steps?: number;
/**
* Custom timing function or use a default timing function.
* Default: `linear`
*/
timing?: 'linear' | 'easeOut' | 'easeIn' | ((interval: number, progress: number) => number);
/**
* This prop accepts a function which returns a string as displayed value.
*/
formatter?: (value: number) => string;
/**
* A function that triggers when text state has updated.
* @param currentValue current frame's value
* @param endValue value from props.value
*/
onProgress?: (currentValue: number, endValue: number) => void;
/**
* A function that triggers when animation completes.
*/
onFinish?: (value: number, formattedValue: number) => void;
/**
* Timeout in milliseconds to start animation after. Default: `0`
*/
startAt?: number;
/**
* A value to start animation from. Default: `0`
*/
initialValue?: number;
}
export default class AnimateNumber extends React.Component<IAnimateNumberProps> {}
}
7 changes: 2 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
// @flow

import React, { Component } from 'react';
import {
Text,
View
} from 'react-native';
import { Text } from 'react-native';
import Timer from 'react-timer-mixin';

const HALF_RAD = Math.PI/2
Expand Down Expand Up @@ -99,7 +96,7 @@ export default class AnimateNumber extends Component {
, this.props.startAt != null ? this.props.startAt : 0);
}

componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps) {

// check if start an animation
if(this.props.value !== nextProps.value) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-animate-number",
"version": "0.1.2",
"version": "0.1.3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down