@infinityfx/lively 2.0.0-beta.3 → 2.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +96 -44
  2. package/dist/cjs/animatable-82c8bdab.js +1 -0
  3. package/dist/cjs/animation-093c54b4.js +1 -0
  4. package/dist/cjs/animations.js +1 -1
  5. package/dist/cjs/auto.js +1 -1
  6. package/dist/cjs/{events-b078b24b.js → events-0578e3ad.js} +1 -1
  7. package/dist/cjs/hooks.js +1 -1
  8. package/dist/cjs/index.js +1 -1
  9. package/dist/cjs/link-127cb540.js +1 -0
  10. package/dist/cjs/{pop-aa2b4873.js → pop-bbcca87f.js} +1 -1
  11. package/dist/cjs/{scroll-36921609.js → scroll-fad125b6.js} +1 -1
  12. package/dist/esm/animatable-da6d3d81.js +1 -0
  13. package/dist/esm/animation-6e420a47.js +1 -0
  14. package/dist/esm/animations.js +1 -1
  15. package/dist/esm/auto.js +1 -1
  16. package/dist/esm/events-880f67a0.js +1 -0
  17. package/dist/esm/hooks.js +1 -1
  18. package/dist/esm/index.js +1 -1
  19. package/dist/esm/link-5b9b9bd9.js +1 -0
  20. package/dist/esm/{pop-3729cc37.js → pop-b892d6b6.js} +1 -1
  21. package/dist/esm/{scroll-85e4c20b.js → scroll-f6402370.js} +1 -1
  22. package/package.json +3 -5
  23. package/types/animatable.d.ts +55 -29
  24. package/types/animate.d.ts +44 -2
  25. package/types/animations/animation.d.ts +6 -0
  26. package/types/auto/layout-group.d.ts +16 -0
  27. package/types/auto/morph.d.ts +26 -0
  28. package/types/auto.d.ts +4 -0
  29. package/types/core/link.d.ts +12 -0
  30. package/types/globals.d.ts +8 -27
  31. package/types/hooks/link.d.ts +8 -0
  32. package/types/hooks/path.d.ts +9 -0
  33. package/types/hooks/reduced-motions.d.ts +4 -0
  34. package/types/hooks/scroll.d.ts +6 -1
  35. package/types/hooks/unmount.d.ts +2 -2
  36. package/types/hooks.d.ts +3 -1
  37. package/types/index.d.ts +1 -1
  38. package/dist/cjs/animatable-a2bb37f4.js +0 -1
  39. package/dist/cjs/animation-d386bd87.js +0 -1
  40. package/dist/cjs/link-3d1b05ee.js +0 -1
  41. package/dist/esm/animatable-3cd57273.js +0 -1
  42. package/dist/esm/animation-6ebdc764.js +0 -1
  43. package/dist/esm/events-262f3d14.js +0 -1
  44. package/dist/esm/link-0e7c5f95.js +0 -1
  45. package/types/animate/animate.d.ts +0 -36
  46. package/types/hooks/animation.d.ts +0 -1
  47. package/types/morph.d.ts +0 -35
package/dist/esm/auto.js CHANGED
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/get";import n from"@babel/runtime/helpers/inherits";import i from"@babel/runtime/helpers/possibleConstructorReturn";import o from"@babel/runtime/helpers/getPrototypeOf";import a from"@babel/runtime/helpers/defineProperty";import{A as l}from"./animatable-3cd57273.js";import u,{isValidElement as s,Children as c,cloneElement as p,Component as f,useRef as h}from"react";import{s as m,k as d,i as y,l as v}from"./link-0e7c5f95.js";import{C as b,c as g}from"./animation-6ebdc764.js";import O from"@babel/runtime/helpers/toConsumableArray";import{u as w}from"./scroll-85e4c20b.js";import"./events-262f3d14.js";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/objectWithoutProperties";function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}function E(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}function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=o(e);if(t){var a=o(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return i(this,r)}}var R={},A=function(i){n(u,l);var a=x(u);function u(t){var r;return e(this,u),(r=a.call(this,t)).animations={default:new b({},{opacity:+t.active,pointerEvents:t.active?"":"none"}),unmorph:new b({},{opacity:0,pointerEvents:"none"})},r.properties=m(r.props.include,r.props.exclude),r.uuid=(t.id||0)+t.group.toString(),r}return t(u,[{key:"shouldComponentUpdate",value:function(e){return this.props.active!==e.active&&(this.uuid in R?R[this.uuid].push(this):R[this.uuid]=[this]),this.props.active!==e.active}},{key:"getSnapshotBeforeUpdate",value:function(e){if(this.props.active!==e.active&&this.props.active){var t,r=k(R[this.uuid]);try{for(r.s();!(t=r.n()).done;){var n=t.value;if(n!==this)return d(n.elements[0],this.props.group)}}catch(e){r.e(e)}finally{r.f()}}return null}},{key:"componentDidUpdate",value:function(e,t,n){if(r(o(u.prototype),"componentDidUpdate",this).call(this),R[this.uuid]=[],n){var i=d(this.elements[0],this.props.group);i.opacity=1,i.pointerEvents="",this.manager.play(g(i,n,this.properties,this.props.duration),{composite:!0})}else this.manager.initialize(this.animations.unmorph)}},{key:"render",value:function(){var e=this.props.children;if(y.array(e)){if(e.length>1)return e;e=e[0]}return s(e)?r(o(u.prototype),"render",this).call(this):e}}]),u}();function C(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=o(e);if(t){var a=o(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return i(this,r)}}a(A,"cascadingProps",["id","duration"]),a(A,"defaultProps",P(P({},l.defaultProps),{},{active:!1,include:v,exclude:[]}));var S=function(r){n(o,f);var i=C(o);function o(t){var r;return e(this,o),(r=i.call(this,t)).children=[],r.properties=m(r.props.include,r.props.exclude),r}return t(o,[{key:"getSnapshotBeforeUpdate",value:function(){return this.children.map((function(e){var t=null==e?void 0:e.elements[0];return t?{data:d(t),key:e.props.layoutKey}:null}))}},{key:"componentDidUpdate",value:function(e,t,r){for(var n=0,i=0;n<r.length;n++,i++){var o=this.children[i];if(o&&o.elements[0]){var a=r[n];if(a&&o.props.layoutKey===a.key){var l=d(o.elements[0]);o.manager.play(g(l,a.data,this.properties,this.props.duration),{composite:!0})}else i--}}}},{key:"render",value:function(){var e=this;return this.childIndex=0,c.map(this.props.children,(function(t){if(!s(t)||!l.isInstance(t))return t;var r=e.childIndex++;return p(t,{ref:function(t){return e.children[r]=t},layoutKey:t.key})}))}}]),o}();function B(e){var t=e.children,r=e.className,n=e.style,i=e.duration;if(!y.string(t))return t;var o=t.split("");return u.createElement("div",{className:r,style:n},u.createElement(l,{whileViewport:!0,animate:{opacity:1,translate:{y:0},rotate:0,duration:.8},initial:{opacity:0,translate:{y:"100%"},rotate:10},stagger:(i-.8)/(o.length-1)},o.map((function(e,t){return u.createElement("span",{style:{display:"inline-block"},key:t},/\s/.test(e)?" ":e)}))))}function D(e){var t,r=e.children,n=e.color,i=e.duration,o=(null===(t=r.props)||void 0===t?void 0:t.children)||[];Array.isArray(o)||(o=[o]);var a=[u.createElement(l,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:i/2}},u.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:n}}))].concat(O(o));return u.createElement(l,{whileViewport:!0,animate:{clip:{right:0},duration:i/2},initial:{clip:{right:1}}},p(r,{},a))}function U(e){var t,r=e.children,n=e.amount,i=w(),o=h();return u.createElement(l,{ref:o,animate:{translate:i((function(e){if(void 0===t){var r,i=null===(r=o.current)||void 0===r?void 0:r.elements[0];i&&(t=Math.max(i.getBoundingClientRect().y+window.scrollY-window.innerHeight/2,0))}return{x:0,y:(e-(t||0))*n}}))}},r)}a(S,"defaultProps",{include:v,exclude:[]}),B.defaultProps={style:{},className:"",duration:1.6},D.defaultProps={color:"grey",duration:1.6},U.defaultProps={amount:.5};export{D as ColorWipe,S as LayoutGroup,A as Morph,U as Parallax,B as WriteOn};
1
+ import t from"@babel/runtime/helpers/classCallCheck";import e from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/get";import n from"@babel/runtime/helpers/inherits";import i from"@babel/runtime/helpers/possibleConstructorReturn";import o from"@babel/runtime/helpers/getPrototypeOf";import a from"@babel/runtime/helpers/defineProperty";import{A as l}from"./animatable-da6d3d81.js";import u,{isValidElement as s,Children as c,cloneElement as p,Component as f,useRef as h}from"react";import{s as m,k as d,i as y,l as v}from"./link-5b9b9bd9.js";import{C as b,c as g}from"./animation-6e420a47.js";import O from"@babel/runtime/helpers/toConsumableArray";import{u as w}from"./scroll-f6402370.js";import"./events-880f67a0.js";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/objectWithoutProperties";function j(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function P(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?j(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function k(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return E(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function x(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=o(t);if(e){var a=o(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return i(this,r)}}var R={},A=function(i){n(u,l);var a=x(u);function u(e){var r;return t(this,u),(r=a.call(this,e)).animations={default:new b({},{opacity:+e.active,pointerEvents:e.active?"":"none"}),unmorph:new b({},{opacity:0,pointerEvents:"none"})},r.properties=m(r.props.include,r.props.exclude),r.uuid=(e.id||0)+e.group.toString(),r}return e(u,[{key:"shouldComponentUpdate",value:function(t){return this.props.active!==t.active&&(this.uuid in R?R[this.uuid].push(this):R[this.uuid]=[this]),this.props.active!==t.active}},{key:"getSnapshotBeforeUpdate",value:function(t){if(this.props.active!==t.active&&this.props.active){var e,r=k(R[this.uuid]);try{for(r.s();!(e=r.n()).done;){var n=e.value;if(n!==this)return d(n.elements[0],this.props.group)}}catch(t){r.e(t)}finally{r.f()}}return null}},{key:"componentDidUpdate",value:function(t,e,n){if(r(o(u.prototype),"componentDidUpdate",this).call(this),R[this.uuid]=[],n){var i=d(this.elements[0],this.props.group);i.opacity=1,i.pointerEvents="",this.manager.play(g(i,n,this.properties,this.props.duration),{composite:!0})}else this.manager.initialize(this.animations.unmorph)}},{key:"render",value:function(){var t=this.props.children;if(y.array(t)){if(t.length>1)return t;t=t[0]}return s(t)?r(o(u.prototype),"render",this).call(this):t}}]),u}();function C(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=o(t);if(e){var a=o(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return i(this,r)}}a(A,"cascadingProps",["id","duration"]),a(A,"defaultProps",P(P({},l.defaultProps),{},{active:!1,include:v,exclude:[]}));var S=function(r){n(o,f);var i=C(o);function o(e){var r;return t(this,o),(r=i.call(this,e)).children=[],r.properties=m(r.props.include,r.props.exclude),r}return e(o,[{key:"getSnapshotBeforeUpdate",value:function(){return this.children.map((function(t){var e=null==t?void 0:t.elements[0];return e?{data:d(e),key:t.props.layoutKey}:null}))}},{key:"componentDidUpdate",value:function(t,e,r){for(var n=0,i=0;n<r.length;n++,i++){var o=this.children[i];if(o&&o.elements[0]){var a=r[n];if(a&&o.props.layoutKey===a.key){var l=d(o.elements[0]);o.manager.play(g(l,a.data,this.properties,this.props.duration),{composite:!0})}else i--}}}},{key:"render",value:function(){var t=this;return this.childIndex=0,c.map(this.props.children,(function(e){if(!s(e)||!l.isInstance(e))return e;var r=t.childIndex++;return p(e,{ref:function(e){return t.children[r]=e},layoutKey:e.key})}))}}]),o}();function B(t){var e=t.children,r=t.className,n=t.style,i=t.duration;if(!y.string(e))return e;var o=e.split("");return u.createElement("div",{className:r,style:n},u.createElement(l,{whileViewport:!0,animate:{opacity:1,translate:{y:0},rotate:0,duration:.8},initial:{opacity:0,translate:{y:"100%"},rotate:10},stagger:(i-.8)/(o.length-1)},o.map((function(t,e){return u.createElement("span",{style:{display:"inline-block"},key:e},/\s/.test(t)?" ":t)}))))}function D(t){var e,r=t.children,n=t.color,i=t.duration,o=(null===(e=r.props)||void 0===e?void 0:e.children)||[];Array.isArray(o)||(o=[o]);var a=[u.createElement(l,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:i/2}},u.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:n}}))].concat(O(o));return u.createElement(l,{whileViewport:!0,animate:{clip:{right:0},duration:i/2},initial:{clip:{right:1}}},p(r,{},a))}function U(t){var e,r=t.children,n=t.amount,i=w(),o=h();return u.createElement(l,{ref:o,animate:{translate:i((function(t){if(void 0===e){var r,i=null===(r=o.current)||void 0===r?void 0:r.elements[0];i&&(e=Math.max(i.getBoundingClientRect().y+window.scrollY-window.innerHeight/2,0))}return{x:0,y:(t-(e||0))*n}}))}},r)}a(S,"defaultProps",{include:v,exclude:[]}),B.defaultProps={style:{},className:"",duration:1.6},D.defaultProps={color:"grey",duration:1.6},U.defaultProps={amount:.5};export{D as ColorWipe,S as LayoutGroup,A as Morph,U as Parallax,B as WriteOn};
@@ -0,0 +1 @@
1
+ import{i as n}from"./link-5b9b9bd9.js";function r(n,r){var e="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!e){if(Array.isArray(n)||(e=function(n,r){if(!n)return;if("string"==typeof n)return t(n,r);var e=Object.prototype.toString.call(n).slice(8,-1);"Object"===e&&n.constructor&&(e=n.constructor.name);if("Map"===e||"Set"===e)return Array.from(n);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return t(n,r)}(n))||r&&n&&"number"==typeof n.length){e&&(n=e);var o=0,a=function(){};return{s:a,n:function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}},e:function(n){throw n},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,f=!1;return{s:function(){e=e.call(n)},n:function(){var n=e.next();return u=n.done,n},e:function(n){f=!0,i=n},f:function(){try{u||null==e.return||e.return()}finally{if(f)throw i}}}}function t(n,r){(null==r||r>n.length)&&(r=n.length);for(var t=0,e=new Array(r);t<r;t++)e[t]=n[t];return e}var e={},o=function(r,t){r in e||(e[r]={unique:0},window.addEventListener(r,(function(t){for(var o=0,a=Object.values(e[r]);o<a.length;o++){var i=a[o];n.function(i)&&i(t)}})));var o=e[r];t.LivelyID=o.unique,o[o.unique++]=t},a=function(r,t){r in e&&!n.null(t)&&"LivelyID"in t&&delete e[r][t.LivelyID]},i=function(n,t,e){var o,a=r(n);try{for(a.s();!(o=a.n()).done;){var i,u=o.value,f=r(t);try{for(f.s();!(i=f.n()).done;){i.value.addEventListener(u,e)}}catch(n){f.e(n)}finally{f.f()}}}catch(n){a.e(n)}finally{a.f()}},u=function(n,t,e){var o,a=r(n);try{for(a.s();!(o=a.n()).done;){var i,u=o.value,f=r(t);try{for(f.s();!(i=f.n()).done;){i.value.removeEventListener(u,e)}}catch(n){f.e(n)}finally{f.f()}}}catch(n){a.e(n)}finally{a.f()}};export{o as a,u as b,i as o,a as r};
package/dist/esm/hooks.js CHANGED
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import{L as i}from"./link-0e7c5f95.js";export{u as useScroll}from"./scroll-85e4c20b.js";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/defineProperty";import"./events-262f3d14.js";function c(n){var o=r(n),u=e(o,2),i=u[0],c=u[1],a=t();return[i,function(){if(!i)return c(!0);a.current.play(a.current.props.onUnmount,{reverse:!0,immediate:!0,callback:function(){return c(!1)}})},a]}function a(e){var r=i.create(e);return[r,r.set]}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=t(),u=n((function(t,n){if(!o.current)return{x:0,y:0};var u=o.current.getTotalLength()*t/n,i=o.current.getPointAtLength(u),c=i.x,a=i.y;return{x:e[0]+c*r,y:e[1]+a*r}}),[o]);return[u,o]}function m(){var t=r(!1),n=e(t,2),u=n[0],i=n[1],c=function(e){return i(e.matches)};return o((function(){var e=matchMedia("(prefers-reduced-motion: reduce)");return e.addEventListener("change",c),i(e.matches),function(){return e.removeEventListener("change",c)}}),[]),u}export{a as useLink,f as usePath,m as useReducedMotion,c as useUnmount};
1
+ import r from"@babel/runtime/helpers/slicedToArray";import{useState as e,useRef as t,useCallback as n,useEffect as o}from"react";import{L as i}from"./link-5b9b9bd9.js";export{u as useScroll}from"./scroll-f6402370.js";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/defineProperty";import"./events-880f67a0.js";function c(n){var o=e(n),u=r(o,2),i=u[0],c=u[1],a=t();return[i,function(){if(!i)return c(!0);a.current.play(a.current.props.onUnmount,{reverse:!0,immediate:!0,callback:function(){return c(!1)}})},a]}function a(r){var e=i.create(r);return[e,e.set]}function f(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=t(),u=n((function(t,n){if(!o.current)return{x:0,y:0};var u=o.current.getTotalLength()*t/n,i=o.current.getPointAtLength(u),c=i.x,a=i.y;return{x:r[0]+c*e,y:r[1]+a*e}}),[o]);return[u,o]}function m(){var t=e(!1),n=r(t,2),u=n[0],i=n[1],c=function(r){return i(r.matches)};return o((function(){var r=matchMedia("(prefers-reduced-motion: reduce)");return r.addEventListener("change",c),i(r.matches),function(){return r.removeEventListener("change",c)}}),[]),u}export{a as useLink,f as usePath,m as useReducedMotion,c as useUnmount};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{A as e}from"./animatable-3cd57273.js";export{A as Animatable}from"./animatable-3cd57273.js";import t from"@babel/runtime/helpers/extends";import r from"@babel/runtime/helpers/objectWithoutProperties";import n from"@babel/runtime/helpers/classCallCheck";import o from"@babel/runtime/helpers/createClass";import i from"@babel/runtime/helpers/inherits";import a from"@babel/runtime/helpers/possibleConstructorReturn";import l from"@babel/runtime/helpers/getPrototypeOf";import s from"@babel/runtime/helpers/defineProperty";import p,{Children as c,isValidElement as m,cloneElement as u,Component as f}from"react";import{M as b,P as h}from"./pop-3729cc37.js";import{p as v}from"./link-0e7c5f95.js";import"./animation-6ebdc764.js";import"@babel/runtime/helpers/slicedToArray";import"./events-262f3d14.js";import"@babel/runtime/helpers/typeof";var y=["levels","animations"];function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var o=l(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return a(this,r)}}var P=function(a){i(s,f);var l=j(s);function s(e){var t;return n(this,s),(t=l.call(this,e)).levels=t.props.levels,t.animations=v(t.props.animations,t.levels),t}return o(s,[{key:"makeAnimatable",value:function(n){var o=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(i<1||c.count(n)<1)return n;var a=this.props;a.levels,a.animations;var l=r(a,y),s=this.animations[this.levels-i];return i===this.levels&&(l.ref=function(e){return o.animatable=e}),p.createElement(e,t({},l,{animate:s}),c.map(n,(function(e){return m(e)?u(e,{},o.makeAnimatable(e.props.children,i-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,d({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),s}();s(P,"defaultProps",{levels:1,animations:[b,h]});export{P as Animate};
1
+ import{A as e}from"./animatable-da6d3d81.js";export{A as Animatable}from"./animatable-da6d3d81.js";import t from"@babel/runtime/helpers/extends";import r from"@babel/runtime/helpers/objectWithoutProperties";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import a from"@babel/runtime/helpers/inherits";import o from"@babel/runtime/helpers/possibleConstructorReturn";import l from"@babel/runtime/helpers/getPrototypeOf";import s from"@babel/runtime/helpers/defineProperty";import m,{Children as p,isValidElement as u,cloneElement as f,Component as c}from"react";import{M as b,P as h}from"./pop-b892d6b6.js";import{p as v}from"./link-5b9b9bd9.js";import"./animation-6e420a47.js";import"@babel/runtime/helpers/slicedToArray";import"./events-880f67a0.js";import"@babel/runtime/helpers/typeof";var d=["levels","animations"];function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var i=l(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return o(this,r)}}var k=function(o){a(s,c);var l=y(s);function s(e){var t;return n(this,s),(t=l.call(this,e)).levels=t.props.levels,t.animations=v(t.props.animations,t.levels),t}return i(s,[{key:"makeAnimatable",value:function(n){var i=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(a<1||p.count(n)<1)return n;var o=this.props;o.levels,o.animations;var l=r(o,d),s=this.animations[this.levels-a];return a===this.levels&&(l.ref=function(e){return i.animatable=e}),m.createElement(e,t({},l,{animate:s}),p.map(n,(function(e){return u(e)?f(e,{},i.makeAnimatable(e.props.children,a-1)):e})))}},{key:"play",value:function(){var e;null===(e=this.animatable)||void 0===e||e.play(arguments)}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),s}();s(k,"defaultProps",{levels:1,animations:[b,h]});export{k as Animate};
@@ -0,0 +1 @@
1
+ import n from"@babel/runtime/helpers/typeof";import t from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/defineProperty";var e=["set","start","end"],o=["%","px","em","rem","vw","vh","vmin","vmax","deg","rad"],i={rotate:"deg",skew:"deg",scale:"%",clip:"%",opacity:null,zIndex:null,lineHeight:null,fontWeight:null,length:null,default:"px"},a=[["x","y"],["r","g","b","a"],["left","top","right","bottom"]],u={translate:{x:[0,"px"],y:[0,"px"]},scale:{x:[1,"%"],y:[1,"%"]},clip:{left:[0,"%"],top:[0,"%"],right:[0,"%"],bottom:[0,"%"]},r:[127,null],g:[127,null],b:[127,null],a:[255,null]},c=["translate","scale","rotate","opacity","borderRadius","backgroundColor","color","zIndex","pointerEvents"],l={translate:function(n,t){return n+t},rotate:function(n,t){return n+t},scale:function(n,t){return n*t},default:function(n,t){return(n+t)/2}};function f(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!r){if(Array.isArray(n)||(r=function(n,t){if(!n)return;if("string"==typeof n)return s(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(n);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(n,t)}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0,o=function(){};return{s:o,n:function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(n){throw n},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(n)},n:function(){var n=r.next();return a=n.done,n},e:function(n){u=!0,i=n},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function s(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}var d=function(n,t){return n&&!t||!n&&t},h=function(n,t){return new Array(t).fill(0).map((function(t,r){return r<n.length?n[r]:n[n.length-1]}))},y=function(n,t){return n.filter((function(n){return!t.includes(n)}))},b=function(n,t){return Object.keys(n).some((function(n){return t.includes(n)}))},g=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=n.y,e=n.bottom,o=e-r;return{left:r>window.innerHeight+o*t,entered:r+o*t<window.innerHeight}},p=function(n){var t=n.getBoundingClientRect(),r=t.x,e=t.y,o=t.right,i=t.bottom;return!(o-r<1||i-e<1)&&(e<window.innerHeight&&i>0&&r<window.innerWidth&&o>0)},m={null:function(n){return null==n},array:function(n){return Array.isArray(n)},object:function(t){return!m.null(t)&&"object"===n(t)&&!m.array(t)},function:function(n){return n instanceof Function},string:function(n){return"string"==typeof n},bool:function(n){return"boolean"==typeof n},number:function(n){return"number"==typeof n},empty:function(n){return function(n,t){return Object.keys(n).length===t}(n,0)},rgb:function(n){return n.match(/^rgba?\(.*\)$/i)},hex:function(n){return n.match(/^#[0-9a-f]{3,8}$/i)},color:function(n){return m.object(n)&&"r"in n}},v=function(n){var t=new DOMMatrix(n),r=Math.sqrt(t.a*t.a+t.b*t.b)*Math.sign(t.a),e=Math.sqrt(t.c*t.c+t.d*t.d)*Math.sign(t.d),o=180*Math.atan2(t.d,t.c)/Math.PI-90,i=180*Math.atan2(t.b,t.a)/Math.PI;return{translate:{x:t.e,y:t.f},scale:{x:r,y:e},rotate:i,skew:{x:o,y:0}}},w=function(n,t){var r=getComputedStyle(n),e=v(r.transform);if(t in e)return D(e[t],t);var o=r[t];return m.rgb(o)?H(o):z(o)},x=function(n){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=getComputedStyle(n),o=n.getBoundingClientRect(),i=o.x,a=o.y,u=o.width,l=o.height,s=(r?n.parentElement:document.body).getBoundingClientRect(),d={layout:{x:i=(i-s.x+u/2)/s.width,y:a=(a-s.y+l/2)/s.height,width:u,height:l,parentWidth:s.width,parentHeight:s.height}},h=f(c);try{for(h.s();!(t=h.n()).done;){var y=t.value;d[y]=e[y]}}catch(n){h.e(n)}finally{h.f()}return Object.assign(d,v(e.transform)),d},j=function(n,t){var r,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.keys(t),o=f(e);try{for(o.s();!(r=o.n()).done;){var i=r.value;m.null(t[i])||(n[i]=t[i])}}catch(n){o.e(n)}finally{o.f()}return n},O=function n(t,r,e){if(m.object(t)){var o={};for(var i in t)o[i]=n(t[i],r[i],e);return o}return m.number(t[0])&&m.number(r[0])?[e(t[0],r[0]),t[1]]:r},P=function(n,t){for(var r in t){var e=l[r]||l.default;n[r]=r in n?O(n[r],t[r],e):t[r]}},k=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;return function(){var r=Date.now();n.LivelyTimestamp-r<t||(n.LivelyTimestamp=r,n())}};function A(n,t){var r=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);t&&(e=e.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.push.apply(r,e)}return r}function S(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?A(Object(e),!0).forEach((function(t){r(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function M(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!r){if(Array.isArray(n)||(r=function(n,t){if(!n)return;if("string"==typeof n)return I(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);"Object"===r&&n.constructor&&(r=n.constructor.name);if("Map"===r||"Set"===r)return Array.from(n);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return I(n,t)}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0,o=function(){};return{s:o,n:function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(n){throw n},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(n)},n:function(){var n=r.next();return a=n.done,n},e:function(n){u=!0,i=n},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function I(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}var D=function n(r,e){var o,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(m.null(r))return null;if("scale"!==e||i||m.object(r)||(r={x:r,y:r}),m.object(r)){var c,l=Object.keys(r),f=M(a);try{for(f.s();!(c=f.n()).done;){var s=c.value;if(b(r,s)){l=s;break}}}catch(n){f.e(n)}finally{f.f()}r=S({},r);var d,h=M(l);try{for(h.s();!(d=h.n()).done;){var y=d.value,g=e in u?u[e][y]:u[y];r[y]=y in r?n(r[y],e,!0):g}}catch(n){h.e(n)}finally{h.f()}return r}if(m.string(r)){if(m.hex(r))return C(r);if(m.rgb(r))return H(r);var p=z(r),v=t(p,2);r=v[0],"%"==(o=v[1])&&(r/=100)}return[r,o=m.number(r)?T.normalize(o,e):null]},C=function(n){var r=n.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),e=t(r,5);e[0];var o=e[1],i=e[2],a=e[3],u=e[4],c=function(n){return[m.null(n)?255:parseInt(n.padStart(2,n),16),null]};return{r:c(o),g:c(i),b:c(a),a:c(u)}},H=function(n){var r=n.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),e=t(r,5);e[0];var o=e[1],i=e[2],a=e[3],u=e[4],c=function(n){return[m.null(n)?255:parseInt(n),null]};return{r:c(o),g:c(i),b:c(a),a:c(u)}},E=function(n,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.keys(n);return r.map((function(t){return B(n[t])})).join(t)},W=function(n){var t=m.object(n)?n:{},r=t.x,e=void 0===r?.5:r,o=t.y,i=void 0===o?.5:o;if(m.string(n))switch(n){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}return{x:e,y:i}},z=function(n){var t=n.toString().match(/^([\d.]+)([^\d.]*)$/i);return t?[parseFloat(t[1]),t[2]||null]:[n,null]},B=function(n){return("%"==n[1]?100*n[0]:n[0])+(m.null(n[1])?"":n[1])},T={emtopx:function(n,t){return n*parseFloat(getComputedStyle(t).fontSize)},remtopx:function(n){return T.emtopx(n,document.body)},vwtopx:function(n){return n*window.innerWidth},vhtopx:function(n){return n*window.innerHeight},vmintopx:function(n){return n*Math.min(window.innerWidth,window.innerHeight)},vmaxtopx:function(n){return n*Math.max(window.innerWidth,window.innerHeight)},radtodeg:function(n){return 180*n/Math.PI},fromProperty:function(n){return n in i?i[n]:i.default},toBase:function(n,t,r){if(m.object(n)){var e={};for(var o in n)e[o]=T.toBase(n[o],t);return e}if(!m.number(n[0]))return n;var i=T.fromProperty(t);if(m.null(n[1])&&!m.null(i))return[n[0],i];var a=T["".concat(n[1],"to").concat(i)];return a?[a(n[0],r),i]:n},normalize:function(n,t){return o.includes(n)||m.null(n)&&t in i?n:T.fromProperty(t)}},$=function(n){return"inset(".concat(E(n," ",["top","right","bottom","left"]),")")},R={origin:["transformOrigin"],length:["strokeDashoffset"],clip:["clipPath","webkitClipPath"],transformOrigin:function(n){return"".concat(100*n.x,"% ").concat(100*n.y,"%")},strokeDashoffset:function(n){return 1-n[0]},clipPath:$,webkitClipPath:$},F={bind:function(n,t){n.origin=n.origin||n;var r=function(){for(var r,e=arguments.length,o=new Array(e),i=0;i<e;i++)o[i]=arguments[i];return(r=n.origin).call.apply(r,[t].concat(o))};return r.origin=n.origin,r},create:function(n){var t=F.bind((function(n){if(m.function(n)){var r=F.bind(t,{transform:n});return r.set=t.set,r.internal=t.internal,r}return this.transform(t.internal.value)}),{transform:function(n){return n}});return t.set=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t.internal.value=n,t.internal.duration=r,t.internal.t=null},t.internal={value:n,duration:0},t},isInstance:function(n){return m.function(n)&&m.function(n.set)}},L=F;export{R as A,u as D,L,l as M,e as P,T as U,O as a,B as b,g as c,j as d,D as e,p as f,w as g,b as h,m as i,W as j,x as k,c as l,P as m,E as o,h as p,y as s,k as t,d as x};
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/objectWithoutProperties";import{A as t}from"./animation-6ebdc764.js";var o=["direction"];function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function c(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var i=t.create((function(e){var t=e.direction,n=void 0===t?"up":t,i=r(e,o),p="0px",a="20px";switch(n){case"down":a="-20px";break;case"left":p="20px",a="0px";break;case"right":p="-20px",a="0px"}return[c({translate:{x:0,y:0},opacity:1,duration:.5},i),{translate:{x:p,y:a},opacity:0}]}));function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function a(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?p(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):p(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var s=t.create((function(e){return[a({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85}]}));export{i as M,s as P};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/objectWithoutProperties";import{A as t}from"./animation-6e420a47.js";var o=["direction"];function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function c(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var i=t.create((function(e){var t=e.direction,n=void 0===t?"up":t,i=r(e,o),p="0px",a="20px";switch(n){case"down":a="-20px";break;case"left":p="20px",a="0px";break;case"right":p="-20px",a="0px"}return[c({translate:{x:0,y:0},opacity:1,duration:.5},i),{translate:{x:p,y:a},opacity:0}]}));function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function a(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?p(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):p(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var s=t.create((function(e){return[a({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85}]}));export{i as M,s as P};
@@ -1 +1 @@
1
- import{useEffect as r}from"react";import{L as t}from"./link-0e7c5f95.js";import{a as n,r as o}from"./events-262f3d14.js";function e(){var e=t.create(0);return r((function(){var r=function(){return e.set(window.scrollY)};return r(),n("scroll",r),function(){return o("scroll",r)}}),[]),e}export{e as u};
1
+ import{useEffect as r}from"react";import{L as t}from"./link-5b9b9bd9.js";import{a as n,r as o}from"./events-880f67a0.js";function e(){var e=t.create(0);return r((function(){var r=function(){return e.set(window.scrollY)};return r(),n("scroll",r),function(){return o("scroll",r)}}),[]),e}export{e as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinityfx/lively",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.5",
4
4
  "description": "Feature complete, lightweight react animation library.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -8,8 +8,7 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": "./dist/esm/index.js",
11
- "require": "./dist/cjs/index.js",
12
- "types": "./types/index.d.ts"
11
+ "require": "./dist/cjs/index.js"
13
12
  },
14
13
  "./animations": {
15
14
  "import": "./dist/esm/animations.js",
@@ -21,8 +20,7 @@
21
20
  },
22
21
  "./auto": {
23
22
  "import": "./dist/esm/auto.js",
24
- "require": "./dist/cjs/auto.js",
25
- "types": "./types/auto.d.ts"
23
+ "require": "./dist/cjs/auto.js"
26
24
  }
27
25
  },
28
26
  "typesVersions": {
@@ -17,6 +17,32 @@ interface AnimatableProps {
17
17
  */
18
18
  viewportMargin?: number;
19
19
 
20
+ /**
21
+ * Controls the order in which the component animates when part of a cascading animation.
22
+ */
23
+ group?: number;
24
+
25
+ /**
26
+ * Whether to pause an animation when the animated `element` is not visible on screen.
27
+ *
28
+ * @default true
29
+ */
30
+ lazy?: boolean;
31
+
32
+ /**
33
+ * Whether all playing animations should be paused or not.
34
+ *
35
+ * @default false
36
+ */
37
+ paused?: boolean;
38
+
39
+ /**
40
+ * Whether to correct an `element`'s children and certain of it's properties for deformations caused by scaling the `element`.
41
+ *
42
+ * @default false
43
+ */
44
+ noDeform?: boolean;
45
+
20
46
  /**
21
47
  * Define a default animation.
22
48
  */
@@ -81,51 +107,51 @@ interface AnimatableProps {
81
107
  * @default false
82
108
  */
83
109
  whileFocus?: string | boolean;
84
-
85
- /**
86
- * Controls the order in which the component animates when part of a cascading animation.
87
- */
88
- group?: number;
89
110
  }
90
111
 
91
112
  export class Animatable extends React.Component<AnimatableProps> {
92
113
 
93
- private parse;
114
+ /**
115
+ * Checks whether something is an instance of `Animatable` or a class that extends it.
116
+ */
117
+ static isInstance(val: any): boolean;
94
118
 
95
- private style;
119
+ private parse;
96
120
 
97
121
  private update;
98
122
 
99
- private inViewport;
100
-
101
- private onScroll;
123
+ private dispatch;
102
124
 
103
- private onResize;
125
+ private onEvent;
104
126
 
105
- private onEnter;
106
-
107
- private onLeave;
108
-
109
- private onFocus;
110
-
111
- private onBlur;
127
+ private onScroll;
112
128
 
113
- private onClick;
129
+ private getBoundingBox;
114
130
 
115
- play(animationName: string, { callback, reverse, immediate, cascade, groupAdjust, cascadeDelay, staggerDelay }?: {
131
+ /**
132
+ * Play an animation referenced in `this.animations`.
133
+ *
134
+ * @param {string} animation
135
+ * @param {object} [options]
136
+ * @param {Function} [options.callback] - A callback function that gets called when the animation finishes playing.
137
+ * @param {boolean} [options.reverse] - Play the animation in reverse.
138
+ * @param {boolean} [options.composite] - Whether to play the animation simultaneously with other animations.
139
+ * @param {boolean} [options.immediate] - Whether to immediately play the animation, will override other playing animations when `composite` is `false`.
140
+ * @param {number} [options.delay] - Delay the animation by some amount in seconds.
141
+ */
142
+ play(animation: string, { callback, reverse, composite, immediate, delay }?: {
116
143
  callback?: Function;
117
144
  reverse?: boolean;
145
+ composite?: boolean;
118
146
  immediate?: boolean;
119
- cascade?: boolean;
120
- groupAdjust?: number;
121
- cascadeDelay?: number;
122
- staggerDelay?: number;
123
- }): Promise<void>;
147
+ delay?: number;
148
+ }, delegate?: boolean): number;
124
149
 
125
- private mergeProperties;
150
+ /**
151
+ * Stop playing all currently playing animations.
152
+ */
153
+ stop(): void;
126
154
 
127
- private deepClone;
128
-
129
- private countNestedLevels;
155
+ private prerender;
130
156
 
131
157
  }
@@ -1,3 +1,45 @@
1
- export as namespace Animate;
1
+ import React from 'react';
2
+ import { AnimatableProps } from '../animatable';
3
+ import { Animation } from '../animations/animation';
2
4
 
3
- export { Animate } from './animate/animate';
5
+ interface AnimateProps extends AnimatableProps {
6
+
7
+ /**
8
+ * An array of `Animation` objects that defines what animation to apply to element depending on it's level.
9
+ *
10
+ * @default [Move, Pop]
11
+ */
12
+ animations?: Animation[];
13
+
14
+ /**
15
+ * How many levels of `elements` to animate.
16
+ *
17
+ * @default 1
18
+ */
19
+ levels?: number;
20
+ }
21
+
22
+ export class Animate extends React.Component<AnimateProps> {
23
+
24
+ private makeAnimatable;
25
+
26
+ /**
27
+ * Play an animation referenced in `this.animations`.
28
+ *
29
+ * @param {string} animation
30
+ * @param {object} [options]
31
+ * @param {Function} [options.callback] - A callback function that gets called when the animation finishes playing.
32
+ * @param {boolean} [options.reverse] - Play the animation in reverse.
33
+ * @param {boolean} [options.composite] - Whether to play the animation simultaneously with other animations.
34
+ * @param {boolean} [options.immediate] - Whether to immediately play the animation, will override other playing animations when `composite` is `false`.
35
+ * @param {number} [options.delay] - Delay the animation by some amount in seconds.
36
+ */
37
+ play(animation: string, { callback, reverse, composite, immediate, delay }?: {
38
+ callback?: Function;
39
+ reverse?: boolean;
40
+ composite?: boolean;
41
+ immediate?: boolean;
42
+ delay?: number;
43
+ }, delegate?: boolean): number;
44
+
45
+ }
@@ -2,8 +2,14 @@ import { AnimationInitials, AnimationProperties } from '../globals';
2
2
 
3
3
  export type Animation = {
4
4
 
5
+ /**
6
+ * Creates a new `Animation` based on a `Function` that returns a tuple of animation properties and initials.
7
+ */
5
8
  create(getProperties?: () => [AnimationProperties, AnimationInitials]): Animation;
6
9
 
10
+ /**
11
+ * Check whether something is an instance of `Animation`.
12
+ */
7
13
  isAnimation(animation: any): boolean;
8
14
 
9
15
  }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ interface LayoutGroupProps {
4
+
5
+ /**
6
+ * @default ['translate', 'scale', 'rotate', 'opacity', 'borderRadius', 'backgroundColor', 'color', 'zIndex', 'pointerEvents']
7
+ */
8
+ include?: string[];
9
+
10
+ /**
11
+ * @default []
12
+ */
13
+ exclude?: string[];
14
+ }
15
+
16
+ export class LayoutGroup extends React.Component<LayoutGroupProps> {}
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { AnimatableProps } from '../animatable';
3
+
4
+ interface MorphProps extends AnimatableProps {
5
+
6
+ /**
7
+ * @default false
8
+ */
9
+ active?: boolean;
10
+
11
+ /**
12
+ * @default ['translate', 'scale', 'rotate', 'opacity', 'borderRadius', 'backgroundColor', 'color', 'zIndex', 'pointerEvents']
13
+ */
14
+ include?: string[];
15
+
16
+ /**
17
+ * @default []
18
+ */
19
+ exclude?: string[];
20
+ }
21
+
22
+ export class Morph extends React.Component<MorphProps> {
23
+
24
+ private static cascadingProps;
25
+
26
+ }
@@ -0,0 +1,4 @@
1
+ export as namespace Auto;
2
+
3
+ export { LayoutGroup } from './auto/layout-group';
4
+ export { Morph } from './auto/morph';
@@ -0,0 +1,12 @@
1
+ export type Link = {
2
+
3
+ set: (val: any, duration?: number) => void;
4
+
5
+ }
6
+
7
+ /**
8
+ * A reactive `Function` which returns it currently stored value.
9
+ *
10
+ * @param {Function} transformer - A function which transforms the `Link` value before returning it.
11
+ */
12
+ export function Link(transformer?: (val: any) => any): any;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- type PositionProperty = { x?: number; y?: number; } | string;
3
+ type TranslateProperty = { x?: number; y?: number; } | string;
4
4
 
5
5
  type ScaleProperty = { x?: number; y?: number; } | string | number;
6
6
 
@@ -17,7 +17,7 @@ export interface AnimationInitials extends React.CSSProperties {
17
17
  *
18
18
  * @default { x: 0, y: 0 }
19
19
  */
20
- position?: PositionProperty;
20
+ translate?: TranslateProperty;
21
21
 
22
22
  /**
23
23
  * @default { x: 1, y: 1 }
@@ -27,7 +27,7 @@ export interface AnimationInitials extends React.CSSProperties {
27
27
  /**
28
28
  * @default 0
29
29
  */
30
- rotation?: number;
30
+ rotate?: number | string;
31
31
 
32
32
  /**
33
33
  * @default { left: 0, top: 0, right: 0, bottom: 0 }
@@ -35,27 +35,11 @@ export interface AnimationInitials extends React.CSSProperties {
35
35
  clip?: ClipProperty;
36
36
 
37
37
  /**
38
- * Whether to render the `element`.
39
- * An alias for the `display` property which maps `true` to `""` and `false` to `"none"`.
40
- *
41
- * @default true
42
- */
43
- active?: boolean;
44
-
45
- /**
46
- * Whether to allow mouse interactions with the `element`.
47
- * An alias for the `pointerEvents` property which maps `true` to `"all"` and `false` to `"none"`.
48
- *
49
- * @default true
50
- */
51
- interact?: boolean;
52
-
53
- /**
54
- * Value between `0` and `1` which defines how much of an `<svg>` element stroke is shown.
38
+ * Value between `0` and `1` which defines how much of an `SVGElement`'s stroke is shown.
55
39
  *
56
40
  * @default 1
57
41
  */
58
- strokeLength?: number;
42
+ length?: number;
59
43
  }
60
44
 
61
45
  export interface AnimationProperties extends AnimationInitials {
@@ -95,15 +79,12 @@ export interface AnimationProperties extends AnimationInitials {
95
79
  *
96
80
  * @default "ease"
97
81
  */
98
- interpolate?: 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' | 'step-start' | 'step-end' | 'spring';
82
+ interpolate?: 'constant' | 'linear' | 'ease' | 'spring';
99
83
 
100
84
  /**
85
+ * Alias for `transform-origin`.
86
+ *
101
87
  * @default { x: 0.5, y: 0.5 }
102
88
  */
103
89
  origin?: string | { x?: number, y?: number } | number;
104
-
105
- /**
106
- * @default false
107
- */
108
- useLayout?: boolean;
109
90
  }
@@ -0,0 +1,8 @@
1
+ import { Link } from '../core/link';
2
+
3
+ /**
4
+ * Returns a `Link`, which can be used as an animation value.
5
+ *
6
+ * @param {any} initial - The initial value for the `Link`.
7
+ */
8
+ export function useLink(initial: any): [Link, Link.set];
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Returns a `Function`, which can be passed as an animation value for the `translate` property, that describes the motion along a referenced `SVGElement`'s path.
5
+ *
6
+ * @param {number[]} [offset=[0, 0]] - Offset the path's position by some amount along the x and y axis in pixels.
7
+ * @param {number} [scale=1] - Scale the size of the path some amount.
8
+ */
9
+ export function usePath(offset?: number[], scale?: number): [Function, React.Ref<SVGElement>];
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Checks whether a user prefers reduced motion, when `preferes-reduced-motion: reduce`.
3
+ */
4
+ export function useReducedMotion(): boolean;
@@ -1 +1,6 @@
1
- export function useScroll(): object;
1
+ import { Link } from '../core/link';
2
+
3
+ /**
4
+ * Returns a `Link`, which can be used as an animation value, that describes the current scroll position on the page.
5
+ */
6
+ export function useScroll(): Link;
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Animatable } from '../animatable';
3
- import { Animate } from '../animate/animate';
3
+ import { Animate } from '../animate';
4
4
 
5
5
  /**
6
6
  * Returns a boolean value which dictates whether the referenced component should be mounted or not and allows for animating the respective component when it unmounts.
7
7
  *
8
- * @param initial whether the referenced component is initially mounted.
8
+ * @param {boolean} initial - whether the referenced component is initially mounted.
9
9
  */
10
10
  export function useUnmount(initial: boolean): [boolean, (mounted: boolean) => void, React.Ref<Animatable | Animate>];
package/types/hooks.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export as namespace Hooks;
2
2
 
3
3
  export { useUnmount } from './hooks/unmount';
4
- export { useAnimation } from './hooks/animation';
4
+ export { useLink } from './hooks/link';
5
5
  export { useScroll } from './hooks/scroll';
6
+ export { usePath } from './hooks/path';
7
+ export { useReducedMotion } from './hooks/reduced-motion';
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export as namespace Lively;
2
2
 
3
3
  export { Animatable } from './animatable';
4
- export { Morph } from './morph';
4
+ export { Animate } from './animate';
@@ -1 +0,0 @@
1
- "use strict";var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),i=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/defineProperty"),a=require("react"),s=require("./animation-d386bd87.js"),l=require("./link-3d1b05ee.js"),u=require("./events-b078b24b.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=c(e),f=c(t),p=c(r),y=c(n),d=c(i),v=c(o);function m(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function g(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 b=function(){function e(){h.default(this,e),this.t=Date.now(),this.managers=[],this.step()}return f.default(e,[{key:"step",value:function(){var e,t=Date.now(),r=m(this.managers);try{for(r.s();!(e=r.n()).done;){e.value.step((t-this.t)/1e3)}}catch(e){r.e(e)}finally{r.f()}this.t=t,requestAnimationFrame(this.step.bind(this))}},{key:"add",value:function(e){var t=this.managers.findIndex((function(t){return t.priority>=e.priority}));this.managers.splice(t<0?0:t,0,e)}},{key:"remove",value:function(e){this.managers.splice(this.managers.indexOf(e),1)}}],[{key:"get",value:function(){return window.Lively||(window.Lively=new e),window.Lively}}]),e}();function w(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function k(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 O=function(){function e(t,r,n){h.default(this,e),this.element=t,this.tracks=[],this.queue=[],this.playing=!0,this.culling=r,this.layout=n}return f.default(e,[{key:"purge",value:function(){if(!("cache"in this.element)){this.element.cache={strokeDasharray:1,borderRadius:l.getProperty(this.element,"borderRadius")};for(var e=0;e<this.element.style.length;e++){var t=this.element.style[e];this.element.cache[t]=this.element.style[t]}}for(var r in this.element.style={},this.element.cache)this.element.style[r]=this.element.cache[r]}},{key:"clear",value:function(){this.tracks=[],this.queue=[]}},{key:"add",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.immediate,n=void 0!==r&&r,i=t.composite,o=void 0===i||i;n&&this.clear(),o||!this.tracks.length?this.tracks.push(e):this.queue.push(e)}},{key:"remove",value:function(e){this.tracks.splice(this.tracks.indexOf(e),1),!this.tracks.length&&this.queue.length&&this.tracks.push(this.queue.shift())}},{key:"step",value:function(e){if(this.playing){for(var t=this.element.correction?{scale:l.DEFAULT_OBJECTS.scale}:{},r=this.tracks.length+ +!this.channel.isEmpty,n=0;n<r;n++){var i=this.tracks[n]||this.channel;l.mergeProperties(t,i.get(this.element,this.culling)),i.step(e)&&this.remove(i)}this.apply(this.element,t)}}},{key:"apply",value:function(e,t){if(!l.is.empty(t)){var r=[];for(var n in t){var i=t[n];if("scale"==n){if(this.layout){var o,a={x:[1/i.x[0],i.x[1]],y:[1/i.y[0],i.y[1]]},s=w(e.children);try{for(s.s();!(o=s.n()).done;){o.value.correction=a}}catch(e){s.e(e)}finally{s.f()}var u=t.borderRadius||e.cache.borderRadius;delete t.borderRadius,e.style.borderRadius="".concat(u[0]/i.x[0]).concat(u[1]," / ").concat(u[0]/i.y[0]).concat(u[1])}e.correction&&(i=l.merge(i,e.correction,l.MERGE_FUNCTIONS.scale))}var c=l.TRANSFORMS.indexOf(n);if(c>=0)r[c]="".concat(n,"(").concat(l.is.object(i)?l.objToStr(i,", ",["x","y"]):l.arrToStyle(i),")");else{var h,f=w(l.Alias[n]||[n]);try{for(f.s();!(h=f.n()).done;){var p=h.value;l.is.color(i)?e.style[p]="rgba(".concat(i.r[0],", ").concat(i.g[0],", ").concat(i.b[0],", ").concat(i.a[0],")"):e.style[p]=p in l.Alias?l.Alias[p](i):l.arrToStyle(i)}}catch(e){f.e(e)}finally{f.f()}}}(r=r.filter((function(e){return!!e}))).length&&(e.style.transform=r.join(" "))}}},{key:"initialize",value:function(e){this.apply(this.element,e.initials),this.channel=e.channel}}]),e}();function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){v.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function x(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 E=function(){function e(t){var r=t.priority,n=void 0===r?0:r,i=t.stagger,o=void 0===i?.1:i,a=t.culling,s=void 0===a||a,l=t.noDeform,u=void 0!==l&&l,c=t.paused,f=void 0!==c&&c;h.default(this,e),this.targets=[],this.priority=n,this.stagger=o,this.culling=s,this.noDeform=u,this.paused=f}return f.default(e,[{key:"register",value:function(){b.get().add(this)}},{key:"destroy",value:function(){this.targets=[],b.get().remove(this)}},{key:"purge",value:function(){var e,t=S(this.targets);try{for(t.s();!(e=t.n()).done;){e.value.purge()}}catch(e){t.e(e)}finally{t.f()}}},{key:"clear",value:function(){var e,t=S(this.targets);try{for(t.s();!(e=t.n()).done;){e.value.clear()}}catch(e){t.e(e)}finally{t.f()}}},{key:"set",value:function(e){var t=this;this.targets=e.map((function(e){return new O(e,t.culling,t.noDeform)}))}},{key:"play",value:function(e,t){if(!e.isEmpty)for(var r=0;r<this.targets.length;r++){var n=A(A({},t),{},{delay:(t.delay||0)+r*this.stagger});this.targets[r].add(e.play(n),n)}}},{key:"initialize",value:function(e){var t,r=S(this.targets);try{for(r.s();!(t=r.n()).done;){t.value.initialize(e)}}catch(e){r.e(e)}finally{r.f()}}},{key:"step",value:function(e){if(!this.paused){var t,r=S(this.targets);try{for(r.s();!(t=r.n()).done;){t.value.step(e)}}catch(e){r.e(e)}finally{r.f()}}}}]),e}();function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){v.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function M(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}function q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d.default(e);if(t){var i=d.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return y.default(this,r)}}var C=function(e){p.default(r,e);var t=q(r);function r(e){var n;for(var i in h.default(this,r),(n=t.call(this,e)).animations={default:n.parse(n.props.animate||{})},n.props.animations||{})n.animations[i]=n.parse(n.props.animations[i]);return n.children=[],n.elements=[],n.stagger=n.props.stagger||.1,n.manager=new E({priority:n.props.group,stagger:n.stagger,culling:n.props.lazy,noDeform:n.props.noDeform,paused:n.props.paused}),n}return f.default(r,[{key:"parse",value:function(e){return s.Animation.isInstance(e)?e.use():l.is.object(e)?new s.Clip(e,this.props.initial):null}},{key:"update",value:function(){this.manager.clear(),this.manager.purge(),this.manager.initialize(this.animations.default)}},{key:"componentDidMount",value:function(){var e=this;this.scrollEventListener=l.throttle(this.onScroll.bind(this)),u.addEventListener("scroll",this.scrollEventListener),this.eventListener=this.onEvent.bind(this),u.onAny(r.events,this.elements,this.eventListener),this.manager.set(this.elements),this.manager.register(),this.update(),document.fonts.ready.then((function(){e.update(),clearTimeout(e.timeout),e.inViewport=!1,e.props.group||(e.play(e.props.onMount),e.onScroll())}))}},{key:"componentWillUnmount",value:function(){u.removeEventListener("scroll",this.scrollEventListener),u.offAny(r.events,this.elements,this.eventListener),this.manager.destroy()}},{key:"componentDidUpdate",value:function(){this.manager.paused=this.props.paused;var e,t=D(this.children);try{for(t.s();!(e=t.n()).done;){e.value.manager.paused=this.props.paused}}catch(e){t.e(e)}finally{t.f()}}},{key:"dispatch",value:function(e){l.is.function(this.props[e])&&this.props[e]()}},{key:"onEvent",value:function(e){switch(e.type){case"click":this.play(this.props.onClick);break;case"mouseenter":this.hover||(this.hover=!0,this.play(this.props.whileHover));break;case"mouseleave":this.hover&&(this.hover=!1,this.play(this.props.whileHover,{reverse:!0}));break;case"focus":this.focus||(this.focus=!0,this.play(this.props.whileFocus));break;case"blur":this.focus&&(this.focus=!1,this.play(this.props.whileFocus,{reverse:!0}))}}},{key:"getBoundingBox",value:function(){var e,t={x:Number.MAX_VALUE,y:Number.MAX_VALUE,right:0,bottom:0},r=D(this.elements.length?this.elements:this.children);try{for(r.s();!(e=r.n()).done;){var n=e.value,i=this.elements.length?n.getBoundingClientRect():n.getBoundingBox();t.y=Math.min(i.y,t.y),t.x=Math.min(i.x,t.x),t.right=Math.max(i.right,t.right),t.bottom=Math.max(i.bottom,t.bottom)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"onScroll",value:function(){if(this.props.whileViewport){var e=l.inViewport(this.getBoundingBox(),this.props.viewportMargin),t=e.entered,r=e.left;t&&!this.inViewport&&(this.inViewport=!0,this.play(this.props.whileViewport),this.dispatch("onEnterViewport")),r&&this.inViewport&&(this.inViewport=!1,this.play(this.props.whileViewport,{reverse:!0,immediate:!0}),this.dispatch("onLeaveViewport"))}}},{key:"play",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.reverse,i=void 0!==n&&n,o=r.composite,a=void 0!==o&&o,s=r.immediate,u=void 0!==s&&s,c=r.delay,h=void 0===c?0:c,f=r.callback,p=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!(!e||this.props.disabled||this.props.group>0&&!p)){l.is.string(e)||(e="default"),this.dispatch("onAnimationStart");var y,d=this.animations[e],v=d.length(),m=0,g=D(this.children);try{for(g.s();!(y=g.n()).done;){var b=y.value;m=Math.max(m,b.play(e,{reverse:i,immediate:u,delay:h+v},!0))}}catch(e){g.e(e)}finally{g.f()}return this.manager.play(d,{reverse:i,composite:a,immediate:u,delay:i?m:h}),u&&clearTimeout(this.timeout),this.props.group||(this.timeout=setTimeout((function(){t.dispatch("onAnimationEnd"),l.is.function(f)&&f()}),1e3*(m+v))),v+(i?m:h)}}},{key:"stop",value:function(){this.manager.clear()}},{key:"prerender",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return a.Children.map(e,(function(e){if(!a.isValidElement(e))return e;var o={pathLength:1},s=t.elementIndex++;if(n&&(o.ref=function(e){return t.elements[s]=e}),r.isInstance(e)&&i&&!e.props.noCascade){var u=t.childIndex++;i=!1,o.group=t.props.group+1,o.ref=function(e){return t.children[u]=e},t.props.group||(o.active=t.props.active),l.mergeObjects(o,I(I({},t.props),e.props),t.constructor.cascadingProps)}return a.cloneElement(e,o,t.prerender(e.props.children,!1,i))}))}},{key:"render",value:function(){return this.elementIndex=this.childIndex=0,this.prerender(this.props.children)}}],[{key:"isInstance",value:function(e){return e.type===r||e.type.prototype instanceof r}}]),r}(a.Component);v.default(C,"events",["click","mouseenter","mouseleave","focus","blur"]),v.default(C,"cascadingProps",["animate","initial","animations","stagger"]),v.default(C,"defaultProps",{group:0,viewportMargin:.75,lazy:!0,paused:!1}),exports.Animatable=C;
@@ -1 +0,0 @@
1
- "use strict";var t=require("@babel/runtime/helpers/slicedToArray"),e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),a=require("@babel/runtime/helpers/inherits"),o=require("@babel/runtime/helpers/possibleConstructorReturn"),u=require("@babel/runtime/helpers/getPrototypeOf"),s=require("./link-3d1b05ee.js");function l(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var c=l(t),f=l(e),h=l(r),p=l(n),d=l(i),v=l(a),y=l(o),b=l(u);function m(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return g(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw a}}}}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var O=function t(e,r,n,i){if(s.is.object(e)){var a={};for(var o in e)a[o]=t(e[o],r[o],n,i);return a}return[i(e[0],r[0],n),e[1]]},j=function(t,e,r){return s.is.number(t)&&s.is.number(e)?t*(1-r)+e*r:r>.5?e:t},w=function(t,e,r){return j(t,e,(1-Math.cos(r*Math.PI))/2)},P=function(t,e,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,a={duration:i},o={},u=m(r);try{for(u.s();!(n=u.n()).done;){var s=n.value;"scale"==s?(a.scale={x:1,y:1},o.scale={x:1+(e.layout.width-t.layout.width)/t.layout.width,y:1+(e.layout.height-t.layout.height)/t.layout.height}):"translate"==s?(a.translate={x:0,y:0},o.translate={x:(e.layout.x-t.layout.x)*t.layout.parentWidth,y:(e.layout.y-t.layout.y)*t.layout.parentHeight}):(a[s]=t[s],o[s]=e[s])}}catch(t){u.e(t)}finally{u.f()}return new B(a,o)},S=Object.freeze({__proto__:null,interpolate:O,constant:function(t){return t},linear:j,ease:w,spring:function(t,e,r){return r=1-1*Math.exp(-3.6*r)*Math.cos(2.5*Math.pow(r,2)*Math.PI),j(t,e,r)},computeMorph:P}),I=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.reverse,i=void 0!==n&&n,a=r.repeat,o=void 0===a?1:a,u=r.delay,s=void 0===u?0:u,l=r.alternate,c=void 0!==l&&l;p.default(this,t),this.indices={},this.clip=e,this.t=0,this.T=e.duration*o+s,this.reverse=i,this.delay=s,this.alternate=c}return d.default(t,[{key:"getInterpolatedValue",value:function(t,e,r,n){if(s.is.function(e))e=s.convert(e(r,this.clip.duration),t),e=s.Units.toBase(e,t,n);else{t in this.indices||(this.indices[t]=this.reverse?e.length-1:0);var i,a=this.reverse?-1:1,o=this.indices[t],u=e[o],l=e[o+a],c=u.set;if(this.reverse?l.time>r:l.time<r){this.indices[t]=o+=a;var f=["start","end"],h=f[+!this.reverse],p=f[+this.reverse];h in u||p in l?(c=h in u?u[h]:l[p],i=!0):(u=e[o],l=e[o+a])}if(s.is.null(c)&&(c=s.getProperty(n,t)),c=s.Units.toBase(c,t,n),i)e=c;else{var d=s.is.null(l.set)?s.getProperty(n,t):l.set;d=s.Units.toBase(d,t,n);var v=S[l.interpolate||this.clip.interpolate]||w;e=O(c,d,(r-u.time)/(l.time-u.time),v)}}return e}},{key:"get",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r={},n=this.t>=this.T;if(this.t<this.delay||e&&!n&&!s.isVisible(t))return r;var i=this.t-this.delay,a=this.clip.duration,o=this.alternate&&Math.floor(i/a)%2==+!n;for(var u in i=n?a:i%a,i=s.xor(this.reverse,o)?a-i:i,r.origin=this.clip.origin,this.clip.properties)r[u]=this.getInterpolatedValue(u,this.clip.properties[u],i,t);return r}},{key:"step",value:function(t){var e=this.t>=this.T;return this.t+=t,e}}]),t}();function x(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=b.default(t);if(e){var i=b.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return y.default(this,r)}}var k=function(t){v.default(r,t);var e=x(r);function r(){var t;return p.default(this,r),(t=e.call(this,{duration:1/0,properties:{},origin:{x:.5,y:.5}})).isEmpty=!0,t.cache={},t}return d.default(r,[{key:"add",value:function(t,e){this.clip.properties[t]=e,this.isEmpty=!1}},{key:"getInterpolatedValue",value:function(t,e,r,n){s.is.null(e.internal.t)&&(e.internal.t=r),e.internal.t===r&&(this.cache[t]={});var i=e.internal.duration?Math.min((r-e.internal.t)/e.internal.duration,1):1,a=this.cache[t]||{};if(a.t===i)return a.value;var o=s.Units.toBase(s.convert(e(r,this.clip.duration),t),t,n),u=s.getProperty(n,t);u=s.Units.toBase(u,t,n);var l=O(u,o,i,j);return this.cache[t]={value:l,t:i},l}}]),r}(I),A=["duration","delay","repeat","alternate","interpolate","origin"];function q(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return M(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw a}}}}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function T(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?T(Object(r),!0).forEach((function(e){f.default(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var B=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.duration,n=void 0===r?1:r,i=e.delay,a=e.repeat,o=e.alternate,u=e.interpolate,l=e.origin,f=void 0===l?{x:.5,y:.5}:l,d=h.default(e,A),v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p.default(this,t),this.duration=n,this.origin=s.originToStr(f),this.channel=new k;var y=this.parse(d,v),b=c.default(y,2);this.properties=b[0],this.initials=b[1],this.isEmpty=s.is.empty(this.properties),this.interpolate=u,this.defaults={delay:i,repeat:a,alternate:o}}return d.default(t,[{key:"length",value:function(){return this.duration*(this.defaults.repeat||1)+(this.defaults.delay||0)}},{key:"parse",value:function(t,e){var r=this,n=function(n){var i=t[n];if(s.Link.isInstance(i))return r.channel.add(n,i),delete t[n],"continue";if(s.is.function(i))return"continue";(i=s.is.array(i)?i:[i]).length<2?i.unshift(n in e?e[n]:null):s.is.null(i[0])||(e[n]=i[0]);for(var a=i.map((function(t){return r.sanitize(t,n)})),o=0;o<a.length;o++)r.quantize(a,o);t[n]=a};for(var i in t)n(i);for(var a in e=z({},e))e[a]=s.convert(e[a],a);return[t,e]}},{key:"sanitize",value:function(t,e){s.is.object(t)||(t={set:t}),s.hasSomeKey(t,s.POSITIONS)||(t={set:t}),"set"in t||(t.set="start"in t?t.start:t.end),"time"in t&&t.time>this.duration&&delete t.time,t=z({},t);var r,n=q(s.POSITIONS);try{for(n.s();!(r=n.n()).done;){var i=r.value;i in t&&(t[i]=s.convert(t[i],e))}}catch(t){n.e(t)}finally{n.f()}return t}},{key:"quantize",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e-1;if("time"in t[e])return t[e].time;if(0==e||e==t.length-1)return t[e].time=0==e?0:this.duration;var n=this.quantize(t,r,r);return t[e].time=n+(this.quantize(t,e+1,r)-n)*((e-r)/(e-r+1))}},{key:"play",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new I(this,s.mergeObjects(t,this.defaults))}}]),t}(),C={create:function(t){var e=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.use=t.use.bind(t,e),t};return e.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t(e),n=c.default(r,2),i=n[0],a=n[1];return new B(i,a)},e},isInstance:function(t){return s.is.function(t)&&s.is.function(t.use)}};exports.Animation=C,exports.Clip=B,exports.computeMorph=P;