use-elapsed-time
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return e[n].call(u.exports,u,u.exports,r),u.l=!0,u.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 u in e)r.d(n,u,function(t){return e[t]}.bind(null,u));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=require("react")},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return o}));var n=r(0);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,u=!1,o=void 0;try{for(var i,c=e[Symbol.iterator]();!(n=(i=c.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){u=!0,o=e}finally{try{n||null==c.return||c.return()}finally{if(u)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.durationMilliseconds,o=t.onComplete,i=t.startAt,c="number"==typeof r,l=Object(n.useState)(i||0),a=u(l,2),f=a[0],s=a[1],d=Object(n.useRef)(null),p=Object(n.useRef)(null),m=function e(t){if(null===p.current)return p.current=t,void(d.current=requestAnimationFrame(e));s((function(n){var i=n+(t-p.current);if(!c||i<r)return p.current=t,d.current=requestAnimationFrame(e),i;if("function"==typeof o){var l=u(o()||[],2),a=l[0],f=void 0!==a&&a,m=l[1];f&&setTimeout((function(){s(0),p.current=null,d.current=requestAnimationFrame(e)}),void 0===m?0:m)}return r}))};return Object(n.useLayoutEffect)((function(){return e&&(d.current=requestAnimationFrame(m)),function(){cancelAnimationFrame(d.current),p.current=null,d.current=null}}),[e]),f}}]); | ||
module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var u=t[n]={i:n,l:!1,exports:{}};return r[n].call(u.exports,u,u.exports,e),u.l=!0,u.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var u in r)e.d(n,u,function(t){return r[t]}.bind(null,u));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=1)}([function(r,t){r.exports=require("react")},function(r,t,e){"use strict";e.r(t),e.d(t,"useElapsedTime",(function(){return i}));var n=e(0);function u(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(r)))return;var e=[],n=!0,u=!1,o=void 0;try{for(var i,c=r[Symbol.iterator]();!(n=(i=c.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){u=!0,o=r}finally{try{n||null==c.return||c.return()}finally{if(u)throw o}}return e}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return o(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return o(r,t)}(r,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 o(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}var i=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=t.durationMilliseconds,o=t.onComplete,i=t.startAt,c="number"==typeof e,a=Object(n.useState)(i||0),l=u(a,2),f=l[0],s=l[1],d=Object(n.useRef)(null),y=Object(n.useRef)(null),m=function r(t){if(null===y.current)return y.current=t,void(d.current=requestAnimationFrame(r));s((function(n){var i=n+(t-y.current);if(!c||i<e)return y.current=t,d.current=requestAnimationFrame(r),i;if("function"==typeof o){var a=u(o()||[],2),l=a[0],f=void 0!==l&&l,m=a[1];f&&setTimeout((function(){s(0),y.current=null,d.current=requestAnimationFrame(r)}),void 0===m?0:m)}return e}))};return Object(n.useLayoutEffect)((function(){return r&&(d.current=requestAnimationFrame(m)),function(){cancelAnimationFrame(d.current),y.current=null,d.current=null}}),[r]),f}}]); |
{ | ||
"name": "use-elapsed-time", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "React hook to get the elapsed time in an animation using requestAnimationFrame", | ||
@@ -39,6 +39,6 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.5.5", | ||
"@babel/core": "^7.9.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.7.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"@babel/preset-react": "^7.9.0", | ||
"@testing-library/react-hooks": "^3.2.1", | ||
@@ -52,5 +52,5 @@ "babel-loader": "^8.0.6", | ||
"react-test-renderer": "16.8.0", | ||
"webpack": "^4.41.4", | ||
"webpack-cli": "^3.3.10" | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11" | ||
} | ||
} |
# useElapsedTime React hook | ||
![npm bundle size](https://img.shields.io/bundlephobia/min/use-elapsed-time) | ||
[![npm](https://img.shields.io/npm/v/use-elapsed-time)](https://www.npmjs.com/package/use-elapsed-time) | ||
[![npm](https://img.shields.io/npm/dw/use-elapsed-time)](https://www.npmjs.com/package/use-elapsed-time) | ||
![Codecov](https://img.shields.io/codecov/c/github/vydimitrov/use-elapsed-time) | ||
![npm](https://img.shields.io/npm/v/use-elapsed-time) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/min/use-elapsed-time)](https://bundlephobia.com/result?p=use-elapsed-time) | ||
@@ -6,0 +7,0 @@ The only hook you need to perform JavaScript animations in React. |
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
8704
63