react-countup
Advanced tools
Comparing version 4.2.6 to 4.3.0
@@ -441,2 +441,3 @@ 'use strict'; | ||
start: PropTypes.number, | ||
startOnMount: PropTypes.bool, | ||
suffix: PropTypes.string, | ||
@@ -464,2 +465,3 @@ style: PropTypes.object, | ||
start: 0, | ||
startOnMount: true, | ||
suffix: '', | ||
@@ -564,19 +566,24 @@ style: undefined, | ||
onStart = _props.onStart, | ||
onEnd = _props.onEnd; | ||
var timeout = setTimeout(function () { | ||
onStart({ | ||
pauseResume: pauseResume, | ||
reset: reset, | ||
update: update | ||
}); | ||
getCountUp().start(function () { | ||
clearTimeout(timeout); | ||
onEnd({ | ||
onEnd = _props.onEnd, | ||
startOnMount = _props.startOnMount; | ||
if (startOnMount) { | ||
var timeout = setTimeout(function () { | ||
onStart({ | ||
pauseResume: pauseResume, | ||
reset: reset, | ||
start: restart, | ||
update: update | ||
}); | ||
}); | ||
}, delay * 1000); | ||
getCountUp().start(function () { | ||
clearTimeout(timeout); | ||
onEnd({ | ||
pauseResume: pauseResume, | ||
reset: reset, | ||
start: restart, | ||
update: update | ||
}); | ||
}); | ||
}, delay * 1000); | ||
} | ||
return reset; | ||
@@ -583,0 +590,0 @@ }, []); |
import * as React from 'react'; | ||
export interface RenderCounterProps { | ||
countUpRef: React.RefObject<any>; | ||
start?: () => void; | ||
pauseResume?: () => void; | ||
reset?: () => void; | ||
update?: (newEnd?: number) => void; | ||
} | ||
export interface CountUpProps { | ||
@@ -24,2 +32,3 @@ className?: string; | ||
onUpdate?: ({ pauseResume, reset, start }) => void; | ||
children?: (props: RenderCounterProps) => JSX.Element; | ||
} | ||
@@ -30,2 +39,3 @@ | ||
export interface useCountUpProps { | ||
startOnMount?: boolean; | ||
start?: number; | ||
@@ -46,7 +56,6 @@ end: number; | ||
countUp: number | string; | ||
onReset: () => void; | ||
nUpdate: () => void; | ||
onPauseResume: () => void; | ||
onStart: ({ pauseResume }) => void; | ||
onEnd: ({ pauseResume }) => void; | ||
start: () => void; | ||
pauseResume: () => void; | ||
reset: () => void; | ||
update: (newEnd?: number) => void; | ||
}; | ||
@@ -53,0 +62,0 @@ |
{ | ||
"name": "react-countup", | ||
"version": "4.2.6", | ||
"version": "4.3.0", | ||
"description": "A React component wrapper around CountUp.js", | ||
@@ -45,3 +45,4 @@ "author": "Glenn Reyes <glenn@glennreyes.com> (https://twitter.com/glnnrys)", | ||
"@babel/preset-react": "7.7.4", | ||
"@testing-library/react": "9.3.2", | ||
"@testing-library/react": "9.4.0", | ||
"@testing-library/react-hooks": "^3.2.1", | ||
"babel-jest": "24.9.0", | ||
@@ -55,5 +56,6 @@ "husky": "3.1.0", | ||
"react-dom": "16.12.0", | ||
"rollup": "1.27.9", | ||
"react-test-renderer": "^16.12.0", | ||
"rollup": "1.27.12", | ||
"rollup-plugin-babel": "4.3.3" | ||
} | ||
} |
@@ -42,2 +42,3 @@ # [React CountUp](https://react-countup.now.sh) | ||
- [`start: number`](#start-number) | ||
- [`startOnMount: boolean`](#startonmount-boolean) | ||
- [`suffix: string`](#suffix-string) | ||
@@ -254,2 +255,8 @@ - [`useEasing: boolean`](#useeasing-boolean) | ||
#### `startOnMount: boolean` | ||
Use for start counter on mount for hook usage. | ||
Default: `true` | ||
#### `suffix: string` | ||
@@ -256,0 +263,0 @@ |
29576
559
335
17