use-count-up
Advanced tools
Comparing version 2.1.2 to 2.1.3
# Change Log | ||
## 2.1.3 (June 3rd, 2020) | ||
**Big fix:** | ||
- Fix: upgrade use-elapsed-time to 2.1.4 which fixes an issue where pausing the animation once it is completed, resetting the timer and playing again it did not work. | ||
## 2.1.2 (June 1st, 2020) | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -24,3 +24,3 @@ import { CountUpProps } from '../types'; | ||
fallbackSuffix: PropTypes.Requireable<string>; | ||
autoResetKey: PropTypes.Requireable<string | number>; | ||
autoResetKey: PropTypes.Requireable<React.ReactText>; | ||
easing: PropTypes.Requireable<string | ((...args: any[]) => any)>; | ||
@@ -27,0 +27,0 @@ onComplete: PropTypes.Requireable<(...args: any[]) => any>; |
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("react")},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=r(1)},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return i}));var n=r(0);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,u=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,u=t.onComplete,i=t.startAt,c=void 0===i?0:i,f=t.autoResetKey,l=Object(n.useState)(c),s=o(l,2),d=s[0],p=s[1],m=Object(n.useRef)(-1e3*c),b=Object(n.useRef)(null),y=Object(n.useRef)(null),v=Object(n.useRef)(null),g=Object(n.useRef)(!0),O=Object(n.useRef)(!1),S=Object(n.useRef)(0),j=Object(n.useCallback)((function(e){S.current+=1,p("number"==typeof e?e:c)}),[]),x=function e(t){var n=t/1e3;if(null===y.current)return y.current=n,void(b.current=requestAnimationFrame(e));var o=n-y.current;if(y.current=n,p((function(e){var t=e+o;return"number"!=typeof r||t<r?t:(O.current=!0,r)})),O.current){if("function"==typeof u){m.current+=1e3*r;var i=m.current/1e3,a=u(i)||{},c=a.shouldRepeat,f=void 0!==c&&c,l=a.delay,s=void 0===l?0:l,d=a.newStartAt;f&&(v.current=setTimeout((function(){j(d)}),1e3*s))}}else b.current=requestAnimationFrame(e)},h=function(){cancelAnimationFrame(b.current),clearTimeout(v.current),y.current=null};return a((function(){return e&&(b.current=requestAnimationFrame(x)),h}),[e]),a((function(){e&&!g.current&&(h(),b.current=requestAnimationFrame(x))}),[r]),a((function(){g.current||j()}),[f]),a((function(){e&&O.current&&(O.current=!1,h(),b.current=requestAnimationFrame(x))}),[S.current]),a((function(){g.current=!1}),[]),{elapsedTime:d,reset:j}},a="undefined"==typeof window?n.useEffect:n.useLayoutEffect}])},function(e,t,r){"use strict";r.r(t),r.d(t,"useCountUp",(function(){return a})),r.d(t,"CountUp",(function(){return y}));var n=r(2),o={easeInCubic:function(e,t,r,n){return r*(e/=n)*e*e+t},easeOutCubic:function(e,t,r,n){return e/=n,r*(--e*e*e+1)+t},linear:function(e,t,r,n){return r*e/n+t}},u=o.easeOutCubic,i=function(){var e=function(){try{(0).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}(),t=!("object"!=typeof Intl||!Intl||"function"!=typeof Intl.NumberFormat);return e&&t},a=function(e){var t,r=e.isCounting,i=void 0!==r&&r,a=e.start,c=void 0===a?0:a,f=e.end,l=e.duration,s=e.easing,d=void 0===s?u:s,m=e.onComplete,b=e.autoResetKey,y=function(e,t){if("number"==typeof e)return"number"==typeof t?t:2}(f,l),v=Object(n.useElapsedTime)(i,{duration:y,onComplete:m,autoResetKey:b}),g=v.elapsedTime,O=v.reset;if(0===y&&"number"==typeof f)t=f;else if("number"==typeof f&&"number"==typeof y){t=function(e){return"function"==typeof e?e:o[e]}(d)(g<y?g:y,c,f-c,y)}else t=c+g;return{value:p(t,e),reset:O}},c=r(1),f=r.n(c),l=function(e,t){return e.replace(/\B(?=(\d{3})+(?!\d))/g,t)},s=function(e,t,r){return""+e+t+r},d=function(e){return(e.toString().split(".")[1]||"").length},p=function(e,t){var r=t.start,n=void 0===r?0:r,o=t.end,u=t.decimalPlaces,a=void 0===u?function(e,t){var r=d(e),n=d(t||1);return r>=n?r:n}(n,o):u,f=t.formatter,p=t.decimalSeparator,m=void 0===p?".":p,b=t.thousandsSeparator,y=void 0===b?"":b,v=t.prefix,g=void 0===v?"":v,O=t.suffix,S=void 0===O?"":O,j=t.shouldUseToLocaleString,x=void 0!==j&&j,h=t.toLocaleStringParams,T=t.fallbackPrefix,P=void 0===T?"":T,A=t.fallbackSuffix,C=void 0===A?"":A,R=Object(c.useMemo)((function(){return i()}),[]),M=function(){if(0===a){var t=Math.round(e).toString();return l(t,y)}var r=e.toFixed(a).split("."),n=r[0],o=r[1];return""+l(n,y)+m+o};if("function"==typeof f)return f(e);if(x){var _=function(e,t){return 0===t?Math.round(e):parseFloat(e.toFixed(t))}(e,a);if(void 0===h){var F=_.toLocaleString();return s(g,F,S)}if(R)try{var w=h.locale,L=h.options,q=_.toLocaleString(w,L);return s(g,q,S)}catch(e){console.error(e.message)}var E=M();return s(P,E,C)}var I=M();return s(g,I,S)},m=r(0),b=r.n(m),y=function(e){var t=e.children,r=a(e);return f.a.createElement(f.a.Fragment,null,"function"==typeof t?t(r):r.value)};y.displayName="CountUp",y.propTypes={isCounting:b.a.bool,start:b.a.number,end:b.a.number,duration:b.a.number,decimalPlaces:b.a.number,decimalSeparator:b.a.string,thousandsSeparator:b.a.string,prefix:b.a.string,suffix:b.a.string,shouldUseToLocaleString:b.a.bool,toLocaleStringParams:b.a.shape({locale:b.a.oneOfType([b.a.string,b.a.arrayOf(b.a.string)]),options:b.a.object}),fallbackPrefix:b.a.string,fallbackSuffix:b.a.string,autoResetKey:b.a.oneOfType([b.a.string,b.a.number]),easing:b.a.oneOfType([b.a.string,b.a.func]),onComplete:b.a.func,formatter:b.a.func,children:b.a.func}}]); | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("react")},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=r(1)},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return i}));var n=r(0);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,u=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,u=t.onComplete,i=t.startAt,c=void 0===i?0:i,f=t.autoResetKey,l=Object(n.useState)(c),s=o(l,2),d=s[0],p=s[1],m=Object(n.useRef)(-1e3*c),b=Object(n.useRef)(null),y=Object(n.useRef)(null),v=Object(n.useRef)(null),g=Object(n.useRef)(!0),O=Object(n.useRef)(!1),S=Object(n.useRef)(0),j=Object(n.useCallback)((function(e){S.current+=1,p("number"==typeof e?e:c)}),[]),x=function e(t){var n=t/1e3;if(null===y.current)return y.current=n,void(b.current=requestAnimationFrame(e));var o=n-y.current;if(y.current=n,p((function(e){var t=e+o;return"number"!=typeof r||t<r?t:(O.current=!0,r)})),O.current){if("function"==typeof u){m.current+=1e3*r;var i=m.current/1e3,a=u(i)||{},c=a.shouldRepeat,f=void 0!==c&&c,l=a.delay,s=void 0===l?0:l,d=a.newStartAt;f&&(v.current=setTimeout((function(){j(d)}),1e3*s))}}else b.current=requestAnimationFrame(e)},h=function(){cancelAnimationFrame(b.current),clearTimeout(v.current),y.current=null};return a((function(){return e&&(b.current=requestAnimationFrame(x)),h}),[e]),a((function(){e&&!g.current&&(h(),b.current=requestAnimationFrame(x))}),[r]),a((function(){g.current||j()}),[f]),a((function(){e&&O.current&&(h(),b.current=requestAnimationFrame(x)),O.current=!1}),[S.current]),a((function(){g.current=!1}),[]),{elapsedTime:d,reset:j}},a="undefined"==typeof window?n.useEffect:n.useLayoutEffect}])},function(e,t,r){"use strict";r.r(t),r.d(t,"useCountUp",(function(){return a})),r.d(t,"CountUp",(function(){return y}));var n=r(2),o={easeInCubic:function(e,t,r,n){return r*(e/=n)*e*e+t},easeOutCubic:function(e,t,r,n){return e/=n,r*(--e*e*e+1)+t},linear:function(e,t,r,n){return r*e/n+t}},u=o.easeOutCubic,i=function(){var e=function(){try{(0).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}(),t=!("object"!=typeof Intl||!Intl||"function"!=typeof Intl.NumberFormat);return e&&t},a=function(e){var t,r=e.isCounting,i=void 0!==r&&r,a=e.start,c=void 0===a?0:a,f=e.end,l=e.duration,s=e.easing,d=void 0===s?u:s,m=e.onComplete,b=e.autoResetKey,y=function(e,t){if("number"==typeof e)return"number"==typeof t?t:2}(f,l),v=Object(n.useElapsedTime)(i,{duration:y,onComplete:m,autoResetKey:b}),g=v.elapsedTime,O=v.reset;if(0===y&&"number"==typeof f)t=f;else if("number"==typeof f&&"number"==typeof y){t=function(e){return"function"==typeof e?e:o[e]}(d)(g<y?g:y,c,f-c,y)}else t=c+g;return{value:p(t,e),reset:O}},c=r(1),f=r.n(c),l=function(e,t){return e.replace(/\B(?=(\d{3})+(?!\d))/g,t)},s=function(e,t,r){return""+e+t+r},d=function(e){return(e.toString().split(".")[1]||"").length},p=function(e,t){var r=t.start,n=void 0===r?0:r,o=t.end,u=t.decimalPlaces,a=void 0===u?function(e,t){var r=d(e),n=d(t||1);return r>=n?r:n}(n,o):u,f=t.formatter,p=t.decimalSeparator,m=void 0===p?".":p,b=t.thousandsSeparator,y=void 0===b?"":b,v=t.prefix,g=void 0===v?"":v,O=t.suffix,S=void 0===O?"":O,j=t.shouldUseToLocaleString,x=void 0!==j&&j,h=t.toLocaleStringParams,T=t.fallbackPrefix,P=void 0===T?"":T,A=t.fallbackSuffix,C=void 0===A?"":A,R=Object(c.useMemo)((function(){return i()}),[]),M=function(){if(0===a){var t=Math.round(e).toString();return l(t,y)}var r=e.toFixed(a).split("."),n=r[0],o=r[1];return""+l(n,y)+m+o};if("function"==typeof f)return f(e);if(x){var _=function(e,t){return 0===t?Math.round(e):parseFloat(e.toFixed(t))}(e,a);if(void 0===h){var F=_.toLocaleString();return s(g,F,S)}if(R)try{var w=h.locale,L=h.options,q=_.toLocaleString(w,L);return s(g,q,S)}catch(e){console.error(e.message)}var E=M();return s(P,E,C)}var I=M();return s(g,I,S)},m=r(0),b=r.n(m),y=function(e){var t=e.children,r=a(e);return f.a.createElement(f.a.Fragment,null,"function"==typeof t?t(r):r.value)};y.displayName="CountUp",y.propTypes={isCounting:b.a.bool,start:b.a.number,end:b.a.number,duration:b.a.number,decimalPlaces:b.a.number,decimalSeparator:b.a.string,thousandsSeparator:b.a.string,prefix:b.a.string,suffix:b.a.string,shouldUseToLocaleString:b.a.bool,toLocaleStringParams:b.a.shape({locale:b.a.oneOfType([b.a.string,b.a.arrayOf(b.a.string)]),options:b.a.object}),fallbackPrefix:b.a.string,fallbackSuffix:b.a.string,autoResetKey:b.a.oneOfType([b.a.string,b.a.number]),easing:b.a.oneOfType([b.a.string,b.a.func]),onComplete:b.a.func,formatter:b.a.func,children:b.a.func}}]); |
{ | ||
"name": "use-count-up", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "React/React Native component and hook to animate counting up or down to a number", | ||
@@ -36,3 +36,3 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"use-elapsed-time": "^2.1.3" | ||
"use-elapsed-time": "^2.1.4" | ||
}, | ||
@@ -39,0 +39,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33561
Updateduse-elapsed-time@^2.1.4