@infinityfx/lively 0.2.2 → 0.2.3
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.
- package/dist/cjs/{animatable-a4bb5fae.js → animatable-62e7223b.js} +1 -1
- package/dist/cjs/animate.js +1 -1
- package/dist/cjs/animation-1595965d.js +1 -0
- package/dist/cjs/animations.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{pop-4d31c962.js → pop-592e65c5.js} +1 -1
- package/dist/esm/{animatable-9f51f204.js → animatable-54740b57.js} +1 -1
- package/dist/esm/animate.js +1 -1
- package/dist/esm/animation-7720f4a3.js +1 -0
- package/dist/esm/animations.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/{pop-102dfc2c.js → pop-dc41899a.js} +1 -1
- package/package.json +1 -1
- package/dist/cjs/animation-4153d232.js +0 -1
- package/dist/esm/animation-d10c9aed.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";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"),u=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),c=require("react"),p=require("./animation-4153d232.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=h(e),d=h(t),v=h(r),y=h(n),m=h(i),w=h(o),b=h(a),g=h(s),k=h(u),x=h(l);function E(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 L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){k.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(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 C(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 C(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 C(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 O(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=g.default(e);if(t){var i=g.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return b.default(this,r)}}var A=function(e){w.default(g,e);var t,r,n,i,o,a,s,u,l,h,b=O(g);function g(e){var t;for(var r in y.default(this,g),(t=b.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 m.default(g,[{key:"update",value:function(){var e,t=j(this.elements);try{for(t.s();!(e=t.n()).done;){var r,n=e.value;p.cacheElementStyles(n),null===(r=this.animations.default)||void 0===r||r.setToLast(n,!0)}}catch(e){t.e(e)}finally{t.f()}}},{key:"toAnimation",value:function(e){return!e||"object"!==v.default(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new p.Animation(L({},e),this.props.initial):null}},{key:"componentDidMount",value:(h=d.default(x.default.mark((function e(){var t=this;return x.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),p.addEventListener("resize",this.resizeEventListener),this.update(),!("fonts"in document)){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update({mount:!0});case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),p.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&p.AnimationQueue.delay((function(){return t.onScroll()}),.001));case 8:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"componentDidUpdate",value:(l=d.default(x.default.mark((function e(){return x.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 l.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){p.removeEventListener("scroll",this.scrollEventListener),p.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;if(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){var n,i=j(this.children);try{for(i.s();!(n=i.n()).done;){var o=n.value.animatable.inViewport(),a=f.default(o,2),s=a[0],u=a[1];t=t&&s,r=r&&u}}catch(e){i.e(e)}finally{i.f()}}return[t,r]}},{key:"onScroll",value:(u=d.default(x.default.mark((function e(){var t,r,n,i;return x.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=f.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:(s=d.default(x.default.mark((function e(){var t;return x.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=p.AnimationQueue.delay(this.update.bind(this,{mount:!0}),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"onEnter",value:(a=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n,i,o,a,s,u,l,c,h,f,d,v,y,m,w,b,g,k,E,L,C=this,O=arguments;return x.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=O.length>1&&void 0!==O[1]?O[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,u=r.cascade,l=void 0!==u&&u,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,d=void 0===f?0:f,v=r.staggerDelay,y=void 0===v?0:v,!(this.props.parentLevel>0)||l){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:w=0,this.elements.forEach((function(e,t){var r="group"in C.props?C.props.parentLevel-C.props.group:C.level+h;d=o?m.duration:d;var n=o?r*d:(C.props.parentLevel-r)*d;n=C.props.stagger*t+n+y,w=n>w?n:w,m.play(e,{delay:n,reverse:o,immediate:s})})),b=j(this.children);try{for(b.s();!(g=b.n()).done;)k=g.value,E=k.animatable,L=k.staggerIndex,E.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:L<0?0:this.props.stagger*L,cascadeDelay:m.duration,groupAdjust:L<0?0:1})}catch(e){b.e(e)}finally{b.f()}n&&p.AnimationQueue.delay(n,w+m.duration);case 11: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=L(L({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===v.default(e[n])&&"object"===v.default(t[n])&&(r[n]=L(L({},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,u=n.useEvents,l=void 0===u||u;if(!c.isValidElement(e))return e;var p={};if(e.type===g||e.type.prototype instanceof g||(s&&(p={ref:function(e){return r.elements[o]=e}}),l&&(this.props.parentLevel<1||this.props.noCascade)&&(p=L(L({},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)}}),l=!1)),(e.type===g||e.type.prototype instanceof g)&&(null===(t=e.props)||void 0===t||!t.noCascade)){var h=this.childrenIndex++;p=L(L(L({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[h]={animatable:e,staggerIndex:s?o:-1}}})}var f=c.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:l})}));return c.cloneElement(e,p,f)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.Children.forEach(e,(function(e){var i;if(c.isValidElement(e)){(e.type===g||e.type.prototype instanceof g)&&(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:"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.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0})}))}}]),g}(c.Component);k.default(A,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}}),exports.Animatable=A;
|
|
1
|
+
"use strict";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"),u=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),c=require("react"),p=require("./animation-1595965d.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=h(e),d=h(t),v=h(r),y=h(n),m=h(i),w=h(o),b=h(a),g=h(s),k=h(u),x=h(l);function E(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 L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){k.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(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 C(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 C(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 C(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 O(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=g.default(e);if(t){var i=g.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return b.default(this,r)}}var A=function(e){w.default(g,e);var t,r,n,i,o,a,s,u,l,h,b=O(g);function g(e){var t;for(var r in y.default(this,g),(t=b.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 m.default(g,[{key:"update",value:function(){var e,t=j(this.elements);try{for(t.s();!(e=t.n()).done;){var r,n=e.value;p.cacheElementStyles(n),null===(r=this.animations.default)||void 0===r||r.setToLast(n,!0)}}catch(e){t.e(e)}finally{t.f()}}},{key:"toAnimation",value:function(e){return!e||"object"!==v.default(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new p.Animation(L({},e),this.props.initial):null}},{key:"componentDidMount",value:(h=d.default(x.default.mark((function e(){var t=this;return x.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),p.addEventListener("resize",this.resizeEventListener),this.update(),!("fonts"in document)){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update({mount:!0});case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),p.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&p.AnimationQueue.delay((function(){return t.onScroll()}),.001));case 8:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"componentDidUpdate",value:(l=d.default(x.default.mark((function e(){return x.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 l.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){p.removeEventListener("scroll",this.scrollEventListener),p.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;if(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){var n,i=j(this.children);try{for(i.s();!(n=i.n()).done;){var o=n.value.animatable.inViewport(),a=f.default(o,2),s=a[0],u=a[1];t=t&&s,r=r&&u}}catch(e){i.e(e)}finally{i.f()}}return[t,r]}},{key:"onScroll",value:(u=d.default(x.default.mark((function e(){var t,r,n,i;return x.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=f.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:(s=d.default(x.default.mark((function e(){var t;return x.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=p.AnimationQueue.delay(this.update.bind(this,{mount:!0}),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"onEnter",value:(a=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n=arguments;return x.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=d.default(x.default.mark((function e(t){var r,n,i,o,a,s,u,l,c,h,f,d,v,y,m,w,b,g,k,E,L,C=this,O=arguments;return x.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=O.length>1&&void 0!==O[1]?O[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,u=r.cascade,l=void 0!==u&&u,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,d=void 0===f?0:f,v=r.staggerDelay,y=void 0===v?0:v,!(this.props.parentLevel>0)||l){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:w=0,this.elements.forEach((function(e,t){var r="group"in C.props?C.props.parentLevel-C.props.group:C.level+h;d=o?m.duration:d;var n=o?r*d:(C.props.parentLevel-r)*d;n=C.props.stagger*t+n+y,w=n>w?n:w,m.play(e,{delay:n,reverse:o,immediate:s})})),b=j(this.children);try{for(b.s();!(g=b.n()).done;)k=g.value,E=k.animatable,L=k.staggerIndex,E.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:L<0?0:this.props.stagger*L,cascadeDelay:m.duration,groupAdjust:L<0?0:1})}catch(e){b.e(e)}finally{b.f()}n&&p.AnimationQueue.delay(n,w+m.duration);case 11: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=L(L({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===v.default(e[n])&&"object"===v.default(t[n])&&(r[n]=L(L({},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,u=n.useEvents,l=void 0===u||u;if(!c.isValidElement(e))return e;var p={};if(e.type===g||e.type.prototype instanceof g||(s&&(p={ref:function(e){return r.elements[o]=e}}),l&&(this.props.parentLevel<1||this.props.noCascade)&&(p=L(L({},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)}}),l=!1)),(e.type===g||e.type.prototype instanceof g)&&(null===(t=e.props)||void 0===t||!t.noCascade)){var h=this.childrenIndex++;p=L(L(L({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[h]={animatable:e,staggerIndex:s?o:-1}}})}var f=c.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:l})}));return c.cloneElement(e,p,f)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.Children.forEach(e,(function(e){var i;if(c.isValidElement(e)){(e.type===g||e.type.prototype instanceof g)&&(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:"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.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0})}))}}]),g}(c.Component);k.default(A,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}}),exports.Animatable=A;
|
package/dist/cjs/animate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("@babel/runtime/helpers/objectWithoutProperties"),r=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),i=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),l=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/defineProperty"),u=require("react"),s=require("./animatable-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("@babel/runtime/helpers/objectWithoutProperties"),r=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),i=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),l=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/defineProperty"),u=require("react"),s=require("./animatable-62e7223b.js"),c=require("./pop-592e65c5.js"),p=require("./animation-1595965d.js"),f=require("@babel/runtime/helpers/toConsumableArray");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/regenerator");var d=m(e),b=m(t),h=m(r),y=m(n),v=m(i),g=m(a),O=m(l),j=m(o),q=m(u),P=m(f),k=["levels","animations"];function A(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 E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach((function(t){j.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g.default(this,r)}}var C=function(e){v.default(r,e);var t=w(r);function r(e){var n;return h.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=p.padArray(n.props.animations,n.levels),n}return y.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||u.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=b.default(n,k),a=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),q.default.createElement(s.Animatable,d.default({animate:a},i),u.Children.map(e,(function(e){return u.isValidElement(e)?u.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,E({},r))}},{key:"shouldComponentUpdate",value:function(e){return e.animations===this.props.animations}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(u.Component);function x(e){var t=e.children,r=e.className,n=e.style,i=e.duration;if("string"!=typeof t)return t;var a=t.split("");return q.default.createElement("div",{className:r,style:n},q.default.createElement(s.Animatable,{whileViewport:!0,animate:{opacity:1,position:{y:0},rotation:0,duration:.8},initial:{opacity:0,position:{y:"100%"},rotation:10},stagger:(i-.8)/(a.length-1)},a.map((function(e,t){return q.default.createElement("span",{style:{display:"inline-block"},key:t},/\s/.test(e)?" ":e)}))))}function R(e){var t,r=e.children,n=e.color,i=e.duration,a=(null===(t=r.props)||void 0===t?void 0:t.children)||[];Array.isArray(a)||(a=[a]);var l=[q.default.createElement(s.Animatable,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:i/2}},q.default.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:n}}))].concat(P.default(a));return q.default.createElement(s.Animatable,{whileViewport:!0,animate:{clip:{right:0},duration:i/2},initial:{clip:{right:1}}},u.cloneElement(r,{},l))}j.default(C,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]}),x.defaultProps={style:{},className:"",duration:1.6},R.defaultProps={color:"grey",duration:1.6},exports.Animate=C,exports.ColorWipe=R,exports.WriteOn=x;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/defineProperty"),a=require("@babel/runtime/helpers/asyncToGenerator"),o=require("@babel/runtime/regenerator"),s=require("@babel/runtime/helpers/typeof");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(e),c=l(t),d=l(i),h=l(n),y=l(r),f=l(a),v=l(o),p=l(s),g=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"Lively"in i||(i.Lively={}),e in i.Lively||(i.Lively[e]=t)},m=function(e){return e&&"object"===p.default(e)&&!Array.isArray(e)},b=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=u.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}},k=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=u.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}},L=function(){function e(){d.default(this,e),this.queue=[],this.tick()}var t;return h.default(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=f.default(v.default.mark((function e(){var t,i,n;return v.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=13;break}if(n=this.queue[i],!(this.queue.length===i||n.timestamp>t)){e.next=7;break}return this.queue.splice(0,i),e.abrupt("break",13);case 7:n.callback(),delete n.cancel,delete n.store[n.id+n.timestamp];case 10:i++,e.next=2;break;case 13:requestAnimationFrame(this.tick.bind(this));case 14: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){for(var t=this.search(e);t>0&&this.queue[t].timestamp>=e.timestamp;)t--;for(;t<this.queue.length&&this.queue[t].timestamp<=e.timestamp;){if(this.queue[t].id===e.id){this.queue.splice(t,1);break}t++}delete e.cancel}},{key:"delay",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof Function){var r={timestamp:Date.now()+1e3*t,id:this.uuid(),cancel:function(){return i.cancel(r)},callback:e,store:n};return this.insert(r),n[r.id+r.timestamp]=r,r}}}],[{key:"get",value:function(){return g("AnimationQueue",new e),window.Lively.AnimationQueue}},{key:"cancelAll",value:function(e){for(var t in e)e[t].cancel(),delete e[t]}},{key:"delay",value:function(e,t,i){return this.get().delay(e,t,i)}},{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}(),x=["delay","duration","repeat","interpolate","origin","useLayout"];function w(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var q=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,u=void 0===l?"ease":l,h=t.origin,y=void 0===h?{x:.5,y:.5}:h,f=t.useLayout,v=void 0!==f&&f,p=c.default(t,x),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d.default(this,e),this.length=0,this.useLayout=v,this.keyframes=this.getKeyframes(p,g),this.delay=n,this.duration=a,this.delta=a/(this.length-1),this.interpolation="spring"===u?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":u,this.origin=this.originToStyle(y),this.repeat=s}return h.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if(m(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=function(r){var a=r in n?n[r]:e.initials[r];Array.isArray(t[r])||(t[r]=[t[r]]),t[r].length<2&&t[r].unshift(a),t[r]=t[r].map((function(e){return i.sanitize(r,e)})),i.length=Math.max(t[r].length,i.length)};for(var a in t)r(a);return new Array(this.length).fill(0).map((function(n,r){var a={start:{},end:{}};for(var o in t)if(o in e.initials){var s=i.interpolateKeyframe(t[o],r,i.length);m(s)&&("start"in s||"end"in s||"set"in s)?("start"in s&&(a.start[o]=s.start),"end"in s&&(a.end[o]=s.end),"set"in s&&(a[o]=s.set)):a[o]=s}return i.keyframeToStyle(a)}))}},{key:"sanitize",value:function(t,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return b(i);if(i.match(/^rgba?\(.*\)$/i))return k(i);var r=parseFloat(i),a=(i.match(/[^0-9\.]*$/i)||["px"])[0];return isNaN(r)?e.initials[t]:("%"===a&&(r/=100),a?[r,a]:r)}if(m(i)){var o=Object.keys(i),s=i;("x"in i||"y"in i)&&(o=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(o=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(o=["left","right","top","bottom"]),i={};var l,u=w(o);try{for(u.s();!(l=u.n()).done;){var c=l.value;i[c]=this.sanitize(t,s[c],c)}}catch(e){u.e(e)}finally{u.f()}}if(void 0!==i)return i;var d=e.initials[t];return n in d?d[n]:d}},{key:"interpolate",value:function(e,t,i){if(m(e)){for(var n={},r=0,a=Object.keys(e);r<a.length;r++){var o=a[r];n[o]=this.interpolate(e[o],m(t)?t[o]:t,i)}return n}var s=!1;if(Array.isArray(e)&&(s=e[1],e=e[0]),Array.isArray(t)&&(s=t[1],t=t[0]),"number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var l=e*(1-i)+t*i;return s?[l,s]:l}},{key:"interpolateKeyframe",value:function(e,t,i){if(e.length===i)return e[t];var n=t*((e.length-1)/(i-1)),r=Math.floor(n),a=e[r];return r===e.length-1?a:this.interpolate(a,e[r+1],n-r)}},{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){for(var t={transform:""},i=0,n=Object.entries(e);i<n.length;i++){var r=u.default(n[i],2),a=r[0],o=r[1];switch(a){case"start":case"end":Object.keys(o).length&&(t[a]=this.keyframeToStyle(o));break;case"position":t.transform+="translate(".concat(this.toString(o.x,"px"),", ").concat(this.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),this.useLayout){t.width=this.toLength(o.x),t.height=this.toLength(o.y);break}t.transform+="scale(".concat(this.toString(o.x,"%"),", ").concat(this.toString(o.y,"%"),") ");break;case"rotation":t.transform+="rotate(".concat(this.toString(o,"deg"),") ");break;case"clip":t.clipPath="inset(".concat(this.toString(o.top,"%")," ").concat(this.toString(o.right,"%")," ").concat(this.toString(o.bottom,"%")," ").concat(this.toString(o.left,"%"),")"),t.webkitClipPath=t.clipPath;break;case"borderRadius":case"padding":case"fontSize":t[a]=this.toString(o,"px");break;case"backgroundColor":case"color":t[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":t.pointerEvents=o?"all":"none";break;case"opacity":case"active":case"zIndex":t[a]=o}}return t.transform.length||delete t.transform,t}},{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],u=t.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var c=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":c,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(c,") * ");e.style[n]=d+.5*u,e.style[r]=d+1/(0===u?1e-6:u)*.5}},{key:"apply",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.duration,a=void 0===r?this.delta:r,o=n.reverse,s=void 0!==o&&o,l=function(){e.style.transitionDuration="".concat(a,"s");for(var n=0,r=Object.entries(t);n<r.length;n++){var o=u.default(r[n],2),s=o[0],l=o[1];"width"!==s?"height"!==s?"padding"===s&&(t.width||t.height)||"start"===s||"end"===s||(e.style[s]=l):i.setLength(e,t,"height","paddingTop","paddingBottom"):i.setLength(e,t,"width","paddingLeft","paddingRight")}e.Lively.keyframe=t};"start"in t&&!s||"end"in t&&s?(this.apply(e,t[s?"end":"start"],{duration:0}),L.delay(l,.001)):l(),("end"in t&&!s||"start"in t&&s)&&L.delay(this.apply.bind(this,e,t[s?"start":"end"],{duration:0}),this.delta,e.Lively.timeouts)}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.keyframes[0];e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin,this.apply(e,t,{duration:0})}},{key:"setToLast",value:function(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(n||null!==(t=e.Lively)&&void 0!==t&&t.keyframe)&&this.setInitial(e,null===(i=e.Lively)||void 0===i?void 0:i.keyframe)}},{key:"start",value:function(e){var t=this,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,o?this.keyframes[this.length-1]:this.keyframes[0]),e.Lively.index=1,e.Lively.animating=!0,requestAnimationFrame((function(){return t.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;if(e.style&&this.length){a&&(e.Lively.queue=[],L.cancelAll(e.Lively.timeouts));var l=this.start.bind(this,e,{immediate:a,reverse:s});this.delay||n?L.delay(l,this.delay+n,e.Lively.timeouts):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.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=u.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.length-1-l),this.apply(e,this.keyframes[l],{reverse:i}),e.Lively.index++,L.delay((function(){return t.getNext(e,i,n)}),this.delta,e.Lively.timeouts)}}]),e}();y.default(q,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},rotation:0,clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1rem",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:!0,interact:!0,zIndex:0}),exports.Animation=q,exports.AnimationQueue=L,exports.addEventListener=function(e,t){if(t instanceof Function){g("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 i=window.Lively.Events[e];t.Lively={ListenerID:i.unique},i[i.unique++]=t}},exports.cacheElementStyles=function(e){g("queue",[],e),g("timeouts",{},e),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"),function(e,t){for(var i in e.style={},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,u=t.padding,c=t.fontSize,d=t.zIndex,h=e.getBoundingClientRect(),y=h.x,f=h.y,v=h.width,p=h.height;e.Lively.initials={x:y,y:f,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:c,zIndex:"auto"===d?0:parseInt(d),width:v+"px",height:p+"px",borderRadius:l.split(" ")[0],padding:u.split(" ")[0]}},exports.isObject=m,exports.livelyProperty=g,exports.padArray=function(e,t){return new Array(t).fill(0).map((function(t,i){return i<e.length?e[i]:e[e.length-1]}))},exports.removeEventListener=function(e,t){var i,n;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&t.Lively&&"ListenerID"in t.Lively&&delete window.Lively.Events[e][t.Lively.ListenerID]};
|
package/dist/cjs/animations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./animation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./animation-1595965d.js"),t=require("./pop-592e65c5.js"),n=require("@babel/runtime/helpers/objectWithoutProperties");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("@babel/runtime/helpers/typeof");var i=o(e),c=o(n);function u(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 a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?u(Object(t),!0).forEach((function(r){i.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):u(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function p(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return p.use=p.use.bind(p,e),p}p.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(a({opacity:1,duration:.65},e),{opacity:0})};var s=["direction"];function l(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 b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?l(Object(t),!0).forEach((function(r){i.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=c.default(e,s),i=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":i=1,u=0,a={x:0,y:1};break;case"down":i=1,u=0,a={x:0,y:0}}return new r.Animation(b({scale:{x:1},origin:a,duration:.6},o),{scale:{x:i,y:u}})};var O=["direction"];function y(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 d(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?y(Object(t),!0).forEach((function(r){i.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):y(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j.use=j.use.bind(j,e),j}j.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=c.default(e,O);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(d({clip:i.default({},n,0)},o),{clip:i.default({},n,1)})},exports.Move=t.Move,exports.Pop=t.Pop,exports.Fade=p,exports.Scale=f,exports.Wipe=j;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./animatable-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./animatable-62e7223b.js"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),n=require("@babel/runtime/helpers/get"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),u=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),p=require("react"),c=require("./animation-1595965d.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/objectWithoutProperties");var f=h(t),d=h(r),m=h(i),y=h(n),v=h(o),b=h(a),g=h(s),x=h(u),w=h(l);function A(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){x.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,i=g.default(e);if(t){var n=g.default(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return b.default(this,r)}}var q=function(e){v.default(o,e);var t,r,i,n=j(o);function o(e){var t,r,i;return d.default(this,o),(i=n.call(this,e)).properties=i.props.properties||["position","scale","opacity","backgroundColor","color","interact","zIndex"],!i.props.properties&&i.props.useLayout&&i.properties.push("borderRadius","fontSize"),i.parent=(null===(t=(r=i.props).parent)||void 0===t?void 0:t.call(r))||{group:""},i.group=i.parent.group+i.props.group,i.useLayout=!1,i.childStyles={pointerEvents:"initial"},i.parentStyles={background:"transparent",border:"none",padding:0,pointerEvents:"none",backdropFilter:"none",boxShadow:"unset",fontSize:"unset",zIndex:"unset"},i}return m.default(o,[{key:"layout",value:function(){this.position=this.position||getComputedStyle(this.element).position;var e=S(S({},this.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight});"absolute"===this.position||"fixed"===this.position?e.position="absolute":(e.position="relative",this.childStyles=S(S({},this.childStyles),{},{position:"absolute",margin:0,top:0,left:0})),this.parentStyles=e,this.useLayout=!0,this.hasUpdated=!0,this.forceUpdate()}},{key:"update",value:(i=f.default(w.default.mark((function e(){var t,r,i,n,o,a,s,u,l=arguments;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=l.length>0&&void 0!==l[0]?l[0]:{},r=t.mount,i=void 0===r?!this.useLayout:r,n=t.active,o=void 0===n?this.props.active:n,this.element=this.elements[0],this.element){e.next=4;break}return e.abrupt("return");case 4:if(!this.props.useLayout||!i){e.next=6;break}return e.abrupt("return",this.layout());case 6:if(!this.element.Lively||this.hasUpdated){e.next=8;break}return e.abrupt("return");case 8:if(c.cacheElementStyles(this.element),this.hasUpdated=!1,!this.parent.props){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,c.AnimationQueue.sleep(.001);case 14:this.setUniqueId(),this.animations={default:this.unmorphAnimation()},o||this.animations.default.setInitial(this.element),a=A(this.children);try{for(a.s();!(s=a.n()).done;)(u=s.value.animatable).setUniqueId(),u.animations={default:u.unmorphAnimation()},o||u.animations.default.setInitial(u.element)}catch(e){a.e(e)}finally{a.f()}case 19:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||(c.livelyProperty("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:"componentDidUpdate",value:(r=f.default(w.default.mark((function e(t){return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.update({mount:!1,active:t.active});case 2:t.active!==this.props.active&&this.morph(this.props.active);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"morph",value:(t=f.default(w.default.mark((function e(t){var r,i;return w.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"),(i=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i,{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.morphAnimation(this.element,t);var r,i=A(this.children);try{for(i.s();!(r=i.n()).done;){r.value.animatable.createAnimations(e)}}catch(e){i.e(e)}finally{i.f()}}},{key:"animationFromKeyframes",value:function(e){var t,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},o=A(this.properties);try{var a=function(){var o=t.value;if(r.props.ignore.includes(o))return"continue";var a=o in e?o:"auto";if(!(a in e))return"continue";n[o]=e[a].map((function(e){if(!c.isObject(e))return e in i?i[e][o]:e;var t={};for(var r in e)e[r]in i?t[r]=i[e[r]][o]:t[r]=e[r];return t}))};for(o.s();!(t=o.n()).done;)a()}catch(e){o.e(e)}finally{o.f()}return new c.Animation(n)}},{key:"morphAnimation",value:function(e,t){var r,i;return t?(e=null===(r=e.Lively)||void 0===r?void 0:r.initials,t=null===(i=t.Lively)||void 0===i?void 0:i.initials,this.x=t.x-e.x,this.y=t.y-e.y,this.parent.props&&(this.x-=this.parent.x,this.y-=this.parent.y),this.animationFromKeyframes({auto:["from","to",{set:"to",end:"from"}],position:["from","to",{set:"to",end:"from"}],scale:["from","to",{set:"to",end:"from"}],opacity:[1,1,{end:0}],interact:[!0,!0,{end:!1}]},{from:S(S({},e),{},{position:{x:0,y:0},scale:{x:1,y:1}}),to:S(S({},t),{},{position:{x:this.x,y:this.y},scale:{x:parseInt(t.width)/parseInt(e.width),y:parseInt(t.height)/parseInt(e.height)}})})):this.animationFromKeyframes({opacity:[1,0,0],interact:[!0,!1,!1]})}},{key:"unmorphAnimation",value:function(){var e=this.element.Lively.initials;return this.animationFromKeyframes({auto:["from","from","from"],position:[{x:0,y:0}],scale:[{x:1,y:1}],opacity:[0,0,1],interact:[!1,!1,!0],zIndex:["from",e.zIndex+1,{set:e.zIndex+1,end:"from"}]},{from:e})}},{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!==o?{}:{parent:function(){return t},duration:t.props.duration};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),i={"lively-morph-group":this.group,style:S(S({},t.props.style),this.childStyles)},n=y.default(g.default(o.prototype),"render",this).call(this,p.cloneElement(t,i,r));return this.useLayout?p.cloneElement(t,{style:this.parentStyles},n):n}}]),o}(e.Animatable);x.default(q,"defaultProps",{group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]}),exports.Animatable=e.Animatable,exports.Animation=c.Animation,exports.Morph=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),r=require("./animation-
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),r=require("./animation-1595965d.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),i=n(t),c=["direction"];function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){o.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}function s(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?s(Object(r),!0).forEach((function(t){o.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return f.use=f.use.bind(f,e),f}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"up":t,o=i.default(e,c),p="0px",a="20px";switch(n){case"down":a="-20px";break;case"left":p="20px",a="0px";break;case"right":p="-20px",a="0px"}return new r.Animation(u({position:{x:"0px",y:"0px"},opacity:1,duration:.5},o),{position:{x:p,y:a},opacity:0})},f.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(b({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Move=a,exports.Pop=f;
|
|
@@ -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 u from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/regenerator";import{isValidElement as p,Children as c,cloneElement as h,Component as f}from"react";import{c as v,a as d,b as y,A as m,r as w}from"./animation-d10c9aed.js";function b(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 g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(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 x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,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 x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(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 O=function(s){o(F,f);var a,u,b,x,O,j,E,A,C,D,P=L(F);function F(e){var t;for(var r in n(this,F),(t=P.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(F,[{key:"update",value:function(){var e,t=k(this.elements);try{for(t.s();!(e=t.n()).done;){var r,n=e.value;v(n),null===(r=this.animations.default)||void 0===r||r.setToLast(n,!0)}}catch(e){t.e(e)}finally{t.f()}}},{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new d(g({},e),this.props.initial):null}},{key:"componentDidMount",value:(D=t(l.mark((function e(){var t=this;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),y("resize",this.resizeEventListener),this.update(),!("fonts"in document)){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update({mount:!0});case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),y("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&m.delay((function(){return t.onScroll()}),.001));case 8:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"componentDidUpdate",value:(C=t(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){w("scroll",this.scrollEventListener),w("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;if(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){var i,o=k(this.children);try{for(o.s();!(i=o.n()).done;){var s=i.value.animatable.inViewport(),a=e(s,2),u=a[0],l=a[1];r=r&&u,n=n&&l}}catch(e){o.e(e)}finally{o.f()}}return[r,n]}},{key:"onScroll",value:(A=t(l.mark((function t(){var r,n,i,o;return l.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 A.apply(this,arguments)})},{key:"onResize",value:(E=t(l.mark((function e(){var t;return l.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=m.delay(this.update.bind(this,{mount:!0}),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"onEnter",value:(j=t(l.mark((function e(t){var r,n=arguments;return l.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 j.apply(this,arguments)})},{key:"onLeave",value:(O=t(l.mark((function e(t){var r,n=arguments;return l.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:(x=t(l.mark((function e(t){var r,n=arguments;return l.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 x.apply(this,arguments)})},{key:"onBlur",value:(b=t(l.mark((function e(t){var r,n=arguments;return l.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:(u=t(l.mark((function e(t){var r,n=arguments;return l.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 u.apply(this,arguments)})},{key:"play",value:(a=t(l.mark((function e(t){var r,n,i,o,s,a,u,p,c,h,f,v,d,y,w,b,g,x,L,O,j,E=this,A=arguments;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=A.length>1&&void 0!==A[1]?A[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,u=r.cascade,p=void 0!==u&&u,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,d=r.staggerDelay,y=void 0===d?0:d,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(w="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 E.props?E.props.parentLevel-E.props.group:E.level+h;v=o?w.duration:v;var n=o?r*v:(E.props.parentLevel-r)*v;n=E.props.stagger*t+n+y,b=n>b?n:b,w.play(e,{delay:n,reverse:o,immediate:a})})),g=k(this.children);try{for(g.s();!(x=g.n()).done;)L=x.value,O=L.animatable,j=L.staggerIndex,O.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:j<0?0:this.props.stagger*j,cascadeDelay:w.duration,groupAdjust:j<0?0:1})}catch(e){g.e(e)}finally{g.f()}n&&m.delay(n,b+w.duration);case 11: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=g(g({},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]=g(g({},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,u=n.useEvents,l=void 0===u||u;if(!p(e))return e;var f={};if(e.type===F||e.type.prototype instanceof F||(a&&(f={ref:function(e){return r.elements[o]=e}}),l&&(this.props.parentLevel<1||this.props.noCascade)&&(f=g(g({},f),{},{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)}}),l=!1)),(e.type===F||e.type.prototype instanceof F)&&(null===(t=e.props)||void 0===t||!t.noCascade)){var v=this.childrenIndex++;f=g(g(g({},f),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[v]={animatable:e,staggerIndex:a?o:-1}}})}var d=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:l})}));return h(e,f,d)}},{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(p(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:"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})}))}}]),F}();u(O,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});export{O as A};
|
|
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 u from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/regenerator";import{isValidElement as p,Children as c,cloneElement as h,Component as f}from"react";import{c as v,a as d,b as y,A as m,r as w}from"./animation-7720f4a3.js";function b(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 g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(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 x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,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 x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(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 O=function(s){o(F,f);var a,u,b,x,O,j,E,A,C,D,P=L(F);function F(e){var t;for(var r in n(this,F),(t=P.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(F,[{key:"update",value:function(){var e,t=k(this.elements);try{for(t.s();!(e=t.n()).done;){var r,n=e.value;v(n),null===(r=this.animations.default)||void 0===r||r.setToLast(n,!0)}}catch(e){t.e(e)}finally{t.f()}}},{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new d(g({},e),this.props.initial):null}},{key:"componentDidMount",value:(D=t(l.mark((function e(){var t=this;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),y("resize",this.resizeEventListener),this.update(),!("fonts"in document)){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update({mount:!0});case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),y("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&m.delay((function(){return t.onScroll()}),.001));case 8:case"end":return e.stop()}}),e,this)}))),function(){return D.apply(this,arguments)})},{key:"componentDidUpdate",value:(C=t(l.mark((function e(){return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){w("scroll",this.scrollEventListener),w("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;if(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){var i,o=k(this.children);try{for(o.s();!(i=o.n()).done;){var s=i.value.animatable.inViewport(),a=e(s,2),u=a[0],l=a[1];r=r&&u,n=n&&l}}catch(e){o.e(e)}finally{o.f()}}return[r,n]}},{key:"onScroll",value:(A=t(l.mark((function t(){var r,n,i,o;return l.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 A.apply(this,arguments)})},{key:"onResize",value:(E=t(l.mark((function e(){var t;return l.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=m.delay(this.update.bind(this,{mount:!0}),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"onEnter",value:(j=t(l.mark((function e(t){var r,n=arguments;return l.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 j.apply(this,arguments)})},{key:"onLeave",value:(O=t(l.mark((function e(t){var r,n=arguments;return l.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:(x=t(l.mark((function e(t){var r,n=arguments;return l.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 x.apply(this,arguments)})},{key:"onBlur",value:(b=t(l.mark((function e(t){var r,n=arguments;return l.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:(u=t(l.mark((function e(t){var r,n=arguments;return l.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 u.apply(this,arguments)})},{key:"play",value:(a=t(l.mark((function e(t){var r,n,i,o,s,a,u,p,c,h,f,v,d,y,w,b,g,x,L,O,j,E=this,A=arguments;return l.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=A.length>1&&void 0!==A[1]?A[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,u=r.cascade,p=void 0!==u&&u,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,d=r.staggerDelay,y=void 0===d?0:d,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(w="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 E.props?E.props.parentLevel-E.props.group:E.level+h;v=o?w.duration:v;var n=o?r*v:(E.props.parentLevel-r)*v;n=E.props.stagger*t+n+y,b=n>b?n:b,w.play(e,{delay:n,reverse:o,immediate:a})})),g=k(this.children);try{for(g.s();!(x=g.n()).done;)L=x.value,O=L.animatable,j=L.staggerIndex,O.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:j<0?0:this.props.stagger*j,cascadeDelay:w.duration,groupAdjust:j<0?0:1})}catch(e){g.e(e)}finally{g.f()}n&&m.delay(n,b+w.duration);case 11: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=g(g({},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]=g(g({},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,u=n.useEvents,l=void 0===u||u;if(!p(e))return e;var f={};if(e.type===F||e.type.prototype instanceof F||(a&&(f={ref:function(e){return r.elements[o]=e}}),l&&(this.props.parentLevel<1||this.props.noCascade)&&(f=g(g({},f),{},{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)}}),l=!1)),(e.type===F||e.type.prototype instanceof F)&&(null===(t=e.props)||void 0===t||!t.noCascade)){var v=this.childrenIndex++;f=g(g(g({},f),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[v]={animatable:e,staggerIndex:a?o:-1}}})}var d=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:l})}));return h(e,f,d)}},{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(p(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:"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})}))}}]),F}();u(O,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});export{O as A};
|
package/dist/esm/animate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/extends";import t from"@babel/runtime/helpers/objectWithoutProperties";import r from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import i from"@babel/runtime/helpers/inherits";import o from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import s,{Children as p,isValidElement as c,cloneElement as u,Component as m}from"react";import{A as f}from"./animatable-
|
|
1
|
+
import e from"@babel/runtime/helpers/extends";import t from"@babel/runtime/helpers/objectWithoutProperties";import r from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import i from"@babel/runtime/helpers/inherits";import o from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import s,{Children as p,isValidElement as c,cloneElement as u,Component as m}from"react";import{A as f}from"./animatable-54740b57.js";import{M as b,P as h}from"./pop-dc41899a.js";import{p as y}from"./animation-7720f4a3.js";import v from"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/typeof";import"@babel/runtime/regenerator";var d=["levels","animations"];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 O(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(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 P(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 o(this,r)}}var j=function(o){i(l,m);var a=P(l);function l(e){var t;return r(this,l),(t=a.call(this,e)).levels=t.props.levels,t.animations=y(t.props.animations,t.levels),t}return n(l,[{key:"makeAnimatable",value:function(r){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(i<1||p.count(r)<1)return r;var o=this.props;o.levels,o.animations;var a=t(o,d),l=this.animations[this.levels-i];return i===this.levels&&(a.ref=function(e){return n.animatable=e}),s.createElement(f,e({animate:l},a),p.map(r,(function(e){return c(e)?u(e,{},n.makeAnimatable(e.props.children,i-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,O({},r))}},{key:"shouldComponentUpdate",value:function(e){return e.animations===this.props.animations}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),l}();function k(e){var t=e.children,r=e.className,n=e.style,i=e.duration;if("string"!=typeof t)return t;var o=t.split("");return s.createElement("div",{className:r,style:n},s.createElement(f,{whileViewport:!0,animate:{opacity:1,position:{y:0},rotation:0,duration:.8},initial:{opacity:0,position:{y:"100%"},rotation:10},stagger:(i-.8)/(o.length-1)},o.map((function(e,t){return s.createElement("span",{style:{display:"inline-block"},key:t},/\s/.test(e)?" ":e)}))))}function w(e){var t,r=e.children,n=e.color,i=e.duration,o=(null===(t=r.props)||void 0===t?void 0:t.children)||[];Array.isArray(o)||(o=[o]);var a=[s.createElement(f,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:i/2}},s.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:n}}))].concat(v(o));return s.createElement(f,{whileViewport:!0,animate:{clip:{right:0},duration:i/2},initial:{clip:{right:1}}},u(r,{},a))}l(j,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[b,h]}),k.defaultProps={style:{},className:"",duration:1.6},w.defaultProps={color:"grey",duration:1.6};export{j as Animate,w as ColorWipe,k as WriteOn};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/defineProperty";import a from"@babel/runtime/helpers/asyncToGenerator";import o from"@babel/runtime/regenerator";import s from"@babel/runtime/helpers/typeof";var l=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"Lively"in i||(i.Lively={}),t in i.Lively||(i.Lively[t]=e)},u=function(t){return t&&"object"===s(t)&&!Array.isArray(t)},c=function(t,e){return new Array(e).fill(0).map((function(e,i){return i<t.length?t[i]:t[t.length-1]}))},d=function(e){var i=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=t(i,5);n[0];var r=n[1],a=n[2],o=n[3],s=n[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}},h=function(e){var i=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=t(i,5);n[0];var r=n[1],a=n[2],o=n[3],s=n[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},y=function(t,e){if(e instanceof Function){l("Events",{}),t in window.Lively.Events||(window.Lively.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.Lively.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))})));var i=window.Lively.Events[t];e.Lively={ListenerID:i.unique},i[i.unique++]=e}},v=function(t,e){var i,n;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&e.Lively&&"ListenerID"in e.Lively&&delete window.Lively.Events[t][e.Lively.ListenerID]},f=function(t){l("queue",[],t),l("timeouts",{},t),t.Lively.style||(t.Lively.style=function(t){for(var e={},i=0;i<t.style.length;i++)e[t.style[i]]=t.style[t.style[i]];return e}(t),t.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",t.Lively.style.willChange="transform"),function(t,e){for(var i in t.style={},e)t.style[i]=e[i]}(t,t.Lively.style);var e=getComputedStyle(t),i=e.paddingLeft,n=e.paddingRight,r=e.paddingTop,a=e.paddingBottom,o=e.backgroundColor,s=e.color,u=e.borderRadius,c=e.padding,d=e.fontSize,h=e.zIndex,y=t.getBoundingClientRect(),v=y.x,f=y.y,p=y.width,g=y.height;t.Lively.initials={x:v,y:f,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:d,zIndex:"auto"===h?0:parseInt(h),width:p+"px",height:g+"px",borderRadius:u.split(" ")[0],padding:c.split(" ")[0]}},p=function(){function t(){i(this,t),this.queue=[],this.tick()}var e;return n(t,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(e=a(o.mark((function t(){var e,i,n;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){t.next=13;break}if(n=this.queue[i],!(this.queue.length===i||n.timestamp>e)){t.next=7;break}return this.queue.splice(0,i),t.abrupt("break",13);case 7:n.callback(),delete n.cancel,delete n.store[n.id+n.timestamp];case 10:i++,t.next=2;break;case 13:requestAnimationFrame(this.tick.bind(this));case 14:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,r=this.queue.length-1;n<=r;)if(e=n+r>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;r=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"cancel",value:function(t){for(var e=this.search(t);e>0&&this.queue[e].timestamp>=t.timestamp;)e--;for(;e<this.queue.length&&this.queue[e].timestamp<=t.timestamp;){if(this.queue[e].id===t.id){this.queue.splice(e,1);break}e++}delete t.cancel}},{key:"delay",value:function(t,e){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t instanceof Function){var r={timestamp:Date.now()+1e3*e,id:this.uuid(),cancel:function(){return i.cancel(r)},callback:t,store:n};return this.insert(r),n[r.id+r.timestamp]=r,r}}}],[{key:"get",value:function(){return l("AnimationQueue",new t),window.Lively.AnimationQueue}},{key:"cancelAll",value:function(t){for(var e in t)t[e].cancel(),delete t[e]}},{key:"delay",value:function(t,e,i){return this.get().delay(t,e,i)}},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),t}(),g=["delay","duration","repeat","interpolate","origin","useLayout"];function m(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(!t)return;if("string"==typeof t)return b(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return b(t,e)}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var k=function(){function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.delay,a=void 0===n?0:n,o=t.duration,s=void 0===o?1:o,l=t.repeat,u=void 0===l?1:l,c=t.interpolate,d=void 0===c?"ease":c,h=t.origin,y=void 0===h?{x:.5,y:.5}:h,v=t.useLayout,f=void 0!==v&&v,p=e(t,g),m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,r),this.length=0,this.useLayout=f,this.keyframes=this.getKeyframes(p,m),this.delay=a,this.duration=s,this.delta=s/(this.length-1),this.interpolation="spring"===d?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":d,this.origin=this.originToStyle(y),this.repeat=u}return n(r,[{key:"originToStyle",value:function(t){var e=.5,i=.5;if(u(t))e=t.x,i=t.y;else if("string"==typeof t)switch(t){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}else e=i=t;return"".concat(100*e,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(n){var a=n in i?i[n]:r.initials[n];Array.isArray(t[n])||(t[n]=[t[n]]),t[n].length<2&&t[n].unshift(a),t[n]=t[n].map((function(t){return e.sanitize(n,t)})),e.length=Math.max(t[n].length,e.length)};for(var a in t)n(a);return new Array(this.length).fill(0).map((function(i,n){var a={start:{},end:{}};for(var o in t)if(o in r.initials){var s=e.interpolateKeyframe(t[o],n,e.length);u(s)&&("start"in s||"end"in s||"set"in s)?("start"in s&&(a.start[o]=s.start),"end"in s&&(a.end[o]=s.end),"set"in s&&(a[o]=s.set)):a[o]=s}return e.keyframeToStyle(a)}))}},{key:"sanitize",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e){if(e.match(/^#[0-9a-f]{3,8}$/i))return d(e);if(e.match(/^rgba?\(.*\)$/i))return h(e);var n=parseFloat(e),a=(e.match(/[^0-9\.]*$/i)||["px"])[0];return isNaN(n)?r.initials[t]:("%"===a&&(n/=100),a?[n,a]:n)}if(u(e)){var o=Object.keys(e),s=e;("x"in e||"y"in e)&&(o=["x","y"]),("r"in e||"g"in e||"b"in e||"a"in e)&&(o=["r","g","b","a"]),("left"in e||"right"in e||"top"in e||"bottom"in e)&&(o=["left","right","top","bottom"]),e={};var l,c=m(o);try{for(c.s();!(l=c.n()).done;){var y=l.value;e[y]=this.sanitize(t,s[y],y)}}catch(t){c.e(t)}finally{c.f()}}if(void 0!==e)return e;var v=r.initials[t];return i in v?v[i]:v}},{key:"interpolate",value:function(t,e,i){if(u(t)){for(var n={},r=0,a=Object.keys(t);r<a.length;r++){var o=a[r];n[o]=this.interpolate(t[o],u(e)?e[o]:e,i)}return n}var s=!1;if(Array.isArray(t)&&(s=t[1],t=t[0]),Array.isArray(e)&&(s=e[1],e=e[0]),"number"!=typeof t||"number"!=typeof e)return i>.5?e:t;var l=t*(1-i)+e*i;return s?[l,s]:l}},{key:"interpolateKeyframe",value:function(t,e,i){if(t.length===i)return t[e];var n=e*((t.length-1)/(i-1)),r=Math.floor(n),a=t[r];return r===t.length-1?a:this.interpolate(a,t[r+1],n-r)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(e){for(var i={transform:""},n=0,r=Object.entries(e);n<r.length;n++){var a=t(r[n],2),o=a[0],s=a[1];switch(o){case"start":case"end":Object.keys(s).length&&(i[o]=this.keyframeToStyle(s));break;case"position":i.transform+="translate(".concat(this.toString(s.x,"px"),", ").concat(this.toString(s.y,"px"),") ");break;case"scale":if("number"==typeof s&&(s={x:s,y:s}),this.useLayout){i.width=this.toLength(s.x),i.height=this.toLength(s.y);break}i.transform+="scale(".concat(this.toString(s.x,"%"),", ").concat(this.toString(s.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat(this.toString(s,"deg"),") ");break;case"clip":i.clipPath="inset(".concat(this.toString(s.top,"%")," ").concat(this.toString(s.right,"%")," ").concat(this.toString(s.bottom,"%")," ").concat(this.toString(s.left,"%"),")"),i.webkitClipPath=i.clipPath;break;case"borderRadius":case"padding":case"fontSize":i[o]=this.toString(s,"px");break;case"backgroundColor":case"color":i[o]="rgba(".concat(s.r,", ").concat(s.g,", ").concat(s.b,", ").concat(s.a,")");break;case"interact":i.pointerEvents=s?"all":"none";break;case"opacity":case"active":case"zIndex":i[o]=s}}return i.transform.length||delete i.transform,i}},{key:"setLength",value:function(t,e,i,n,r){var a=t.Lively.initials[i],o=parseInt(t.Lively.initials[n]),s=parseInt(t.Lively.initials[r]),l=e[i],u=e.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var c=e.padding?e.padding:o+s+"px";t.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==t.style.boxSizing?"0px":c,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(c,") * ");t.style[n]=d+.5*u,t.style[r]=d+1/(0===u?1e-6:u)*.5}},{key:"apply",value:function(e,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.duration,o=void 0===a?this.delta:a,s=r.reverse,l=void 0!==s&&s,u=function(){e.style.transitionDuration="".concat(o,"s");for(var r=0,a=Object.entries(i);r<a.length;r++){var s=t(a[r],2),l=s[0],u=s[1];"width"!==l?"height"!==l?"padding"===l&&(i.width||i.height)||"start"===l||"end"===l||(e.style[l]=u):n.setLength(e,i,"height","paddingTop","paddingBottom"):n.setLength(e,i,"width","paddingLeft","paddingRight")}e.Lively.keyframe=i};"start"in i&&!l||"end"in i&&l?(this.apply(e,i[l?"end":"start"],{duration:0}),p.delay(u,.001)):u(),("end"in i&&!l||"start"in i&&l)&&p.delay(this.apply.bind(this,e,i[l?"start":"end"],{duration:0}),this.delta,e.Lively.timeouts)}},{key:"setInitial",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.keyframes[0];t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,this.apply(t,e,{duration:0})}},{key:"setToLast",value:function(t){var e,i,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(n||null!==(e=t.Lively)&&void 0!==e&&e.keyframe)&&this.setInitial(t,null===(i=t.Lively)||void 0===i?void 0:i.keyframe)}},{key:"start",value:function(t){var e=this,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;!t.Lively.animating||r?(this.setInitial(t,o?this.keyframes[this.length-1]:this.keyframes[0]),t.Lively.index=1,t.Lively.animating=!0,requestAnimationFrame((function(){return e.getNext(t,o,l)}))):t.Lively.queue.push([this,{reverse:o,repeat:l}])}},{key:"play",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.delay,n=void 0===i?0:i,r=e.immediate,a=void 0!==r&&r,o=e.reverse,s=void 0!==o&&o;if(t.style&&this.length){a&&(t.Lively.queue=[],p.cancelAll(t.Lively.timeouts));var l=this.start.bind(this,t,{immediate:a,reverse:s});this.delay||n?p.delay(l,this.delay+n,t.Lively.timeouts):l()}}},{key:"getNext",value:function(e){var i=this,n=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.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=t(a,2),s=o[0],l=o[1];return s?s.start(e,l):void(r>1&&this.start(e,{reverse:n,repeat:r-1}))}var u=e.Lively.index;n&&(u=this.length-1-u),this.apply(e,this.keyframes[u],{reverse:n}),e.Lively.index++,p.delay((function(){return i.getNext(e,n,r)}),this.delta,e.Lively.timeouts)}}]),r}();r(k,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},rotation:0,clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1rem",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:!0,interact:!0,zIndex:0});export{p as A,k as a,y as b,f as c,u as i,l,c as p,v as r};
|
package/dist/esm/animations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{a as r}from"./animation-
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import{a as r}from"./animation-7720f4a3.js";export{M as Move,P as Pop}from"./pop-dc41899a.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"@babel/runtime/helpers/typeof";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 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]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,a=1,u={x:0,y:.5};switch(o){case"left":u.x=1;break;case"up":p=1,a=0,u={x:0,y:1};break;case"down":p=1,a=0,u={x:0,y:0}}return new r(s({scale:{x:1},origin:u,duration:.6},i),{scale:{x:p,y:a}})};var u=["direction"];function b(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?b(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):b(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,u);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,a as Scale,f as Wipe};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as t}from"./animatable-
|
|
1
|
+
import{A as t}from"./animatable-54740b57.js";export{A as Animatable}from"./animatable-54740b57.js";import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import n from"@babel/runtime/helpers/get";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import u from"@babel/runtime/helpers/getPrototypeOf";import p from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/regenerator";import{Children as h,isValidElement as c,cloneElement as f}from"react";import{A as m,c as y,l as d,i as v,a as b}from"./animation-7720f4a3.js";export{a as Animation}from"./animation-7720f4a3.js";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/objectWithoutProperties";function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}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(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function w(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function k(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?w(Object(r),!0).forEach((function(e){p(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function S(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,i=u(t);if(e){var n=u(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return s(this,r)}}var O=function(a){o(A,t);var s,p,x,w=S(A);function A(t){var e,i,n;return r(this,A),(n=w.call(this,t)).properties=n.props.properties||["position","scale","opacity","backgroundColor","color","interact","zIndex"],!n.props.properties&&n.props.useLayout&&n.properties.push("borderRadius","fontSize"),n.parent=(null===(e=(i=n.props).parent)||void 0===e?void 0:e.call(i))||{group:""},n.group=n.parent.group+n.props.group,n.useLayout=!1,n.childStyles={pointerEvents:"initial"},n.parentStyles={background:"transparent",border:"none",padding:0,pointerEvents:"none",backdropFilter:"none",boxShadow:"unset",fontSize:"unset",zIndex:"unset"},n}return i(A,[{key:"layout",value:function(){this.position=this.position||getComputedStyle(this.element).position;var t=k(k({},this.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight});"absolute"===this.position||"fixed"===this.position?t.position="absolute":(t.position="relative",this.childStyles=k(k({},this.childStyles),{},{position:"absolute",margin:0,top:0,left:0})),this.parentStyles=t,this.useLayout=!0,this.hasUpdated=!0,this.forceUpdate()}},{key:"update",value:(x=e(l.mark((function t(){var e,r,i,n,o,a,s,u,p=arguments;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=p.length>0&&void 0!==p[0]?p[0]:{},r=e.mount,i=void 0===r?!this.useLayout:r,n=e.active,o=void 0===n?this.props.active:n,this.element=this.elements[0],this.element){t.next=4;break}return t.abrupt("return");case 4:if(!this.props.useLayout||!i){t.next=6;break}return t.abrupt("return",this.layout());case 6:if(!this.element.Lively||this.hasUpdated){t.next=8;break}return t.abrupt("return");case 8:if(y(this.element),this.hasUpdated=!1,!this.parent.props){t.next=12;break}return t.abrupt("return");case 12:return t.next=14,m.sleep(.001);case 14:this.setUniqueId(),this.animations={default:this.unmorphAnimation()},o||this.animations.default.setInitial(this.element),a=g(this.children);try{for(a.s();!(s=a.n()).done;)(u=s.value.animatable).setUniqueId(),u.animations={default:u.unmorphAnimation()},o||u.animations.default.setInitial(u.element)}catch(t){a.e(t)}finally{a.f()}case 19:case"end":return t.stop()}}),t,this)}))),function(){return x.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||(d("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:"componentDidUpdate",value:(p=e(l.mark((function t(e){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.update({mount:!1,active:e.active});case 2:e.active!==this.props.active&&this.morph(this.props.active);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"morph",value:(s=e(l.mark((function t(e){var r,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e&&this.element.setAttribute("lively-morph-target",!0),t.next=3,m.sleep(.001);case 3:e?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(i=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i,{immediate:!0}));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"createAnimations",value:function(t){var e=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(t,'"]'));this.animations[t]=this.morphAnimation(this.element,e);var r,i=g(this.children);try{for(i.s();!(r=i.n()).done;){r.value.animatable.createAnimations(t)}}catch(t){i.e(t)}finally{i.f()}}},{key:"animationFromKeyframes",value:function(t){var e,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},o=g(this.properties);try{var a=function(){var o=e.value;if(r.props.ignore.includes(o))return"continue";var a=o in t?o:"auto";if(!(a in t))return"continue";n[o]=t[a].map((function(t){if(!v(t))return t in i?i[t][o]:t;var e={};for(var r in t)t[r]in i?e[r]=i[t[r]][o]:e[r]=t[r];return e}))};for(o.s();!(e=o.n()).done;)a()}catch(t){o.e(t)}finally{o.f()}return new b(n)}},{key:"morphAnimation",value:function(t,e){var r,i;return e?(t=null===(r=t.Lively)||void 0===r?void 0:r.initials,e=null===(i=e.Lively)||void 0===i?void 0:i.initials,this.x=e.x-t.x,this.y=e.y-t.y,this.parent.props&&(this.x-=this.parent.x,this.y-=this.parent.y),this.animationFromKeyframes({auto:["from","to",{set:"to",end:"from"}],position:["from","to",{set:"to",end:"from"}],scale:["from","to",{set:"to",end:"from"}],opacity:[1,1,{end:0}],interact:[!0,!0,{end:!1}]},{from:k(k({},t),{},{position:{x:0,y:0},scale:{x:1,y:1}}),to:k(k({},e),{},{position:{x:this.x,y:this.y},scale:{x:parseInt(e.width)/parseInt(t.width),y:parseInt(e.height)/parseInt(t.height)}})})):this.animationFromKeyframes({opacity:[1,0,0],interact:[!0,!1,!1]})}},{key:"unmorphAnimation",value:function(){var t=this.element.Lively.initials;return this.animationFromKeyframes({auto:["from","from","from"],position:[{x:0,y:0}],scale:[{x:1,y:1}],opacity:[0,0,1],interact:[!1,!1,!0],zIndex:["from",t.zIndex+1,{set:t.zIndex+1,end:"from"}]},{from:t})}},{key:"getChildren",value:function(t){var e=this;return h.map(t,(function(t){if(!c(t))return t;var r=t.type!==A?{}:{parent:function(){return e},duration:e.props.duration};return f(t,r,e.getChildren(t.props.children))}))}},{key:"render",value:function(){var t,e=null!==(t=this.props.children)&&void 0!==t&&t.length?this.props.children[0]:this.props.children;if(!c(e))return e;var r=this.getChildren(e.props.children),i={"lively-morph-group":this.group,style:k(k({},e.props.style),this.childStyles)},o=n(u(A.prototype),"render",this).call(this,f(e,i,r));return this.useLayout?f(e,{style:this.parentStyles},o):o}}]),A}();p(O,"defaultProps",{group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]});export{O as Morph};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import{a as r}from"./animation-
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import{a as r}from"./animation-7720f4a3.js";var n=["direction"];function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?o(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return c.use=c.use.bind(c,e),c}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?p(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.use=s.use.bind(s,e),s}c.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=e.direction,c=void 0===o?"up":o,p=t(e,n),a="0px",s="20px";switch(c){case"down":s="-20px";break;case"left":a="20px",s="0px";break;case"right":a="-20px",s="0px"}return new r(i({position:{x:"0px",y:"0px"},opacity:1,duration:.5},p),{position:{x:a,y:s},opacity:0})},s.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(a({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{c as M,s as P};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/defineProperty"),a=require("@babel/runtime/helpers/asyncToGenerator"),o=require("@babel/runtime/regenerator"),s=require("@babel/runtime/helpers/typeof");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(e),c=l(t),d=l(i),h=l(n),y=l(r),v=l(a),f=l(o),p=l(s),g=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"Lively"in i||(i.Lively={}),e in i.Lively||(i.Lively[e]=t)},m=function(e){return e&&"object"===p.default(e)&&!Array.isArray(e)},b=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=u.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}},k=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=u.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}},L=function(){function e(){d.default(this,e),this.queue=[],this.tick()}var t;return h.default(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=v.default(f.default.mark((function e(){var t,i;return f.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=11;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",11);case 6:this.queue[i].callback(),delete this.queue[i].cancel;case 8:i++,e.next=2;break;case 11:requestAnimationFrame(this.tick.bind(this));case 12: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){for(var t=this.search(e);t>0&&this.queue[t].timestamp>=e.timestamp;)t--;for(;t<this.queue.length&&this.queue[t].timestamp<=e.timestamp;){if(this.queue[t].id===e.id){this.queue.splice(t,1);break}t++}delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n={timestamp:Date.now()+1e3*t,id:this.uuid(),cancel:function(){return i.cancel(n)},callback:e};return this.insert(n),n}}}],[{key:"get",value:function(){return g("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}(),x=["delay","duration","repeat","interpolate","origin","useLayout"];function w(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var q=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,u=void 0===l?"ease":l,h=t.origin,y=void 0===h?{x:.5,y:.5}:h,v=t.useLayout,f=void 0!==v&&v,p=c.default(t,x),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d.default(this,e),this.length=0,this.useLayout=f,this.keyframes=this.getKeyframes(p,g),this.delay=n,this.duration=a,this.delta=a/(this.length-1),this.interpolation="spring"===u?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":u,this.origin=this.originToStyle(y),this.repeat=s}return h.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if(m(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=function(r){var a=r in n?n[r]:e.initials[r];Array.isArray(t[r])||(t[r]=[t[r]]),t[r].length<2&&t[r].unshift(a),t[r]=t[r].map((function(e){return i.sanitize(r,e)})),i.length=Math.max(t[r].length,i.length)};for(var a in t)r(a);return new Array(this.length).fill(0).map((function(n,r){var a={start:{},end:{}};for(var o in t)if(o in e.initials){var s=i.interpolateKeyframe(t[o],r,i.length);m(s)&&("start"in s||"end"in s||"set"in s)?("start"in s&&(a.start[o]=s.start),"end"in s&&(a.end[o]=s.end),"set"in s&&(a[o]=s.set)):a[o]=s}return i.keyframeToStyle(a)}))}},{key:"sanitize",value:function(t,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return b(i);if(i.match(/^rgba?\(.*\)$/i))return k(i);var r=parseFloat(i),a=(i.match(/[^0-9\.]*$/i)||["px"])[0];return isNaN(r)?e.initials[t]:("%"===a&&(r/=100),a?[r,a]:r)}if(m(i)){var o=Object.keys(i),s=i;("x"in i||"y"in i)&&(o=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(o=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(o=["left","right","top","bottom"]),i={};var l,u=w(o);try{for(u.s();!(l=u.n()).done;){var c=l.value;i[c]=this.sanitize(t,s[c],c)}}catch(e){u.e(e)}finally{u.f()}}if(void 0!==i)return i;var d=e.initials[t];return n in d?d[n]:d}},{key:"interpolate",value:function(e,t,i){if(m(e)){for(var n={},r=0,a=Object.keys(e);r<a.length;r++){var o=a[r];n[o]=this.interpolate(e[o],m(t)?t[o]:t,i)}return n}var s=!1;if(Array.isArray(e)&&(s=e[1],e=e[0]),Array.isArray(t)&&(s=t[1],t=t[0]),"number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var l=e*(1-i)+t*i;return s?[l,s]:l}},{key:"interpolateKeyframe",value:function(e,t,i){if(e.length===i)return e[t];var n=t*((e.length-1)/(i-1)),r=Math.floor(n),a=e[r];return r===e.length-1?a:this.interpolate(a,e[r+1],n-r)}},{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){for(var t={transform:""},i=0,n=Object.entries(e);i<n.length;i++){var r=u.default(n[i],2),a=r[0],o=r[1];switch(a){case"start":case"end":Object.keys(o).length&&(t[a]=this.keyframeToStyle(o));break;case"position":t.transform+="translate(".concat(this.toString(o.x,"px"),", ").concat(this.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),this.useLayout){t.width=this.toLength(o.x),t.height=this.toLength(o.y);break}t.transform+="scale(".concat(this.toString(o.x,"%"),", ").concat(this.toString(o.y,"%"),") ");break;case"rotation":t.transform+="rotate(".concat(this.toString(o,"deg"),") ");break;case"clip":t.clipPath="inset(".concat(this.toString(o.top,"%")," ").concat(this.toString(o.right,"%")," ").concat(this.toString(o.bottom,"%")," ").concat(this.toString(o.left,"%"),")"),t.webkitClipPath=t.clipPath;break;case"borderRadius":case"padding":case"fontSize":t[a]=this.toString(o,"px");break;case"backgroundColor":case"color":t[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":t.pointerEvents=o?"all":"none";break;case"opacity":case"active":case"zIndex":t[a]=o}}return t.transform.length||delete t.transform,t}},{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],u=t.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var c=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":c,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(c,") * ");e.style[n]=d+.5*u,e.style[r]=d+1/(0===u?1e-6:u)*.5}},{key:"apply",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.duration,a=void 0===r?this.delta:r,o=n.reverse,s=void 0!==o&&o,l=function(){e.style.transitionDuration="".concat(a,"s");for(var n=0,r=Object.entries(t);n<r.length;n++){var o=u.default(r[n],2),s=o[0],l=o[1];"width"!==s?"height"!==s?"padding"===s&&(t.width||t.height)||"start"===s||"end"===s||(e.style[s]=l):i.setLength(e,t,"height","paddingTop","paddingBottom"):i.setLength(e,t,"width","paddingLeft","paddingRight")}e.Lively.keyframe=t};"start"in t&&!s||"end"in t&&s?(this.apply(e,t[s?"end":"start"],{duration:0}),L.delay(l,.001)):l(),("end"in t&&!s||"start"in t&&s)&&(e.Lively.end=L.delay(this.apply.bind(this,e,t[s?"start":"end"],{duration:0}),this.delta))}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.keyframes[0];e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin,this.apply(e,t,{duration:0}),e.Lively.index=1,e.Lively.animating=!0}},{key:"setToLast",value:function(e){var t,i,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(n||null!==(t=e.Lively)&&void 0!==t&&t.keyframe)&&this.setInitial(e,null===(i=e.Lively)||void 0===i?void 0:i.keyframe)}},{key:"start",value:function(e){var t=this,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,o?this.keyframes[this.length-1]:this.keyframes[0]),requestAnimationFrame((function(){return t.getNext(e,o,l)}))):e.Lively.queue.push([this,{reverse:o,repeat:l}])}},{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;if(e.style&&this.length){var u,c,d,h;if(o)e.Lively.queue=[],null===(u=e.Lively.next)||void 0===u||null===(c=u.cancel)||void 0===c||c.call(u),null===(d=e.Lively.end)||void 0===d||null===(h=d.cancel)||void 0===h||h.call(d);this.delay||r?e.Lively.next=L.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.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=u.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.length-1-l),this.apply(e,this.keyframes[l],{reverse:i}),e.Lively.index++,e.Lively.next=L.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();y.default(q,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},rotation:0,clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1rem",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:!0,interact:!0,zIndex:0}),exports.Animation=q,exports.AnimationQueue=L,exports.addEventListener=function(e,t){if(t instanceof Function){g("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 i=window.Lively.Events[e];t.Lively={ListenerID:i.unique},i[i.unique++]=t}},exports.cacheElementStyles=function(e){g("queue",[],e),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"),function(e,t){for(var i in e.style={},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,u=t.padding,c=t.fontSize,d=t.zIndex,h=e.getBoundingClientRect(),y=h.x,v=h.y,f=h.width,p=h.height;e.Lively.initials={x:y,y:v,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:c,zIndex:"auto"===d?0:parseInt(d),width:f+"px",height:p+"px",borderRadius:l.split(" ")[0],padding:u.split(" ")[0]}},exports.isObject=m,exports.livelyProperty=g,exports.padArray=function(e,t){return new Array(t).fill(0).map((function(t,i){return i<e.length?e[i]:e[e.length-1]}))},exports.removeEventListener=function(e,t){var i,n;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&t.Lively&&"ListenerID"in t.Lively&&delete window.Lively.Events[e][t.Lively.ListenerID]};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/defineProperty";import a from"@babel/runtime/helpers/asyncToGenerator";import o from"@babel/runtime/regenerator";import s from"@babel/runtime/helpers/typeof";var l=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"Lively"in i||(i.Lively={}),t in i.Lively||(i.Lively[t]=e)},u=function(t){return t&&"object"===s(t)&&!Array.isArray(t)},c=function(t,e){return new Array(e).fill(0).map((function(e,i){return i<t.length?t[i]:t[t.length-1]}))},d=function(e){var i=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=t(i,5);n[0];var r=n[1],a=n[2],o=n[3],s=n[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}},h=function(e){var i=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=t(i,5);n[0];var r=n[1],a=n[2],o=n[3],s=n[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},y=function(t,e){if(e instanceof Function){l("Events",{}),t in window.Lively.Events||(window.Lively.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.Lively.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))})));var i=window.Lively.Events[t];e.Lively={ListenerID:i.unique},i[i.unique++]=e}},v=function(t,e){var i,n;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&e.Lively&&"ListenerID"in e.Lively&&delete window.Lively.Events[t][e.Lively.ListenerID]},f=function(t){l("queue",[],t),t.Lively.style||(t.Lively.style=function(t){for(var e={},i=0;i<t.style.length;i++)e[t.style[i]]=t.style[t.style[i]];return e}(t),t.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",t.Lively.style.willChange="transform"),function(t,e){for(var i in t.style={},e)t.style[i]=e[i]}(t,t.Lively.style);var e=getComputedStyle(t),i=e.paddingLeft,n=e.paddingRight,r=e.paddingTop,a=e.paddingBottom,o=e.backgroundColor,s=e.color,u=e.borderRadius,c=e.padding,d=e.fontSize,h=e.zIndex,y=t.getBoundingClientRect(),v=y.x,f=y.y,p=y.width,g=y.height;t.Lively.initials={x:v,y:f,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:d,zIndex:"auto"===h?0:parseInt(h),width:p+"px",height:g+"px",borderRadius:u.split(" ")[0],padding:c.split(" ")[0]}},p=function(){function t(){i(this,t),this.queue=[],this.tick()}var e;return n(t,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(e=a(o.mark((function t(){var e,i;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){t.next=11;break}if(!(this.queue.length===i||this.queue[i].timestamp>e)){t.next=6;break}return this.queue.splice(0,i),t.abrupt("break",11);case 6:this.queue[i].callback(),delete this.queue[i].cancel;case 8:i++,t.next=2;break;case 11:requestAnimationFrame(this.tick.bind(this));case 12:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,r=this.queue.length-1;n<=r;)if(e=n+r>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;r=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"cancel",value:function(t){for(var e=this.search(t);e>0&&this.queue[e].timestamp>=t.timestamp;)e--;for(;e<this.queue.length&&this.queue[e].timestamp<=t.timestamp;){if(this.queue[e].id===t.id){this.queue.splice(e,1);break}e++}delete t.cancel}},{key:"delay",value:function(t,e){var i=this;if(t instanceof Function){var n={timestamp:Date.now()+1e3*e,id:this.uuid(),cancel:function(){return i.cancel(n)},callback:t};return this.insert(n),n}}}],[{key:"get",value:function(){return l("AnimationQueue",new t),window.Lively.AnimationQueue}},{key:"delay",value:function(t,e){return this.get().delay(t,e)}},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),t}(),g=["delay","duration","repeat","interpolate","origin","useLayout"];function m(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function(t,e){if(!t)return;if("string"==typeof t)return b(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return b(t,e)}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==i.return||i.return()}finally{if(s)throw a}}}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var k=function(){function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.delay,a=void 0===n?0:n,o=t.duration,s=void 0===o?1:o,l=t.repeat,u=void 0===l?1:l,c=t.interpolate,d=void 0===c?"ease":c,h=t.origin,y=void 0===h?{x:.5,y:.5}:h,v=t.useLayout,f=void 0!==v&&v,p=e(t,g),m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,r),this.length=0,this.useLayout=f,this.keyframes=this.getKeyframes(p,m),this.delay=a,this.duration=s,this.delta=s/(this.length-1),this.interpolation="spring"===d?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":d,this.origin=this.originToStyle(y),this.repeat=u}return n(r,[{key:"originToStyle",value:function(t){var e=.5,i=.5;if(u(t))e=t.x,i=t.y;else if("string"==typeof t)switch(t){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}else e=i=t;return"".concat(100*e,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(n){var a=n in i?i[n]:r.initials[n];Array.isArray(t[n])||(t[n]=[t[n]]),t[n].length<2&&t[n].unshift(a),t[n]=t[n].map((function(t){return e.sanitize(n,t)})),e.length=Math.max(t[n].length,e.length)};for(var a in t)n(a);return new Array(this.length).fill(0).map((function(i,n){var a={start:{},end:{}};for(var o in t)if(o in r.initials){var s=e.interpolateKeyframe(t[o],n,e.length);u(s)&&("start"in s||"end"in s||"set"in s)?("start"in s&&(a.start[o]=s.start),"end"in s&&(a.end[o]=s.end),"set"in s&&(a[o]=s.set)):a[o]=s}return e.keyframeToStyle(a)}))}},{key:"sanitize",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e){if(e.match(/^#[0-9a-f]{3,8}$/i))return d(e);if(e.match(/^rgba?\(.*\)$/i))return h(e);var n=parseFloat(e),a=(e.match(/[^0-9\.]*$/i)||["px"])[0];return isNaN(n)?r.initials[t]:("%"===a&&(n/=100),a?[n,a]:n)}if(u(e)){var o=Object.keys(e),s=e;("x"in e||"y"in e)&&(o=["x","y"]),("r"in e||"g"in e||"b"in e||"a"in e)&&(o=["r","g","b","a"]),("left"in e||"right"in e||"top"in e||"bottom"in e)&&(o=["left","right","top","bottom"]),e={};var l,c=m(o);try{for(c.s();!(l=c.n()).done;){var y=l.value;e[y]=this.sanitize(t,s[y],y)}}catch(t){c.e(t)}finally{c.f()}}if(void 0!==e)return e;var v=r.initials[t];return i in v?v[i]:v}},{key:"interpolate",value:function(t,e,i){if(u(t)){for(var n={},r=0,a=Object.keys(t);r<a.length;r++){var o=a[r];n[o]=this.interpolate(t[o],u(e)?e[o]:e,i)}return n}var s=!1;if(Array.isArray(t)&&(s=t[1],t=t[0]),Array.isArray(e)&&(s=e[1],e=e[0]),"number"!=typeof t||"number"!=typeof e)return i>.5?e:t;var l=t*(1-i)+e*i;return s?[l,s]:l}},{key:"interpolateKeyframe",value:function(t,e,i){if(t.length===i)return t[e];var n=e*((t.length-1)/(i-1)),r=Math.floor(n),a=t[r];return r===t.length-1?a:this.interpolate(a,t[r+1],n-r)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(e){for(var i={transform:""},n=0,r=Object.entries(e);n<r.length;n++){var a=t(r[n],2),o=a[0],s=a[1];switch(o){case"start":case"end":Object.keys(s).length&&(i[o]=this.keyframeToStyle(s));break;case"position":i.transform+="translate(".concat(this.toString(s.x,"px"),", ").concat(this.toString(s.y,"px"),") ");break;case"scale":if("number"==typeof s&&(s={x:s,y:s}),this.useLayout){i.width=this.toLength(s.x),i.height=this.toLength(s.y);break}i.transform+="scale(".concat(this.toString(s.x,"%"),", ").concat(this.toString(s.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat(this.toString(s,"deg"),") ");break;case"clip":i.clipPath="inset(".concat(this.toString(s.top,"%")," ").concat(this.toString(s.right,"%")," ").concat(this.toString(s.bottom,"%")," ").concat(this.toString(s.left,"%"),")"),i.webkitClipPath=i.clipPath;break;case"borderRadius":case"padding":case"fontSize":i[o]=this.toString(s,"px");break;case"backgroundColor":case"color":i[o]="rgba(".concat(s.r,", ").concat(s.g,", ").concat(s.b,", ").concat(s.a,")");break;case"interact":i.pointerEvents=s?"all":"none";break;case"opacity":case"active":case"zIndex":i[o]=s}}return i.transform.length||delete i.transform,i}},{key:"setLength",value:function(t,e,i,n,r){var a=t.Lively.initials[i],o=parseInt(t.Lively.initials[n]),s=parseInt(t.Lively.initials[r]),l=e[i],u=e.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var c=e.padding?e.padding:o+s+"px";t.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==t.style.boxSizing?"0px":c,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(c,") * ");t.style[n]=d+.5*u,t.style[r]=d+1/(0===u?1e-6:u)*.5}},{key:"apply",value:function(e,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.duration,o=void 0===a?this.delta:a,s=r.reverse,l=void 0!==s&&s,u=function(){e.style.transitionDuration="".concat(o,"s");for(var r=0,a=Object.entries(i);r<a.length;r++){var s=t(a[r],2),l=s[0],u=s[1];"width"!==l?"height"!==l?"padding"===l&&(i.width||i.height)||"start"===l||"end"===l||(e.style[l]=u):n.setLength(e,i,"height","paddingTop","paddingBottom"):n.setLength(e,i,"width","paddingLeft","paddingRight")}e.Lively.keyframe=i};"start"in i&&!l||"end"in i&&l?(this.apply(e,i[l?"end":"start"],{duration:0}),p.delay(u,.001)):u(),("end"in i&&!l||"start"in i&&l)&&(e.Lively.end=p.delay(this.apply.bind(this,e,i[l?"start":"end"],{duration:0}),this.delta))}},{key:"setInitial",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.keyframes[0];t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,this.apply(t,e,{duration:0}),t.Lively.index=1,t.Lively.animating=!0}},{key:"setToLast",value:function(t){var e,i,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(n||null!==(e=t.Lively)&&void 0!==e&&e.keyframe)&&this.setInitial(t,null===(i=t.Lively)||void 0===i?void 0:i.keyframe)}},{key:"start",value:function(t){var e=this,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;!t.Lively.animating||r?(this.setInitial(t,o?this.keyframes[this.length-1]:this.keyframes[0]),requestAnimationFrame((function(){return e.getNext(t,o,l)}))):t.Lively.queue.push([this,{reverse:o,repeat:l}])}},{key:"play",value:function(t){var e=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;if(t.style&&this.length){var u,c,d,h;if(o)t.Lively.queue=[],null===(u=t.Lively.next)||void 0===u||null===(c=u.cancel)||void 0===c||c.call(u),null===(d=t.Lively.end)||void 0===d||null===(h=d.cancel)||void 0===h||h.call(d);this.delay||r?t.Lively.next=p.delay((function(){return e.start(t,{immediate:o,reverse:l})}),this.delay+r):this.start(t,{immediate:o,reverse:l})}}},{key:"getNext",value:function(e){var i=this,n=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.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=t(a,2),s=o[0],l=o[1];return s?s.start(e,l):void(r>1&&this.start(e,{reverse:n,repeat:r-1}))}var u=e.Lively.index;n&&(u=this.length-1-u),this.apply(e,this.keyframes[u],{reverse:n}),e.Lively.index++,e.Lively.next=p.delay((function(){return i.getNext(e,n,r)}),this.delta)}}]),r}();r(k,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},rotation:0,clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1rem",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:!0,interact:!0,zIndex:0});export{p as A,k as a,y as b,f as c,u as i,l,c as p,v as r};
|