react-countup
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -7,3 +7,2 @@ 'use strict'; | ||
var CountUp = _interopDefault(require('countup.js')); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
@@ -13,2 +12,3 @@ var React = require('react'); | ||
var warning = _interopDefault(require('warning')); | ||
var CountUp = _interopDefault(require('countup.js')); | ||
@@ -52,16 +52,31 @@ function _classCallCheck(instance, Constructor) { | ||
function _objectSpread(target) { | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
if (i % 2) { | ||
ownKeys(source, true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(source).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
@@ -199,3 +214,3 @@ | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "createInstance", function () { | ||
_defineProperty(_assertThisInitialized(_this), "createInstance", function () { | ||
if (typeof _this.props.children === 'function') { | ||
@@ -209,4 +224,4 @@ // Warn when user didn't use containerRef at all | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "pauseResume", function () { | ||
var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)), | ||
_defineProperty(_assertThisInitialized(_this), "pauseResume", function () { | ||
var _assertThisInitialize = _assertThisInitialized(_this), | ||
reset = _assertThisInitialize.reset, | ||
@@ -227,4 +242,4 @@ start = _assertThisInitialize.restart, | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "reset", function () { | ||
var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)), | ||
_defineProperty(_assertThisInitialized(_this), "reset", function () { | ||
var _assertThisInitialize2 = _assertThisInitialized(_this), | ||
pauseResume = _assertThisInitialize2.pauseResume, | ||
@@ -245,3 +260,3 @@ start = _assertThisInitialize2.restart, | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "restart", function () { | ||
_defineProperty(_assertThisInitialized(_this), "restart", function () { | ||
_this.reset(); | ||
@@ -252,4 +267,4 @@ | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "start", function () { | ||
var _assertThisInitialize3 = _assertThisInitialized(_assertThisInitialized(_this)), | ||
_defineProperty(_assertThisInitialized(_this), "start", function () { | ||
var _assertThisInitialize3 = _assertThisInitialized(_this), | ||
pauseResume = _assertThisInitialize3.pauseResume, | ||
@@ -290,4 +305,4 @@ reset = _assertThisInitialize3.reset, | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "update", function (newEnd) { | ||
var _assertThisInitialize4 = _assertThisInitialized(_assertThisInitialized(_this)), | ||
_defineProperty(_assertThisInitialized(_this), "update", function (newEnd) { | ||
var _assertThisInitialize4 = _assertThisInitialized(_this), | ||
pauseResume = _assertThisInitialize4.pauseResume, | ||
@@ -308,3 +323,3 @@ reset = _assertThisInitialize4.reset, | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "containerRef", React__default.createRef()); | ||
_defineProperty(_assertThisInitialized(_this), "containerRef", React__default.createRef()); | ||
@@ -339,2 +354,3 @@ return _this; | ||
if (this.props.duration !== prevProps.duration || this.props.start !== prevProps.start) { | ||
this.instance.reset(); | ||
this.instance = this.createInstance(); | ||
@@ -347,3 +363,6 @@ this.start(); | ||
if (this.props.end !== prevProps.end) { | ||
this.instance.reset(); | ||
if (!this.props.preserveValue) { | ||
this.instance.reset(); | ||
} | ||
this.instance.update(this.props.end); | ||
@@ -410,3 +429,4 @@ } | ||
style: PropTypes.object, | ||
useEasing: PropTypes.bool | ||
useEasing: PropTypes.bool, | ||
preserveValue: PropTypes.bool | ||
}); | ||
@@ -432,3 +452,4 @@ | ||
style: undefined, | ||
useEasing: true | ||
useEasing: true, | ||
preserveValue: false | ||
}); | ||
@@ -441,3 +462,3 @@ | ||
var useCountUp = function useCountUp(props) { | ||
var _props = _objectSpread({}, CountUp$1.defaultProps, props); | ||
var _props = _objectSpread2({}, CountUp$1.defaultProps, {}, props); | ||
@@ -444,0 +465,0 @@ var start = _props.start, |
{ | ||
"name": "react-countup", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "A React component wrapper around CountUp.js", | ||
@@ -39,19 +39,19 @@ "author": "Glenn Reyes <glenn@glennreyes.com> (https://twitter.com/glnnrys)", | ||
"devDependencies": { | ||
"@babel/core": "^7.1.2", | ||
"@babel/plugin-proposal-class-properties": "^7.1.0", | ||
"@babel/preset-env": "^7.1.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^23.6.0", | ||
"husky": "^3.0.0", | ||
"jest": "^24.8.0", | ||
"prettier": "^1.14.3", | ||
"pretty-quick": "^1.8.0", | ||
"raf": "^3.4.0", | ||
"react": "^16.8.1", | ||
"react-dom": "^16.8.1", | ||
"react-testing-library": "^5.4.4", | ||
"rollup": "^0.66.6", | ||
"rollup-plugin-babel": "^4.0.3" | ||
"@babel/core": "7.5.5", | ||
"@babel/plugin-proposal-class-properties": "7.5.5", | ||
"@babel/preset-env": "7.5.5", | ||
"@babel/preset-react": "7.0.0", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-jest": "23.6.0", | ||
"husky": "3.0.2", | ||
"jest": "24.8.0", | ||
"prettier": "1.18.2", | ||
"pretty-quick": "1.11.1", | ||
"raf": "3.4.1", | ||
"react": "16.8.6", | ||
"react-dom": "16.8.6", | ||
"react-testing-library": "5.4.4", | ||
"rollup": "0.68.2", | ||
"rollup-plugin-babel": "4.3.3" | ||
} | ||
} |
@@ -39,2 +39,3 @@ # [React CountUp](https://react-countup.now.sh) | ||
- [`redraw: boolean`](#redraw-boolean) | ||
- [`preserveValue: boolean`](#preservevalue-boolean) | ||
- [`separator: string`](#separator-string) | ||
@@ -237,2 +238,8 @@ - [`start: number`](#start-number) | ||
#### `preserveValue: boolean` | ||
Save previously ended number to start every new animation from it. | ||
Default: `false` | ||
#### `separator: string` | ||
@@ -239,0 +246,0 @@ |
26211
475
328