@infinityfx/lively 0.0.7 → 0.0.10

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-3b6d66e5.js"),t=require("@babel/runtime/helpers/objectWithoutProperties");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/regenerator");var o=n(e),i=n(t);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(u({opacity:1,duration:.65},e),{opacity:0})};var p=["direction"];function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=i.default(e,p),c=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":c=1,u=0,a={x:0,y:1};break;case"down":c=1,u=0,a={x:0,y:0}}return new r.Animation(l({scale:{x:1},origin:a,duration:.6},o),{scale:{x:c,y:u}})};var f=["direction"];function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return d.use=d.use.bind(d,e),d}d.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,c=i.default(e,f);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(y({clip:o.default({},n,0)},c),{clip:o.default({},n,1)})},exports.Move=r.Move,exports.Pop=r.Pop,exports.Fade=a,exports.Scale=b,exports.Wipe=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-426c8d94.js"),t=require("@babel/runtime/helpers/objectWithoutProperties");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/regenerator");var o=n(e),i=n(t);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(u({opacity:1,duration:.65},e),{opacity:0})};var p=["direction"];function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=i.default(e,p),c=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":c=1,u=0,a={x:0,y:1};break;case"down":c=1,u=0,a={x:0,y:0}}return new r.Animation(l({scale:{x:1},origin:a,duration:.6},o),{scale:{x:c,y:u}})};var f=["direction"];function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return d.use=d.use.bind(d,e),d}d.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,c=i.default(e,f);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(y({clip:o.default({},n,0)},c),{clip:o.default({},n,1)})},exports.Move=r.Move,exports.Pop=r.Pop,exports.Fade=a,exports.Scale=b,exports.Wipe=d;
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/typeof"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/defineProperty"),u=require("@babel/runtime/regenerator"),p=require("react"),c=require("./pop-3b6d66e5.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),v=require("@babel/runtime/helpers/toConsumableArray"),d=require("@babel/runtime/helpers/get");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=y(e),b=y(t),g=y(r),w=y(n),k=y(i),O=y(o),E=y(a),x=y(s),L=y(l),j=y(u),P=y(p),A=y(h),C=y(f),S=y(v),D=y(d);function M(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var I=function(e){O.default(v,e);var t,r,n,i,o,a,s,l,u,h,f=q(v);function v(e){var t;for(var r in w.default(this,v),(t=f.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return k.default(v,[{key:"toAnimation",value:function(e){return!e||"object"!==g.default(e)&&"function"!=typeof e?null:"use"in e?e.use():new c.Animation(R({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){e.type===v&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(h=b.default(j.default.mark((function e(){var t=this;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.elements.forEach((function(e){var r;null===(r=t.animations.default)||void 0===r||r.setInitial(e,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll()),this.resizeEventListener=this.onResize.bind(this),c.addEventListener("resize",this.resizeEventListener);case 4:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),c.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;return this.elements.forEach((function(n){var i=n.getBoundingClientRect().y;t=t&&i+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,r=r&&i>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),i=m.default(n,2),o=i[0],a=i[1];t=t&&o,r=r&&a})),[t,r]}},{key:"onScroll",value:(u=b.default(j.default.mark((function e(){var t,r,n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),r=m.default(t,2),n=r[0],i=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&i&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"onResize",value:(l=b.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return l.apply(this,arguments)})},{key:"onEnter",value:(s=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"onLeave",value:(a=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onFocus",value:(o=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"onBlur",value:(i=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onClick",value:(n=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setInitial",value:(r=b.default(j.default.mark((function e(t){var r,n,i=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=b.default(j.default.mark((function e(t){var r,n,i,o,a,s,l,u,p,h,f,v,d,y,m,b,g=this,w=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=w.length>1&&void 0!==w[1]?w[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,l=r.cascade,u=void 0!==l&&l,p=r.groupAdjust,h=void 0===p?0:p,f=r.cascadeDelay,v=void 0===f?0:f,d=r.staggerDelay,y=void 0===d?0:d,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in g.props?g.props.parentLevel-g.props.group:g.level+h;v=o?m.duration:v;var n=o?r*v:(g.props.parentLevel-r)*v;n=g.props.stagger*t+n+y,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:s})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:i<0?0:g.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&c.AnimationQueue.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=R(R({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===g.default(e[n])&&"object"===g.default(t[n])&&(r[n]=R(R({},t[n]),e[n]));return r}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,a=n.useElements,s=void 0!==a&&a,l=n.useEvents,u=void 0!==l&&l;if(!p.isValidElement(e))return e;var c={};e.type===v||e.type.prototype instanceof v||(s&&(c={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(c=R(R({},c),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===v||e.type.prototype instanceof v)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(c=R(R(R({},c),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:s?o:-1}}}));var h=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return p.cloneElement(e,c,h)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,p.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),v}(p.Component);L.default(I,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var V=["levels","animations"];function F(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 B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function H(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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var z=function(e){O.default(r,e);var t=H(r);function r(e){var n;return w.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=new Array(n.levels).fill(0).map((function(e,t){return t<n.props.animations.length?n.props.animations[t]:n.props.animations[n.props.animations.length-1]})),n}return k.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||p.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=C.default(n,V),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),P.default.createElement(I,A.default({animate:o},i),p.Children.map(e,(function(e){return p.isValidElement(e)?p.cloneElement(e,{},t.makeAnimatable(e.props.children,r-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,B({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(p.Component);function G(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 U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(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 T(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 T(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 T(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 N(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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}L.default(z,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var W=function(e){O.default(i,e);var t,r,n=N(i);function i(e){var t;return w.default(this,i),(t=n.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useContainer:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none"}},t}return k.default(i,[{key:"setUniqueId",value:function(){if(!this.props.parentGroup.length){"Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++,this.element.setAttribute("lively-morph-id",this.id);var e,t=K(this.children);try{for(t.s();!(e=t.n()).done;){var r=e.value.animatable;r&&(r.id=this.id),null==r||r.element.setAttribute("lively-morph-id",this.id)}}catch(e){t.e(e)}finally{t.f()}}}},{key:"reset",value:function(){this.element=this.elements[0],this.layoutOffset=this.props.useLayout&&this.state.useContainer,this.setUniqueId(),c.cacheElementStyles(this.element),this.animations={},this.animations.default=this.createUnmorphAnimation(),this.props.active||this.props.parentGroup.length||this.setInitial()}},{key:"componentDidMount",value:(r=b.default(j.default.mark((function e(){var t,r;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.element=this.elements[0],this.element){e.next=3;break}return e.abrupt("return");case 3:this.props.useLayout&&(t=getComputedStyle(this.element),"absolute"===(r=t.position)||"fixed"===r?this.setState({childStyles:{top:this.element.offsetTop,left:this.element.offsetLeft}}):this.setState({childStyles:{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},parentStyles:U({width:this.element.offsetWidth,height:this.element.offsetHeight},this.state.parentStyles),useContainer:!0})),this.reset();case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"componentDidUpdate",value:(t=b.default(j.default.mark((function e(t,r){var n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.useContainer!==this.state.useContainer&&this.reset(),t.active!==this.props.active){e.next=3;break}return e.abrupt("return");case 3:return this.props.active&&this.element.setAttribute("lively-morph-target",!0),e.next=6,c.AnimationQueue.sleep(.001);case 6:this.props.active?this.play("default"):(n=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(n.removeAttribute("lively-morph-target"),(i=n.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));t&&(this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)})))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,a=i.y-n.y;if(this.props.parentGroup.length){var s=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-s.x,a-=l.y-s.y}return[{x:0,y:0},{x:o,y:a},{x:o,y:a}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,a=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=i.properties;this.props.useLayout&&s.push.apply(s,S.default(i.layoutProperties));var l,u={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0}},p=K(s);try{for(p.s();!(l=p.n()).done;){var h=l.value;this.props.ignore.includes(h)||(u[h]=h in n?n[h]:a?[o[h],a[h],a[h]]:[o[h],o[h],o[h]])}}catch(e){p.e(e)}finally{p.f()}return new c.Animation(u)}},{key:"createMorphAnimation",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var r=e.type!==i?{}:{parentGroup:t.props.parentGroup+t.props.group};return p.cloneElement(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!p.isValidElement(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:U(U({},t.props.style),this.state.childStyles)},o=D.default(x.default(i.prototype),"render",this).call(this,p.cloneElement(t,n,r));return this.state.useContainer?p.cloneElement(t,{style:this.state.parentStyles},o):o}}]),i}(I);L.default(W,"properties",["position","scale","opacity","backgroundColor","color","interact"]),L.default(W,"layoutProperties",["borderRadius","fontSize"]),L.default(W,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",ignore:[]}),exports.Animatable=I,exports.Animate=z,exports.Morph=W;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/typeof"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/defineProperty"),u=require("@babel/runtime/regenerator"),p=require("react"),c=require("./pop-426c8d94.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),d=require("@babel/runtime/helpers/toConsumableArray"),v=require("@babel/runtime/helpers/get");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=y(e),g=y(t),b=y(r),w=y(n),k=y(i),O=y(o),E=y(a),x=y(s),L=y(l),j=y(u),A=y(p),P=y(h),C=y(f),S=y(d),D=y(v);function M(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var V=function(e){O.default(f,e);var t,r,n,i,o,a,s,l,u,h=q(f);function f(e){var t;for(var r in w.default(this,f),(t=h.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.elements=[],t.children=[],t.level=0,t}return k.default(f,[{key:"update",value:function(){var e=this;this.elements.forEach((function(t){var r;c.cacheElementStyles(t),null===(r=e.animations.default)||void 0===r||r.setInitial(t)}))}},{key:"toAnimation",value:function(e){return!e||"object"!==b.default(e)&&"function"!=typeof e?null:"use"in e?e.use():new c.Animation(R({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){(e.type===f||e.type.prototype instanceof f)&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(u=g.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),c.addEventListener("resize",this.resizeEventListener),this.update(!0),!("fonts"in document)||"loaded"===document.fonts.status){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update(!0);case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll());case 8:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),c.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;return this.elements.forEach((function(n){var i=n.getBoundingClientRect().y;t=t&&i+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,r=r&&i>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),i=m.default(n,2),o=i[0],a=i[1];t=t&&o,r=r&&a})),[t,r]}},{key:"onScroll",value:(l=g.default(j.default.mark((function e(){var t,r,n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),r=m.default(t,2),n=r[0],i=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&i&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"onResize",value:(s=g.default(j.default.mark((function e(){var t;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(t=this.nextResize)&&void 0!==t&&t.cancel&&this.nextResize.cancel(),this.nextResize=c.AnimationQueue.delay(this.update.bind(this),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"onEnter",value:(a=g.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onLeave",value:(o=g.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"onFocus",value:(i=g.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onBlur",value:(n=g.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"onClick",value:(r=g.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=g.default(j.default.mark((function e(t){var r,n,i,o,a,s,l,u,p,h,f,d,v,y,m,g,b=this,w=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=w.length>1&&void 0!==w[1]?w[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,l=r.cascade,u=void 0!==l&&l,p=r.groupAdjust,h=void 0===p?0:p,f=r.cascadeDelay,d=void 0===f?0:f,v=r.staggerDelay,y=void 0===v?0:v,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:g=0,this.elements.forEach((function(e,t){var r="group"in b.props?b.props.parentLevel-b.props.group:b.level+h;d=o?m.duration:d;var n=o?r*d:(b.props.parentLevel-r)*d;n=b.props.stagger*t+n+y,g=n>g?n:g,m.play(e,{delay:n,reverse:o,immediate:s})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:i<0?0:b.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&c.AnimationQueue.delay(n,g+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=R(R({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===b.default(e[n])&&"object"===b.default(t[n])&&(r[n]=R(R({},t[n]),e[n]));return r}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,a=n.useElements,s=void 0!==a&&a,l=n.useEvents,u=void 0!==l&&l;if(!p.isValidElement(e))return e;var c={};e.type===f||e.type.prototype instanceof f||(s&&(c={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(c=R(R({},c),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===f||e.type.prototype instanceof f)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(c=R(R(R({},c),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:s?o:-1}}}));var h=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return p.cloneElement(e,c,h)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,p.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),f}(p.Component);L.default(V,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var I=["levels","animations"];function F(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 z(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var U=function(e){O.default(r,e);var t=B(r);function r(e){var n;return w.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=new Array(n.levels).fill(0).map((function(e,t){return t<n.props.animations.length?n.props.animations[t]:n.props.animations[n.props.animations.length-1]})),n}return k.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||p.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=C.default(n,I),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),A.default.createElement(V,P.default({animate:o},i),p.Children.map(e,(function(e){return p.isValidElement(e)?p.cloneElement(e,{},t.makeAnimatable(e.props.children,r-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,z({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(p.Component);function H(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}function K(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 T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(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=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}L.default(U,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var Q=function(e){O.default(i,e);var t,r,n=N(i);function i(e){var t;return w.default(this,i),(t=n.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useLayout:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none",fontSize:"unset"}},t}return k.default(i,[{key:"layoutUpdate",value:function(){var e,t=getComputedStyle(this.element).position,r=!1;"absolute"===t||"fixed"===t?e={top:this.element.offsetTop,left:this.element.offsetLeft}:(e={position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},r=!0),this.setState({childStyles:e,parentStyles:T(T({},this.state.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight}),useLayout:r})}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.element=this.elements[0],this.element){if(e&&this.props.useLayout)return this.layoutUpdate();if(this.layoutOffset=this.props.useLayout&&this.state.useLayout,!this.props.parentGroup.length){this.setUniqueId(),c.cacheElementStyles(this.element),this.animations={default:this.createUnmorphAnimation()},this.props.active||this.animations.default.setInitial(this.element);var t,r=H(this.children);try{for(r.s();!(t=r.n()).done;){var n=t.value.animatable;n&&(n.setUniqueId(this.id),c.cacheElementStyles(n.element),n.animations={default:n.createUnmorphAnimation()},this.props.active||n.animations.default.setInitial(n.element))}}catch(e){r.e(e)}finally{r.f()}}}}},{key:"setUniqueId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;null!==e&&(this.id=e),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"shouldComponentUpdate",value:function(e){return e.active===this.props.active||(this.morph(e.active),!1)}},{key:"componentDidUpdate",value:(r=g.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"morph",value:(t=g.default(j.default.mark((function e(t){var r,n;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t&&this.element.setAttribute("lively-morph-target",!0),e.next=3,c.AnimationQueue.sleep(.001);case 3:t?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)}))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,a=i.y-n.y;if(this.props.parentGroup.length){var s=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-s.x,a-=l.y-s.y}return[{x:0,y:0},{x:o,y:a},{x:o,y:a}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,a=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=i.properties;this.props.useLayout&&s.push.apply(s,S.default(i.layoutProperties));var l,u={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},p=H(s);try{for(p.s();!(l=p.n()).done;){var h=l.value;this.props.ignore.includes(h)||(u[h]=h in n?n[h]:a?[o[h],a[h],a[h]]:[o[h],o[h],o[h]])}}catch(e){p.e(e)}finally{p.f()}return new c.Animation(u)}},{key:"createMorphAnimation",value:function(e){var t,r;if(!e)return this.createAnimation(null,{opacity:[1,0,0],interact:[!0,!1,!1]});var n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var r=e.type!==i?{}:{parentGroup:t.props.parentGroup+t.props.group};return p.cloneElement(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!p.isValidElement(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:T(T({},t.props.style),this.state.childStyles)},o=D.default(x.default(i.prototype),"render",this).call(this,p.cloneElement(t,n,r));return this.state.useLayout?p.cloneElement(t,{style:this.state.parentStyles},o):o}}]),i}(V);L.default(Q,"properties",["position","scale","opacity","backgroundColor","color","interact"]),L.default(Q,"layoutProperties",["borderRadius","fontSize"]),L.default(Q,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]}),exports.Animatable=V,exports.Animate=U,exports.Morph=Q;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/toConsumableArray"),a=require("@babel/runtime/helpers/typeof"),o=require("@babel/runtime/helpers/classCallCheck"),s=require("@babel/runtime/helpers/createClass"),l=require("@babel/runtime/regenerator");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(e),d=c(t),f=c(i),y=c(n),p=c(r),v=c(a),h=c(o),g=c(s),b=c(l),m=function(){function e(){h.default(this,e),this.queue=[],this.tick()}var t;return g.default(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=f.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),k=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=y.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},w=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=y.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},x=["delay","duration","repeat","interpolate","origin","useLayout"],L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.delay,n=void 0===i?0:i,r=t.duration,a=void 0===r?1:r,o=t.repeat,s=void 0===o?1:o,l=t.interpolate,c=void 0===l?"ease":l,u=t.origin,f=void 0===u?{x:.5,y:.5}:u,y=t.useLayout,p=void 0!==y&&y,v=d.default(t,x),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h.default(this,e),this.useLayout=p,this.keyframes=this.getKeyframes(v,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation="spring"===c?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":c,this.origin=this.originToStyle(f),this.repeat=s}var t;return g.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===v.default(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(p.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],a,r));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return k(i);if(i.match(/^rgba?\(.*\)$/i))return w(i);var a=parseFloat(i),o=i.match(/[^0-9\.]*$/i);return isNaN(a)?e.initials[t]:("%"===o&&(a/=100),o?[a,o]:a)}if("object"===v.default(i)){var s=Object.keys(i);("x"in i||"y"in i)&&(s=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(s=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(s=["left","right","top","bottom"]),s.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),a=Math.floor(r),o=e[a];if(a===e.length-1)return o;var s=e[a+1];if("object"===v.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=y.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[r]=t.toString(a,"px");break;case"backgroundColor":case"color":i[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"interact":i.pointerEvents=a?"all":"none";break;case"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var t=this.keyframes[0];this.apply(e,t,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),l=t[i],c=t.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(u,") * ");e.style[n]=d+.5*c,e.style[r]=d+1/c*.5}},{key:"apply",value:(t=f.default(b.default.mark((function e(t,i){var n,r,a=this,o=arguments;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],!("active"in i)){e.next=11;break}if("start"!==(r=Object.keys(i.active)[0])&&!n){e.next=10;break}if(t.style.display=i.active[r]?"":"none",n){e.next=8;break}return e.next=8,m.sleep(.001);case 8:e.next=11;break;case 10:m.delay((function(){t.style.display=i.active[r]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var n=y.default(e,2),r=n[0],o=n[1];return"width"===r?a.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===r?a.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===r||"padding"===r&&(i.width||i.height)||(t.style[r]=o))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"start",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.immediate,r=void 0!==n&&n,a=i.reverse,o=void 0!==a&&a,s=i.repeat,l=void 0===s?this.repeat:s;!e.Lively.animating||r?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.index=1,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),this.getNext(e,o,l)):e.Lively.queue.push([this,{reverse:o,repeat:l}])}},{key:"play",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.delay,n=void 0===i?0:i,r=t.immediate,a=void 0!==r&&r,o=t.reverse,s=void 0!==o&&o;e.style&&(this.delay||n?e.next=m.delay(this.start.bind(this,e,{immediate:a,reverse:s}),this.delay+n):this.start(e,{immediate:a,reverse:s}),e.Lively.animating=!0)}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=y.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.Lively.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.Lively.index++,e.Lively.next=m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();u.default(L,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var O=["direction"];function j(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function S(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?j(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):j(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return q.use=q.use.bind(q,e),q}function E(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function P(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?E(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):E(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function A(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A.use=A.use.bind(A,e),A}q.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,i=void 0===t?"up":t,n=d.default(e,O),r="0px",a="20px";switch(i){case"down":a="-20px";break;case"left":r="20px",a="0px";break;case"right":r="-20px",a="0px"}return new L(S({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},A.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new L(P({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=L,exports.AnimationQueue=m,exports.Move=q,exports.Pop=A,exports.addEventListener=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},exports.cacheElementStyles=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,l=t.borderRadius,c=t.padding,u=t.fontSize,d=e.getBoundingClientRect(),f=d.x,y=d.y;e.Lively.initials={x:f,y:y,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:l.split(" ")[0],padding:c.split(" ")[0]}},exports.removeEventListener=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]};
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-443325e9.js";export{M as Move,P as Pop}from"./pop-443325e9.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(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}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.use=i.use.bind(i,e),i}i.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(o({opacity:1,duration:.65},e),{opacity:0})};var c=["direction"];function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.use=u.use.bind(u,e),u}u.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,u=1,b={x:0,y:.5};switch(o){case"left":b.x=1;break;case"up":p=1,u=0,b={x:0,y:1};break;case"down":p=1,u=0,b={x:0,y:0}}return new r(s({scale:{x:1},origin:b,duration:.6},i),{scale:{x:p,y:u}})};var b=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O.use=O.use.bind(O,e),O}O.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,b);return["left","right","top","bottom"].includes(i)||(i="right"),new r(l({clip:e({},i,0)},c),{clip:e({},i,1)})};export{i as Fade,u as Scale,O as Wipe};
1
+ import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-00e75fce.js";export{M as Move,P as Pop}from"./pop-00e75fce.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(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}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.use=i.use.bind(i,e),i}i.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(o({opacity:1,duration:.65},e),{opacity:0})};var c=["direction"];function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.use=u.use.bind(u,e),u}u.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,u=1,b={x:0,y:.5};switch(o){case"left":b.x=1;break;case"up":p=1,u=0,b={x:0,y:1};break;case"down":p=1,u=0,b={x:0,y:0}}return new r(s({scale:{x:1},origin:b,duration:.6},i),{scale:{x:p,y:u}})};var b=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return f.use=f.use.bind(f,e),f}f.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,b);return["left","right","top","bottom"].includes(i)||(i="right"),new r(l({clip:e({},i,0)},c),{clip:e({},i,1)})};export{i as Fade,u as Scale,f as Wipe};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{A as y,a as d,r as m,b as g,M as b,P as w,c as k}from"./pop-443325e9.js";import O from"@babel/runtime/helpers/extends";import x from"@babel/runtime/helpers/objectWithoutProperties";import P from"@babel/runtime/helpers/toConsumableArray";import j from"@babel/runtime/helpers/get";function L(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?L(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var C=function(s){o(C,v);var a,l,p,b,w,k,O,x,P,j,L=E(C);function C(e){var t;for(var r in n(this,C),(t=L.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return i(C,[{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():new y(A({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){e.type===C&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(j=t(u.mark((function e(){var t=this;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.elements.forEach((function(e){var r;null===(r=t.animations.default)||void 0===r||r.setInitial(e,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),d("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll()),this.resizeEventListener=this.onResize.bind(this),d("resize",this.resizeEventListener);case 4:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){m("scroll",this.scrollEventListener),m("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;return this.elements.forEach((function(e){var i=e.getBoundingClientRect().y;r=r&&i+e.clientHeight*(1-t.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+e.clientHeight*t.viewportMargin})),this.elements.length||this.children.forEach((function(t){var i=t.animatable.inViewport(),o=e(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(P=t(u.mark((function t(){var r,n,i,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(Date.now()-this.scrollDelta<350)){t.next=2;break}return t.abrupt("return");case 2:this.scrollDelta=Date.now(),r=this.inViewport(),n=e(r,2),i=n[0],o=n[1],!this.inView&&i&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return P.apply(this,arguments)})},{key:"onResize",value:(x=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"onLeave",value:(k=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"onFocus",value:(w=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"onBlur",value:(b=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"onClick",value:(p=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setInitial",value:(l=t(u.mark((function e(t){var r,n,i=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=t(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,y,d,m,b,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,y=r.staggerDelay,d=void 0===y?0:y,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+d,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&g.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=A(A({},t),e);for(var i in n)["children","parentLevel","ref"].includes(i)?delete n[i]:Array.isArray(e[i])||Array.isArray(t[i])||"object"===r(e[i])&&"object"===r(t[i])&&(n[i]=A(A({},t[i]),e[i]));return n}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,s=n.useElements,a=void 0!==s&&s,l=n.useEvents,u=void 0!==l&&l;if(!h(e))return e;var p={};e.type===C||e.type.prototype instanceof C||(a&&(p={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(p=A(A({},p),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===C||e.type.prototype instanceof C)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(p=A(A(A({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:a?o:-1}}}));var v=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return f(e,p,v)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,c.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),C}();l(C,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var S=["levels","animations"];function D(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 M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var I=function(e){o(r,v);var t=R(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return i(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||c.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=x(n,S),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(C,O({animate:o},i),c.map(e,(function(e){return h(e)?f(e,{},t.makeAnimatable(e.props.children,r-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,M({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function F(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 V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(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 H(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 H(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,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function H(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 z(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}l(I,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[b,w]});var G=function(e){o(p,C);var r,s,l=z(p);function p(e){var t;return n(this,p),(t=l.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useContainer:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none"}},t}return i(p,[{key:"setUniqueId",value:function(){if(!this.props.parentGroup.length){"Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++,this.element.setAttribute("lively-morph-id",this.id);var e,t=B(this.children);try{for(t.s();!(e=t.n()).done;){var r=e.value.animatable;r&&(r.id=this.id),null==r||r.element.setAttribute("lively-morph-id",this.id)}}catch(e){t.e(e)}finally{t.f()}}}},{key:"reset",value:function(){this.element=this.elements[0],this.layoutOffset=this.props.useLayout&&this.state.useContainer,this.setUniqueId(),k(this.element),this.animations={},this.animations.default=this.createUnmorphAnimation(),this.props.active||this.props.parentGroup.length||this.setInitial()}},{key:"componentDidMount",value:(s=t(u.mark((function e(){var t,r;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.element=this.elements[0],this.element){e.next=3;break}return e.abrupt("return");case 3:this.props.useLayout&&(t=getComputedStyle(this.element),"absolute"===(r=t.position)||"fixed"===r?this.setState({childStyles:{top:this.element.offsetTop,left:this.element.offsetLeft}}):this.setState({childStyles:{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},parentStyles:V({width:this.element.offsetWidth,height:this.element.offsetHeight},this.state.parentStyles),useContainer:!0})),this.reset();case 5:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"componentDidUpdate",value:(r=t(u.mark((function e(t,r){var n,i;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.useContainer!==this.state.useContainer&&this.reset(),t.active!==this.props.active){e.next=3;break}return e.abrupt("return");case 3:return this.props.active&&this.element.setAttribute("lively-morph-target",!0),e.next=6,g.sleep(.001);case 6:this.props.active?this.play("default"):(n=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(n.removeAttribute("lively-morph-target"),(i=n.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));t&&(this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)})))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,s=i.y-n.y;if(this.props.parentGroup.length){var a=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-a.x,s-=l.y-a.y}return[{x:0,y:0},{x:o,y:s},{x:o,y:s}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,o=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=p.properties;this.props.useLayout&&s.push.apply(s,P(p.layoutProperties));var a,l={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0}},u=B(s);try{for(u.s();!(a=u.n()).done;){var c=a.value;this.props.ignore.includes(c)||(l[c]=c in n?n[c]:o?[i[c],o[c],o[c]]:[i[c],i[c],i[c]])}}catch(e){u.e(e)}finally{u.f()}return new y(l)}},{key:"createMorphAnimation",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var r=e.type!==p?{}:{parentGroup:t.props.parentGroup+t.props.group};return f(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!h(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:V(V({},t.props.style),this.state.childStyles)},i=j(a(p.prototype),"render",this).call(this,f(t,n,r));return this.state.useContainer?f(t,{style:this.state.parentStyles},i):i}}]),p}();l(G,"properties",["position","scale","opacity","backgroundColor","color","interact"]),l(G,"layoutProperties",["borderRadius","fontSize"]),l(G,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",ignore:[]});export{C as Animatable,I as Animate,G as Morph};
1
+ import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{c as y,A as d,a as m,r as g,b,M as w,P as k}from"./pop-00e75fce.js";import O from"@babel/runtime/helpers/extends";import x from"@babel/runtime/helpers/objectWithoutProperties";import L from"@babel/runtime/helpers/toConsumableArray";import P from"@babel/runtime/helpers/get";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){l(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 E(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var S=function(s){o(S,v);var a,l,p,w,k,O,x,L,P,j=E(S);function S(e){var t;for(var r in n(this,S),(t=j.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.elements=[],t.children=[],t.level=0,t}return i(S,[{key:"update",value:function(){var e=this;this.elements.forEach((function(t){var r;y(t),null===(r=e.animations.default)||void 0===r||r.setInitial(t)}))}},{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():new d(A({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){(e.type===S||e.type.prototype instanceof S)&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(P=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),m("resize",this.resizeEventListener),this.update(!0),!("fonts"in document)||"loaded"===document.fonts.status){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update(!0);case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),m("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll());case 8:case"end":return e.stop()}}),e,this)}))),function(){return P.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){g("scroll",this.scrollEventListener),g("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;return this.elements.forEach((function(e){var i=e.getBoundingClientRect().y;r=r&&i+e.clientHeight*(1-t.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+e.clientHeight*t.viewportMargin})),this.elements.length||this.children.forEach((function(t){var i=t.animatable.inViewport(),o=e(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(L=t(u.mark((function t(){var r,n,i,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(Date.now()-this.scrollDelta<350)){t.next=2;break}return t.abrupt("return");case 2:this.scrollDelta=Date.now(),r=this.inViewport(),n=e(r,2),i=n[0],o=n[1],!this.inView&&i&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return L.apply(this,arguments)})},{key:"onResize",value:(x=t(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(t=this.nextResize)&&void 0!==t&&t.cancel&&this.nextResize.cancel(),this.nextResize=b.delay(this.update.bind(this),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"onLeave",value:(k=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"onFocus",value:(w=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"onBlur",value:(p=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"onClick",value:(l=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=t(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,y,d,m,g,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,y=r.staggerDelay,d=void 0===y?0:y,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:g=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+d,g=n>g?n:g,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&b.delay(n,g+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=A(A({},t),e);for(var i in n)["children","parentLevel","ref"].includes(i)?delete n[i]:Array.isArray(e[i])||Array.isArray(t[i])||"object"===r(e[i])&&"object"===r(t[i])&&(n[i]=A(A({},t[i]),e[i]));return n}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,s=n.useElements,a=void 0!==s&&s,l=n.useEvents,u=void 0!==l&&l;if(!h(e))return e;var p={};e.type===S||e.type.prototype instanceof S||(a&&(p={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(p=A(A({},p),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===S||e.type.prototype instanceof S)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(p=A(A(A({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:a?o:-1}}}));var v=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return f(e,p,v)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,c.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),S}();l(S,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var C=["levels","animations"];function D(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function M(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var I=function(e){o(r,v);var t=M(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return i(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||c.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=x(n,C),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(S,O({animate:o},i),c.map(e,(function(e){return h(e)?f(e,{},t.makeAnimatable(e.props.children,r-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,R({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function F(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 V(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 V(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,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function V(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 z(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 B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(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=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}l(I,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[w,k]});var H=function(e){o(p,S);var r,s,l=U(p);function p(e){var t;return n(this,p),(t=l.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useLayout:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none",fontSize:"unset"}},t}return i(p,[{key:"layoutUpdate",value:function(){var e,t=getComputedStyle(this.element).position,r=!1;"absolute"===t||"fixed"===t?e={top:this.element.offsetTop,left:this.element.offsetLeft}:(e={position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},r=!0),this.setState({childStyles:e,parentStyles:B(B({},this.state.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight}),useLayout:r})}},{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.element=this.elements[0],this.element){if(e&&this.props.useLayout)return this.layoutUpdate();if(this.layoutOffset=this.props.useLayout&&this.state.useLayout,!this.props.parentGroup.length){this.setUniqueId(),y(this.element),this.animations={default:this.createUnmorphAnimation()},this.props.active||this.animations.default.setInitial(this.element);var t,r=F(this.children);try{for(r.s();!(t=r.n()).done;){var n=t.value.animatable;n&&(n.setUniqueId(this.id),y(n.element),n.animations={default:n.createUnmorphAnimation()},this.props.active||n.animations.default.setInitial(n.element))}}catch(e){r.e(e)}finally{r.f()}}}}},{key:"setUniqueId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;null!==e&&(this.id=e),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"shouldComponentUpdate",value:function(e){return e.active===this.props.active||(this.morph(e.active),!1)}},{key:"componentDidUpdate",value:(s=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"morph",value:(r=t(u.mark((function e(t){var r,n;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t&&this.element.setAttribute("lively-morph-target",!0),e.next=3,b.sleep(.001);case 3:t?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)}))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,s=i.y-n.y;if(this.props.parentGroup.length){var a=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-a.x,s-=l.y-a.y}return[{x:0,y:0},{x:o,y:s},{x:o,y:s}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,o=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=p.properties;this.props.useLayout&&s.push.apply(s,L(p.layoutProperties));var a,l={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},u=F(s);try{for(u.s();!(a=u.n()).done;){var c=a.value;this.props.ignore.includes(c)||(l[c]=c in n?n[c]:o?[i[c],o[c],o[c]]:[i[c],i[c],i[c]])}}catch(e){u.e(e)}finally{u.f()}return new d(l)}},{key:"createMorphAnimation",value:function(e){var t,r;if(!e)return this.createAnimation(null,{opacity:[1,0,0],interact:[!0,!1,!1]});var n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var r=e.type!==p?{}:{parentGroup:t.props.parentGroup+t.props.group};return f(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!h(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:B(B({},t.props.style),this.state.childStyles)},i=P(a(p.prototype),"render",this).call(this,f(t,n,r));return this.state.useLayout?f(t,{style:this.state.parentStyles},i):i}}]),p}();l(H,"properties",["position","scale","opacity","backgroundColor","color","interact"]),l(H,"layoutProperties",["borderRadius","fontSize"]),l(H,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]});export{S as Animatable,I as Animate,H as Morph};
@@ -0,0 +1 @@
1
+ import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import s from"@babel/runtime/helpers/createClass";import c from"@babel/runtime/regenerator";var l=function(){function e(){o(this,e),this.queue=[],this.tick()}var t;return s(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=i(c.mark((function e(){var t,i;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),u=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(a.padStart(2,a),16),b:parseInt(o.padStart(2,o),16),a:void 0!==s?parseInt(s,16):255}},y=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},d=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},p=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]},v=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,c=t.borderRadius,l=t.padding,u=t.fontSize,y=e.getBoundingClientRect(),d=y.x,p=y.y;e.Lively.initials={x:d,y:p,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:c.split(" ")[0],padding:l.split(" ")[0]}},f=["delay","duration","repeat","interpolate","origin","useLayout"],h=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.delay,r=void 0===n?0:n,a=i.duration,s=void 0===a?1:a,c=i.repeat,l=void 0===c?1:c,u=i.interpolate,y=void 0===u?"ease":u,d=i.origin,p=void 0===d?{x:.5,y:.5}:d,v=i.useLayout,h=void 0!==v&&v,g=t(i,f),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.useLayout=h,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation="spring"===y?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":y,this.origin=this.originToStyle(p),this.repeat=l}var d;return s(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===a(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,o=function(o){var s=o in n?n[o]:e.initials[o];Array.isArray(t[o])||(t[o]=[t[o]]),t[o]=t[o].length>1?t[o]:[s].concat(r(t[o])),t[o]=t[o].map((function(e){return i.sanitize(o,e)})),a=t[o].length>a?t[o].length:a};for(var s in t)o(s);return new Array(a).fill(0).map((function(n,r){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],r,a));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return u(i);if(i.match(/^rgba?\(.*\)$/i))return y(i);var o=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(o)?e.initials[t]:("%"===s&&(o/=100),s?[o,s]:o)}if("object"===a(i)){var c=Object.keys(i);("x"in i||"y"in i)&&(c=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(c=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(c=["left","right","top","bottom"]),c.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),o=Math.floor(r),s=e[o];if(o===e.length-1)return s;var c=e[o+1];if("object"===a(s)){var l={};return Object.keys(s).forEach((function(e){l[e]=n.interpolate(s[e],c[e],r-o)})),l}return this.interpolate(s,c,r-o)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var r=n(e,2),a=r[0],o=r[1];switch(a){case"position":i.transform+="translate(".concat(t.toString(o.x,"px"),", ").concat(t.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),t.useLayout){i.width=t.toLength(o.x),i.height=t.toLength(o.y);break}i.transform+="scale(".concat(t.toString(o.x,"%"),", ").concat(t.toString(o.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(o),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(o.top,"%")," ").concat(t.toString(o.right,"%")," ").concat(t.toString(o.bottom,"%")," ").concat(t.toString(o.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[a]=t.toString(o,"px");break;case"backgroundColor":case"color":i[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":i.pointerEvents=o?"all":"none";break;case"opacity":case"active":i[a]=o}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var t=this.keyframes[0];this.apply(e,t,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),c=t[i],l=t.padding?1:o/(0===s?1e-6:s);"string"==typeof c&&(c="calc(".concat(c," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(c," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var y="calc(min(calc(".concat(a," * ").concat(c,"), ").concat(u,") * ");e.style[n]=y+.5*l,e.style[r]=y+1/l*.5}},{key:"apply",value:(d=i(c.mark((function e(t,i){var r,a,o=this,s=arguments;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],!("active"in i)){e.next=11;break}if("start"!==(a=Object.keys(i.active)[0])&&!r){e.next=10;break}if(t.style.display=i.active[a]?"":"none",r){e.next=8;break}return e.next=8,l.sleep(.001);case 8:e.next=11;break;case 10:l.delay((function(){t.style.display=i.active[a]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var r=n(e,2),a=r[0],s=r[1];return"width"===a?o.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===a?o.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===a||"padding"===a&&(i.width||i.height)||(t.style[a]=s))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"start",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.immediate,r=void 0!==n&&n,a=i.reverse,o=void 0!==a&&a,s=i.repeat,c=void 0===s?this.repeat:s;!e.Lively.animating||r?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.index=1,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),this.getNext(e,o,c)):e.Lively.queue.push([this,{reverse:o,repeat:c}])}},{key:"play",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.delay,n=void 0===i?0:i,r=t.immediate,a=void 0!==r&&r,o=t.reverse,s=void 0!==o&&o;e.style&&(this.delay||n?e.next=l.delay(this.start.bind(this,e,{immediate:a,reverse:s}),this.delay+n):this.start(e,{immediate:a,reverse:s}),e.Lively.animating=!0)}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=n(a,2),s=o[0],c=o[1];return s?s.start(e,c):void(r>1&&this.start(e,{reverse:i,repeat:r-1}))}var u=e.Lively.index;i&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){t.apply(e,t.keyframes[u])})),e.Lively.index++,e.Lively.next=l.delay((function(){return t.getNext(e,i,r)}),this.delta)}}]),e}();e(h,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var g=["direction"];function b(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function m(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?b(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function k(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return k.use=k.use.bind(k,e),k}function w(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function x(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L.use=L.use.bind(L,e),L}k.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.direction,n=void 0===i?"up":i,r=t(e,g),a="0px",o="20px";switch(n){case"down":o="-20px";break;case"left":a="20px",o="0px";break;case"right":a="-20px",o="0px"}return new h(m({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:a,y:o},opacity:0})},L.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new h(x({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{h as A,k as M,L as P,d as a,l as b,v as c,p as r};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinityfx/lively",
3
- "version": "0.0.7",
3
+ "version": "0.0.10",
4
4
  "description": "Zero configuration, performant react animation library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1 +0,0 @@
1
- "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/toConsumableArray"),a=require("@babel/runtime/helpers/typeof"),o=require("@babel/runtime/helpers/classCallCheck"),s=require("@babel/runtime/helpers/createClass"),l=require("@babel/runtime/regenerator");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(e),d=c(t),f=c(i),p=c(n),y=c(r),v=c(a),h=c(o),g=c(s),b=c(l),m=function(){function e(){h.default(this,e),this.queue=[],this.tick()}var t,i;return g.default(e,[{key:"tick",value:(i=f.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:(t=f.default(b.default.mark((function e(t,i){return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),k=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},w=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},x=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,l=t.borderRadius,c=t.padding,u=t.fontSize,d=e.getBoundingClientRect(),f=d.x,p=d.y;e.Lively.initials={x:f,y:p,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:l.split(" ")[0],padding:c.split(" ")[0]}},L=["delay","duration","repeat","interpolate","origin","useLayout"],O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.delay,n=void 0===i?0:i,r=t.duration,a=void 0===r?1:r,o=t.repeat,s=void 0===o?1:o,l=t.interpolate,c=void 0===l?"ease":l,u=t.origin,f=void 0===u?{x:.5,y:.5}:u,p=t.useLayout,y=void 0!==p&&p,v=d.default(t,L),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h.default(this,e),this.useLayout=y,this.keyframes=this.getKeyframes(v,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation="spring"===c?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":c,this.origin=this.originToStyle(f),this.repeat=s}var t;return g.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===v.default(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(y.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],a,r));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return k(i);if(i.match(/^rgba?\(.*\)$/i))return w(i);var a=parseFloat(i),o=i.match(/[^0-9\.]*$/i);return isNaN(a)?e.initials[t]:("%"===o&&(a/=100),o?[a,o]:a)}if("object"===v.default(i)){var s=Object.keys(i);("x"in i||"y"in i)&&(s=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(s=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(s=["left","right","top","bottom"]),s.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),a=Math.floor(r),o=e[a];if(a===e.length-1)return o;var s=e[a+1];if("object"===v.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=p.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[r]=t.toString(a,"px");break;case"backgroundColor":case"color":i[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"interact":i.pointerEvents=a?"all":"none";break;case"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&x(e),e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),l=t[i],c=t.padding?1:o/s;"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(u,") * ");e.style[n]=d+.5*c,e.style[r]=d+1/c*.5}},{key:"apply",value:(t=f.default(b.default.mark((function e(t,i){var n,r,a=this,o=arguments;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],!("active"in i)){e.next=11;break}if("start"!==(r=Object.keys(i.active)[0])&&!n){e.next=10;break}if(t.style.display=i.active[r]?"":"none",n){e.next=8;break}return e.next=8,m.sleep(.001);case 8:e.next=11;break;case 10:m.delay((function(){t.style.display=i.active[r]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var n=p.default(e,2),r=n[0],o=n[1];return"width"===r?a.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===r?a.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===r||"padding"===r&&(i.width||i.height)||(t.style[r]=o))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.Lively.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.animating=!0,e.Lively.index=1,this.getNext(e,a,s)):e.Lively.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?m.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=p.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.Lively.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.Lively.index++,m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();u.default(O,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var j=["direction"];function S(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function q(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?S(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E.use=E.use.bind(E,e),E}function P(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function A(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?P(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):P(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return D.use=D.use.bind(D,e),D}E.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,i=void 0===t?"up":t,n=d.default(e,j),r="0px",a="20px";switch(i){case"down":a="-20px";break;case"left":r="20px",a="0px";break;case"right":r="-20px",a="0px"}return new O(q({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},D.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new O(A({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=O,exports.AnimationQueue=m,exports.Move=E,exports.Pop=D,exports.addEventListener=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},exports.cacheElementStyles=x,exports.removeEventListener=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]};
@@ -1 +0,0 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import s from"@babel/runtime/helpers/createClass";import c from"@babel/runtime/regenerator";var l=function(){function e(){o(this,e),this.queue=[],this.tick()}var t,n;return s(e,[{key:"tick",value:(n=i(c.mark((function e(){var t,i;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:(t=i(c.mark((function e(t,i){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),u=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(a.padStart(2,a),16),b:parseInt(o.padStart(2,o),16),a:void 0!==s?parseInt(s,16):255}},p=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},y=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},d=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]},f=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,c=t.borderRadius,l=t.padding,u=t.fontSize,p=e.getBoundingClientRect(),y=p.x,d=p.y;e.Lively.initials={x:y,y:d,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:c.split(" ")[0],padding:l.split(" ")[0]}},v=["delay","duration","repeat","interpolate","origin","useLayout"],h=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.delay,r=void 0===n?0:n,a=i.duration,s=void 0===a?1:a,c=i.repeat,l=void 0===c?1:c,u=i.interpolate,p=void 0===u?"ease":u,y=i.origin,d=void 0===y?{x:.5,y:.5}:y,f=i.useLayout,h=void 0!==f&&f,g=t(i,v),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.useLayout=h,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation="spring"===p?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":p,this.origin=this.originToStyle(d),this.repeat=l}var y;return s(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===a(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,o=function(o){var s=o in n?n[o]:e.initials[o];Array.isArray(t[o])||(t[o]=[t[o]]),t[o]=t[o].length>1?t[o]:[s].concat(r(t[o])),t[o]=t[o].map((function(e){return i.sanitize(o,e)})),a=t[o].length>a?t[o].length:a};for(var s in t)o(s);return new Array(a).fill(0).map((function(n,r){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],r,a));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return u(i);if(i.match(/^rgba?\(.*\)$/i))return p(i);var o=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(o)?e.initials[t]:("%"===s&&(o/=100),s?[o,s]:o)}if("object"===a(i)){var c=Object.keys(i);("x"in i||"y"in i)&&(c=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(c=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(c=["left","right","top","bottom"]),c.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),o=Math.floor(r),s=e[o];if(o===e.length-1)return s;var c=e[o+1];if("object"===a(s)){var l={};return Object.keys(s).forEach((function(e){l[e]=n.interpolate(s[e],c[e],r-o)})),l}return this.interpolate(s,c,r-o)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var r=n(e,2),a=r[0],o=r[1];switch(a){case"position":i.transform+="translate(".concat(t.toString(o.x,"px"),", ").concat(t.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),t.useLayout){i.width=t.toLength(o.x),i.height=t.toLength(o.y);break}i.transform+="scale(".concat(t.toString(o.x,"%"),", ").concat(t.toString(o.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(o),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(o.top,"%")," ").concat(t.toString(o.right,"%")," ").concat(t.toString(o.bottom,"%")," ").concat(t.toString(o.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[a]=t.toString(o,"px");break;case"backgroundColor":case"color":i[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":i.pointerEvents=o?"all":"none";break;case"opacity":case"active":i[a]=o}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&f(e),e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),c=t[i],l=t.padding?1:o/s;"string"==typeof c&&(c="calc(".concat(c," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(c," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var p="calc(min(calc(".concat(a," * ").concat(c,"), ").concat(u,") * ");e.style[n]=p+.5*l,e.style[r]=p+1/l*.5}},{key:"apply",value:(y=i(c.mark((function e(t,i){var r,a,o=this,s=arguments;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],!("active"in i)){e.next=11;break}if("start"!==(a=Object.keys(i.active)[0])&&!r){e.next=10;break}if(t.style.display=i.active[a]?"":"none",r){e.next=8;break}return e.next=8,l.sleep(.001);case 8:e.next=11;break;case 10:l.delay((function(){t.style.display=i.active[a]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var r=n(e,2),a=r[0],s=r[1];return"width"===a?o.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===a?o.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===a||"padding"===a&&(i.width||i.height)||(t.style[a]=s))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.Lively.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.animating=!0,e.Lively.index=1,this.getNext(e,a,s)):e.Lively.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,c=void 0!==s&&s;e.style&&(this.delay||r?l.delay((function(){return t.start(e,{immediate:o,reverse:c})}),this.delay+r):this.start(e,{immediate:o,reverse:c}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=n(a,2),s=o[0],c=o[1];return s?s.start(e,c):void(r>1&&this.start(e,{reverse:i,repeat:r-1}))}var u=e.Lively.index;i&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){t.apply(e,t.keyframes[u])})),e.Lively.index++,l.delay((function(){return t.getNext(e,i,r)}),this.delta)}}]),e}();e(h,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var g=["direction"];function b(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function m(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?b(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function k(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return k.use=k.use.bind(k,e),k}function w(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function x(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L.use=L.use.bind(L,e),L}k.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.direction,n=void 0===i?"up":i,r=t(e,g),a="0px",o="20px";switch(n){case"down":o="-20px";break;case"left":a="20px",o="0px";break;case"right":a="-20px",o="0px"}return new h(m({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:a,y:o},opacity:0})},L.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new h(x({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{h as A,k as M,L as P,y as a,l as b,f as c,d as r};