@infinityfx/lively 0.0.12 → 0.1.0

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/README.md CHANGED
@@ -13,6 +13,12 @@ Lightweight, zero-configuration react animation library.
13
13
  - [Installation](#installation)
14
14
  - [Usage](#usage)
15
15
  - [Components](#components)
16
+ - [Animatable](#animatable)
17
+ - [Animate](#animate)
18
+ - [Morph](#morph)
19
+ - [Build-in animations](#build-in-animations)
20
+ - [`<WriteOn />`](#writeon)
21
+ - [`<ColorWipe />`](#colorwipe)
16
22
 
17
23
  ## Get started
18
24
 
@@ -31,14 +37,58 @@ import { Animate } from '@infinityfx/lively';
31
37
 
32
38
  <Animate onMount>
33
39
  <div class="my-class">
34
- Ullamco Lorem ipsum enim amet consequat ut reprehenderit cupidatat et incididunt qui minim culpa. Dolor do laborum nulla pariatur tempor excepteur duis et ipsum. Eu commodo et esse exercitation laborum cupidatat incididunt elit reprehenderit id.
40
+ Lorem ipsum enim amet consequat ut reprehenderit cupidatat et incididunt qui minim culpa. Dolor do laborum nulla pariatur tempor excepteur duis et ipsum. Eu commodo et esse exercitation laborum cupidatat incididunt elit reprehenderit id.
35
41
  </div>
36
42
  </Animate>
37
43
  ```
38
44
 
39
45
  ## Components
40
- - Animatable
41
- - Animate
42
- - Morph
43
46
 
44
- More documentation coming soon!
47
+ ### Animatable `<Animatable />`
48
+
49
+ Base animation component that allows for fully customizable animations.
50
+
51
+ ```jsx
52
+ import { Animatable } from '@infinityfx/lively';
53
+
54
+ ...
55
+
56
+ <Animatable
57
+ onMount
58
+ initial={{ opacity: 0 }}
59
+ animate={{ opacity: 1 }}>
60
+ <div>...</div>
61
+ </Animatable>
62
+ ```
63
+
64
+ ### Animate `<Animate />`
65
+
66
+ Automatic animation based on pre-fab animations.
67
+
68
+ ### Morph `<Morph />`
69
+
70
+ Morphs one element into another.
71
+
72
+ ## Build-in animations
73
+
74
+ ### `<WriteOn />`
75
+
76
+ ```jsx
77
+ import { WriteOn } from '@infinityfx/lively/prebuild';
78
+
79
+ ...
80
+
81
+ <WriteOn>Lorem ipsum dolor sit amet</WriteOn>
82
+ ```
83
+
84
+ ### `<ColorWipe />`
85
+
86
+ ```jsx
87
+ import { ColorWipe } from '@infinityfx/lively/prebuild';
88
+
89
+ ...
90
+
91
+ <ColorWipe>
92
+ <div class="my-class">...</div>
93
+ </ColorWipe>
94
+ ```
@@ -0,0 +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-ee47eecd.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;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/toConsumableArray"),i=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("@babel/runtime/helpers/classCallCheck"),r=require("@babel/runtime/helpers/createClass"),a=require("@babel/runtime/helpers/defineProperty"),o=require("@babel/runtime/helpers/asyncToGenerator"),s=require("@babel/runtime/regenerator"),l=require("@babel/runtime/helpers/typeof");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),d=u(t),y=u(i),f=u(n),h=u(r),v=u(a),p=u(o),g=u(s),m=u(l),b=function(){function e(){f.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=p.default(g.default.mark((function e(){var t,i;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),k=function(e){return e&&"object"===m.default(e)&&!Array.isArray(e)},L=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=c.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},w=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=c.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},x=["delay","duration","repeat","interpolate","origin","useLayout"];function S(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 A(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 A(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 A(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,c=t.origin,d=void 0===c?{x:.5,y:.5}:c,h=t.useLayout,v=void 0!==h&&h,p=y.default(t,x),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};f.default(this,e),this.useLayout=v,this.keyframes=this.getKeyframes(p,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation="spring"===u?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":u,this.origin=this.originToStyle(d),this.repeat=s}return h.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if(k(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(d.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={start:{},end:{}};for(var s in t)if(s in e.initials){var l=i.interpolateKeyframe(t[s],a,r);k(l)&&("start"in l||"end"in l||"set"in l)?("start"in l&&(o.start[s]=l.start),"end"in l&&(o.end[s]=l.end),"set"in l&&(o[s]=l.set)):o[s]=l}return i.keyframeToStyle(o)}))}},{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 L(i);if(i.match(/^rgba?\(.*\)$/i))return w(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(k(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=S(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(k(e)){for(var n={},r=0,a=Object.keys(e);r<a.length;r++){var o=a[r];n[o]=this.interpolate(e[o],k(t)?t[o]:t,i)}return n}if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var s=!1;Array.isArray(e)&&(s=e[1],e=e[0]),Array.isArray(t)&&(s=t[1],t=t[0]);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];if(r===e.length-1)return a;var o=e[r+1];return this.interpolate(a,o,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=c.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=c.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")}};"start"in t&&!s||"end"in t&&s?(this.apply(e,t[s?"end":"start"],{duration:0}),b.delay(l,.001)):l(),("end"in t&&!s||"start"in t&&s)&&b.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})}},{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,i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.immediate,a=void 0!==r&&r,o=n.reverse,s=void 0!==o&&o,l=n.repeat,u=void 0===l?this.repeat:l;!e.Lively.animating||a?(this.setInitial(e,s?this.keyframes[this.keyframes.length-1]:this.keyframes[0]),e.Lively.index=1,e.Lively.animating=!0,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),requestAnimationFrame((function(){return i.getNext(e,s,u)}))):e.Lively.queue.push([this,{reverse:s,repeat:u}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?e.next=b.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=c.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.Lively.index;i&&(l=this.keyframes.length-1-l),this.apply(e,this.keyframes[l],{reverse:i}),e.Lively.index++,e.Lively.next=b.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();v.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=b,exports.addEventListener=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},exports.cacheElementStyles=function(e){"Lively"in e||(e.Lively={queue:[]}),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,y=e.getBoundingClientRect(),f=y.x,h=y.y,v=y.width,p=y.height;e.Lively.initials={x:f,y:h,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:c,zIndex:d,width:v+"px",height:p+"px",borderRadius:l.split(" ")[0],padding:u.split(" ")[0]}},exports.isObject=k,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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-60044d29.js"),t=require("@babel/runtime/helpers/objectWithoutProperties");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/regenerator");var o=n(e),i=n(t);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(u({opacity:1,duration:.65},e),{opacity:0})};var p=["direction"];function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=i.default(e,p),c=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":c=1,u=0,a={x:0,y:1};break;case"down":c=1,u=0,a={x:0,y:0}}return new r.Animation(l({scale:{x:1},origin:a,duration:.6},o),{scale:{x:c,y:u}})};var f=["direction"];function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return d.use=d.use.bind(d,e),d}d.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,c=i.default(e,f);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(y({clip:o.default({},n,0)},c),{clip:o.default({},n,1)})},exports.Move=r.Move,exports.Pop=r.Pop,exports.Fade=a,exports.Scale=b,exports.Wipe=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./animation-ee47eecd.js"),t=require("./pop-dff59f12.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/toConsumableArray"),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 s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.use=s.use.bind(s,e),s}s.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 p=["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,p),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=s,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("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/typeof"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/defineProperty"),u=require("@babel/runtime/regenerator"),p=require("react"),c=require("./pop-60044d29.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),d=require("@babel/runtime/helpers/toConsumableArray"),v=require("@babel/runtime/helpers/get");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=y(e),b=y(t),g=y(r),w=y(n),k=y(i),x=y(o),O=y(a),E=y(s),L=y(l),j=y(u),A=y(p),P=y(h),C=y(f),S=y(d),D=y(v);function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=E.default(e);if(t){var i=E.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return O.default(this,r)}}var V=function(e){x.default(d,e);var t,r,n,i,o,a,s,l,u,h,f=q(d);function d(e){var t;for(var r in w.default(this,d),(t=f.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.elements=[],t.children=[],t.level=0,t}return k.default(d,[{key:"update",value:function(){var e=this;this.elements.forEach((function(t){var r;c.cacheElementStyles(t),null===(r=e.animations.default)||void 0===r||r.setInitial(t)}))}},{key:"toAnimation",value:function(e){return!e||"object"!==g.default(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new c.Animation(R({},e),this.props.initial):null}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){(e.type===d||e.type.prototype instanceof d)&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(h=b.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),c.addEventListener("resize",this.resizeEventListener),this.update(!0),!("fonts"in document)||"loaded"===document.fonts.status){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update(!0);case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll());case 8:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"componentDidUpdate",value:(u=b.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),c.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;return this.elements.forEach((function(n){var i=n.getBoundingClientRect().y;t=t&&i+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,r=r&&i>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),i=m.default(n,2),o=i[0],a=i[1];t=t&&o,r=r&&a})),[t,r]}},{key:"onScroll",value:(l=b.default(j.default.mark((function e(){var t,r,n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),r=m.default(t,2),n=r[0],i=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&i&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"onResize",value:(s=b.default(j.default.mark((function e(){var t;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(t=this.nextResize)&&void 0!==t&&t.cancel&&this.nextResize.cancel(),this.nextResize=c.AnimationQueue.delay(this.update.bind(this),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"onEnter",value:(a=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onLeave",value:(o=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.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=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onBlur",value:(n=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.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=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=b.default(j.default.mark((function e(t){var r,n,i,o,a,s,l,u,p,h,f,d,v,y,m,b,g=this,w=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=w.length>1&&void 0!==w[1]?w[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,l=r.cascade,u=void 0!==l&&l,p=r.groupAdjust,h=void 0===p?0:p,f=r.cascadeDelay,d=void 0===f?0:f,v=r.staggerDelay,y=void 0===v?0:v,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in g.props?g.props.parentLevel-g.props.group:g.level+h;d=o?m.duration:d;var n=o?r*d:(g.props.parentLevel-r)*d;n=g.props.stagger*t+n+y,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:s})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:i<0?0:g.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&c.AnimationQueue.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=R(R({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===g.default(e[n])&&"object"===g.default(t[n])&&(r[n]=R(R({},t[n]),e[n]));return r}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,a=n.useElements,s=void 0!==a&&a,l=n.useEvents,u=void 0!==l&&l;if(!p.isValidElement(e))return e;var c={};e.type===d||e.type.prototype instanceof d||(s&&(c={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(c=R(R({},c),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===d||e.type.prototype instanceof d)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(c=R(R(R({},c),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:s?o:-1}}}));var h=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return p.cloneElement(e,c,h)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,p.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),d}(p.Component);L.default(V,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var I=["levels","animations"];function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=E.default(e);if(t){var i=E.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return O.default(this,r)}}var B=function(e){x.default(r,e);var t=z(r);function r(e){var n;return w.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=new Array(n.levels).fill(0).map((function(e,t){return t<n.props.animations.length?n.props.animations[t]:n.props.animations[n.props.animations.length-1]})),n}return k.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||p.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=C.default(n,I),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),A.default.createElement(V,P.default({animate:o},i),p.Children.map(e,(function(e){return p.isValidElement(e)?p.cloneElement(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,U({},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}(p.Component);function H(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Q(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 Q(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 Q(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 T(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 N(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(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=E.default(e);if(t){var i=E.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return O.default(this,r)}}L.default(B,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var _=function(e){x.default(o,e);var t,r,n,i=W(o);function o(e){var t,r,n;return w.default(this,o),(n=i.call(this,e)).parent=(null===(t=(r=n.props).parent)||void 0===t?void 0:t.call(r))||{group:""},n.group=n.parent.group+n.props.group,n.state={useLayout:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none",fontSize:"unset"}},n}return k.default(o,[{key:"layoutUpdate",value:function(){var e,t=getComputedStyle(this.element).position,r=!1;"absolute"===t||"fixed"===t?e={top:this.element.offsetTop,left:this.element.offsetLeft}:(e={position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},r=!0),this.setState({childStyles:e,parentStyles:N(N({},this.state.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight}),useLayout:r})}},{key:"update",value:(n=b.default(j.default.mark((function e(){var t,r,n,i,o=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>0&&void 0!==o[0]&&o[0],n=o.length>1&&void 0!==o[1]?o[1]:this.props.active,i=null===(t=this.element)||void 0===t?void 0:t.Lively,this.element=this.elements[0],this.element){e.next=6;break}return e.abrupt("return");case 6:if(!r||!this.props.useLayout){e.next=8;break}return e.abrupt("return",this.layoutUpdate());case 8:if(i?(this.element.Lively=i,c.setStyles(this.element,i.style)):c.cacheElementStyles(this.element),!this.parent.props){e.next=11;break}return e.abrupt("return");case 11:return e.next=13,c.AnimationQueue.sleep(.001);case 13:this.setUniqueId(),this.animations={default:this.createUnmorphAnimation()},n||this.animations.default.setInitial(this.element),this.children.forEach((function(e){var t=e.animatable;t&&(t.setUniqueId(),t.animations={default:t.createUnmorphAnimation()},n||t.animations.default.setInitial(t.element))}));case 17:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"componentDidUpdate",value:(r=b.default(j.default.mark((function e(t){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.update(!1,t.active);case 2:t.active===this.props.active||this.parent.props||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=b.default(j.default.mark((function e(t){var r,n;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t&&this.element.setAttribute("lively-morph-target",!0),e.next=3,c.AnimationQueue.sleep(.001);case 3:t?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)}))}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,a=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=o.properties;this.props.useLayout&&s.push.apply(s,S.default(o.layoutProperties));var l,u={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},p=H(s);try{for(p.s();!(l=p.n()).done;){var h=l.value;this.props.ignore.includes(h)||(u[h]=h in n?n[h]:a?[i[h],a[h],a[h]]:[i[h],i[h],i[h]])}}catch(e){p.e(e)}finally{p.f()}return new c.Animation(u)}},{key:"createMorphAnimation",value:function(e){var t,r;if(!e)return this.createAnimation(null,{opacity:[1,0,0],interact:[!0,!1,!1]});var n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;this.x=i.x-n.x,this.y=i.y-n.y,this.parent.props&&(this.x-=this.parent.x,this.y-=this.parent.y);var o=parseInt(i.width)/parseInt(n.width),a=parseInt(i.height)/parseInt(n.height);return this.createAnimation(e,{position:[{x:0,y:0},{x:this.x,y:this.y},{x:this.x,y:this.y}],scale:[{x:1,y:1},{x:o,y:a},{x:o,y:a}],opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var r=e.type!==o?{}:{parent:function(){return t}};return p.cloneElement(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!p.isValidElement(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,style:N(N({},t.props.style),this.state.childStyles)},i=D.default(E.default(o.prototype),"render",this).call(this,p.cloneElement(t,n,r));return this.state.useLayout?p.cloneElement(t,{style:this.state.parentStyles},i):i}}]),o}(V);L.default(_,"properties",["position","scale","opacity","backgroundColor","color","interact"]),L.default(_,"layoutProperties",["borderRadius","fontSize"]),L.default(_,"defaultProps",{id:null,group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]}),exports.Animatable=V,exports.Animate=B,exports.Morph=_;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./animatable-a9003593.js"),t=require("@babel/runtime/helpers/extends"),r=require("@babel/runtime/helpers/objectWithoutProperties"),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("react"),p=require("./pop-dff59f12.js"),c=require("./animation-ee47eecd.js"),f=require("@babel/runtime/helpers/toConsumableArray"),h=require("@babel/runtime/helpers/asyncToGenerator"),d=require("@babel/runtime/helpers/get"),y=require("@babel/runtime/regenerator");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/typeof");var v=m(t),b=m(r),g=m(n),w=m(i),O=m(o),x=m(a),j=m(s),k=m(u),A=m(l),P=m(f),S=m(h),q=m(d),L=m(y),C=["levels","animations"];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 R(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 I(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=j.default(e);if(t){var i=j.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return x.default(this,r)}}var M=function(t){O.default(n,t);var r=I(n);function n(e){var t;return g.default(this,n),(t=r.call(this,e)).levels=t.props.levels,t.animations=c.padArray(t.props.animations,t.levels),t}return w.default(n,[{key:"makeAnimatable",value:function(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(n<1||l.Children.count(t)<1)return t;var i=this.props;i.levels,i.animations;var o=b.default(i,C),a=this.animations[this.levels-n];return n===this.levels&&(o.ref=function(e){return r.animatable=e}),A.default.createElement(e.Animatable,v.default({animate:a},o),l.Children.map(t,(function(e){return l.isValidElement(e)?l.cloneElement(e,{},r.makeAnimatable(e.props.children,n-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,R({},r))}},{key:"shouldComponentUpdate",value:function(e){return e.animations===this.props.animations}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),n}(l.Component);function U(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 D(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 D(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 D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){k.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function T(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=j.default(e);if(t){var i=j.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return x.default(this,r)}}k.default(M,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[p.Move,p.Pop]});var B=function(e){O.default(o,e);var t,r,n,i=T(o);function o(e){var t,r,n;return g.default(this,o),(n=i.call(this,e)).parent=(null===(t=(r=n.props).parent)||void 0===t?void 0:t.call(r))||{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"},n}return w.default(o,[{key:"layout",value:function(){this.position=this.position||getComputedStyle(this.element).position;var e=F(F({},this.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight});"absolute"===this.position||"fixed"===this.position?e.position="absolute":(e.position="relative",this.childStyles=F(F({},this.childStyles),{},{position:"absolute",margin:0,top:0,left:0})),this.parentStyles=e,this.useLayout=!0,this.hasUpdated=!0,this.forceUpdate()}},{key:"update",value:(n=S.default(L.default.mark((function e(){var t,r,n,i,o,a,s,u,l=arguments;return L.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,n=void 0===r?!this.useLayout:r,i=t.active,o=void 0===i?this.props.active:i,this.element=this.elements[0],this.element){e.next=4;break}return e.abrupt("return");case 4:if(!this.props.useLayout||!n){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.animationFromKeyframes.apply(this,P.default(this.unmorphKeyframes()))},this.animations.default.setToLast(this.element,!o),a=U(this.children);try{for(a.s();!(s=a.n()).done;)(u=s.value.animatable).setUniqueId(),u.animations={default:u.animationFromKeyframes.apply(u,P.default(u.unmorphKeyframes()))},u.animations.default.setToLast(u.element,!o)}catch(e){a.e(e)}finally{a.f()}case 19:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"componentDidUpdate",value:(r=S.default(L.default.mark((function e(t){var r=this;return L.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Object.keys(t).reduce((function(e,n){return t[n]!=r.props[n]?[].concat(P.default(e),[n]):e}),[]),e.next=3,this.update({mount:!1,active:t.active});case 3:t.active!==this.props.active&&this.morph(this.props.active);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"morph",value:(t=S.default(L.default.mark((function e(t){var r,n;return L.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t&&this.element.setAttribute("lively-morph-target",!0),e.next=3,c.AnimationQueue.sleep(.001);case 3:t?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));this.animations[e]=this.animationFromKeyframes.apply(this,P.default(this.morphKeyframes(this.element,t)));var r,n=U(this.children);try{for(n.s();!(r=n.n()).done;){r.value.animatable.createAnimations(e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"animationFromKeyframes",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=P.default(o.properties);this.props.useLayout&&n.push.apply(n,P.default(o.layoutProperties));var i,a={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},s=U(n);try{var u=function(){var n=i.value;if(t.props.ignore.includes(n))return"continue";var o="auto";if(n in e&&(o=n),!(o in e))return"continue";a[n]=e[o].map((function(e){if(!c.isObject(e))return e in r?r[e][n]:e;var t={};for(var i in e)e[i]in r?t[i]=r[e[i]][n]:t[i]=e[i];return t}))};for(s.s();!(i=s.n()).done;)u()}catch(e){s.e(e)}finally{s.f()}return new c.Animation(a)}},{key:"morphKeyframes",value:function(e,t){var r,n;if(!t)return[{opacity:[1,0,0],interact:[!0,!1,!1]}];e=null===(r=e.Lively)||void 0===r?void 0:r.initials,t=null===(n=t.Lively)||void 0===n?void 0:n.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);var i=parseInt(t.width)/parseInt(e.width),o=parseInt(t.height)/parseInt(e.height);return[{auto:["from","to",{set:"to",end:"from"}],position:["from","to",{set:"to",end:"from"}],scale:["from","to",{set:"to",end:"from"}],opacity:[1,1,0],interact:[!0,!0,!1]},{from:F(F({},e),{},{position:{x:0,y:0},scale:{x:1,y:1}}),to:F(F({},t),{},{position:{x:this.x,y:this.y},scale:{x:i,y:o}})}]}},{key:"unmorphKeyframes",value:function(){return[{auto:["from","from","from"],position:[{x:0,y:0}],scale:[{x:1,y:1}],opacity:[0,0,1],interact:[!1,!1,!0]},{from:this.element.Lively.initials}]}},{key:"getChildren",value:function(e){var t=this;return l.Children.map(e,(function(e){if(!l.isValidElement(e))return e;var r=e.type!==o?{}:{parent:function(){return t},duration:t.props.duration};return l.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(!l.isValidElement(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,style:F(F({},t.props.style),this.childStyles)},i=q.default(j.default(o.prototype),"render",this).call(this,l.cloneElement(t,n,r));return this.useLayout?l.cloneElement(t,{style:this.parentStyles},i):i}}]),o}(e.Animatable);k.default(B,"properties",["position","scale","opacity","backgroundColor","color","interact","zIndex"]),k.default(B,"layoutProperties",["borderRadius","fontSize"]),k.default(B,"defaultProps",{group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]}),exports.Animatable=e.Animatable,exports.Animate=M,exports.Morph=B;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),r=require("./animation-ee47eecd.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./animatable-a9003593.js");function t(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/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/helpers/inherits"),require("@babel/runtime/helpers/possibleConstructorReturn"),require("@babel/runtime/helpers/getPrototypeOf"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("./animation-ee47eecd.js"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/objectWithoutProperties");var i=t(e);function a(e){var t=e.children,a=e.className,l=e.style,n=e.duration;if("string"!=typeof t)return t;var o=t.split("");return i.default.createElement("div",{className:a,style:l},i.default.createElement(r.Animatable,{whileViewport:!0,animate:{opacity:1,position:{y:0},rotation:0,duration:.8},initial:{opacity:0,position:{y:"100%"},rotation:10},stagger:(n-.8)/(o.length-1)},o.map((function(e,r){return i.default.createElement("span",{style:{display:"inline-block"},key:r},/\s/.test(e)?" ":e)}))))}function l(t){var a,l=t.children,n=t.color,o=t.duration,u=(null===(a=l.props)||void 0===a?void 0:a.children)||[];return Array.isArray(u)||(u=[u]),u.unshift(i.default.createElement(r.Animatable,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:o/2}},i.default.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:n}}))),i.default.createElement(r.Animatable,{whileViewport:!0,animate:{clip:{right:0},duration:o/2},initial:{clip:{right:1}}},e.cloneElement(l,{},u))}a.defaultProps={style:{},className:"",duration:1.6},l.defaultProps={color:"grey",duration:1.6},exports.ColorWipe=l,exports.WriteOn=a;
@@ -0,0 +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-f6683b75.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};
@@ -0,0 +1 @@
1
+ import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/toConsumableArray";import i from"@babel/runtime/helpers/objectWithoutProperties";import n from"@babel/runtime/helpers/classCallCheck";import r from"@babel/runtime/helpers/createClass";import a from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/asyncToGenerator";import s from"@babel/runtime/regenerator";import l from"@babel/runtime/helpers/typeof";var u=function(){function e(){n(this,e),this.queue=[],this.tick()}var t;return r(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=o(s.mark((function e(){var t,i;return s.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),c=function(e){return e&&"object"===l(e)&&!Array.isArray(e)},d=function(e,t){return new Array(t).fill(0).map((function(t,i){return i<e.length?e[i]:e[e.length-1]}))},y=function(t){var i=t.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=e(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(t){var i=t.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=e(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}},v=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},f=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]},p=function(e){"Lively"in e||(e.Lively={queue:[]}),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,y=e.getBoundingClientRect(),h=y.x,v=y.y,f=y.width,p=y.height;e.Lively.initials={x:h,y:v,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:c,zIndex:d,width:f+"px",height:p+"px",borderRadius:l.split(" ")[0],padding:u.split(" ")[0]}},g=["delay","duration","repeat","interpolate","origin","useLayout"];function m(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 b(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 b(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 b(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 k=function(){function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.delay,r=void 0===t?0:t,o=e.duration,s=void 0===o?1:o,l=e.repeat,u=void 0===l?1:l,c=e.interpolate,d=void 0===c?"ease":c,y=e.origin,h=void 0===y?{x:.5,y:.5}:y,v=e.useLayout,f=void 0!==v&&v,p=i(e,g),m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,a),this.useLayout=f,this.keyframes=this.getKeyframes(p,m),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation="spring"===d?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":d,this.origin=this.originToStyle(h),this.repeat=u}return r(a,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if(c(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(e){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,o=function(o){var s=o in n?n[o]:a.initials[o];Array.isArray(e[o])||(e[o]=[e[o]]),e[o]=e[o].length>1?e[o]:[s].concat(t(e[o])),e[o]=e[o].map((function(e){return i.sanitize(o,e)})),r=e[o].length>r?e[o].length:r};for(var s in e)o(s);return new Array(r).fill(0).map((function(t,n){var o={start:{},end:{}};for(var s in e)if(s in a.initials){var l=i.interpolateKeyframe(e[s],n,r);c(l)&&("start"in l||"end"in l||"set"in l)?("start"in l&&(o.start[s]=l.start),"end"in l&&(o.end[s]=l.end),"set"in l&&(o[s]=l.set)):o[s]=l}return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof t){if(t.match(/^#[0-9a-f]{3,8}$/i))return y(t);if(t.match(/^rgba?\(.*\)$/i))return h(t);var n=parseFloat(t),r=(t.match(/[^0-9\.]*$/i)||["px"])[0];return isNaN(n)?a.initials[e]:("%"===r&&(n/=100),r?[n,r]:n)}if(c(t)){var o=Object.keys(t),s=t;("x"in t||"y"in t)&&(o=["x","y"]),("r"in t||"g"in t||"b"in t||"a"in t)&&(o=["r","g","b","a"]),("left"in t||"right"in t||"top"in t||"bottom"in t)&&(o=["left","right","top","bottom"]),t={};var l,u=m(o);try{for(u.s();!(l=u.n()).done;){var d=l.value;t[d]=this.sanitize(e,s[d],d)}}catch(e){u.e(e)}finally{u.f()}}if(void 0!==t)return t;var v=a.initials[e];return i in v?v[i]:v}},{key:"interpolate",value:function(e,t,i){if(c(e)){for(var n={},r=0,a=Object.keys(e);r<a.length;r++){var o=a[r];n[o]=this.interpolate(e[o],c(t)?t[o]:t,i)}return n}if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var s=!1;Array.isArray(e)&&(s=e[1],e=e[0]),Array.isArray(t)&&(s=t[1],t=t[0]);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];if(r===e.length-1)return a;var o=e[r+1];return this.interpolate(a,o,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(t){for(var i={transform:""},n=0,r=Object.entries(t);n<r.length;n++){var a=e(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(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(t,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,c=function(){t.style.transitionDuration="".concat(o,"s");for(var r=0,a=Object.entries(i);r<a.length;r++){var s=e(a[r],2),l=s[0],u=s[1];"width"!==l?"height"!==l?"padding"===l&&(i.width||i.height)||"start"!==l&&"end"!==l&&(t.style[l]=u):n.setLength(t,i,"height","paddingTop","paddingBottom"):n.setLength(t,i,"width","paddingLeft","paddingRight")}};"start"in i&&!l||"end"in i&&l?(this.apply(t,i[l?"end":"start"],{duration:0}),u.delay(c,.001)):c(),("end"in i&&!l||"start"in i&&l)&&u.delay(this.apply.bind(this,t,i[l?"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})}},{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,i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.immediate,a=void 0!==r&&r,o=n.reverse,s=void 0!==o&&o,l=n.repeat,u=void 0===l?this.repeat:l;!e.Lively.animating||a?(this.setInitial(e,s?this.keyframes[this.keyframes.length-1]:this.keyframes[0]),e.Lively.index=1,e.Lively.animating=!0,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),requestAnimationFrame((function(){return i.getNext(e,s,u)}))):e.Lively.queue.push([this,{reverse:s,repeat:u}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?e.next=u.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(t){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(t.Lively.index===this.keyframes.length){t.Lively.animating=!1;var a=t.Lively.queue.shift()||[],o=e(a,2),s=o[0],l=o[1];return s?s.start(t,l):void(r>1&&this.start(t,{reverse:n,repeat:r-1}))}var c=t.Lively.index;n&&(c=this.keyframes.length-1-c),this.apply(t,this.keyframes[c],{reverse:n}),t.Lively.index++,t.Lively.next=u.delay((function(){return i.getNext(t,n,r)}),this.delta)}}]),a}();a(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{u as A,k as a,v as b,p as c,c as i,d as p,f as r};
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-531fd7cc.js";export{M as Move,P as Pop}from"./pop-531fd7cc.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.use=i.use.bind(i,e),i}i.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(o({opacity:1,duration:.65},e),{opacity:0})};var c=["direction"];function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.use=u.use.bind(u,e),u}u.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,u=1,b={x:0,y:.5};switch(o){case"left":b.x=1;break;case"up":p=1,u=0,b={x:0,y:1};break;case"down":p=1,u=0,b={x:0,y:0}}return new r(s({scale:{x:1},origin:b,duration:.6},i),{scale:{x:p,y:u}})};var b=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return f.use=f.use.bind(f,e),f}f.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,b);return["left","right","top","bottom"].includes(i)||(i="right"),new r(l({clip:e({},i,0)},c),{clip:e({},i,1)})};export{i as Fade,u as Scale,f as Wipe};
1
+ import e from"@babel/runtime/helpers/defineProperty";import{a as r}from"./animation-f6683b75.js";export{M as Move,P as Pop}from"./pop-e25984d4.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";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 b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,b=1,u={x:0,y:.5};switch(o){case"left":u.x=1;break;case"up":p=1,b=0,u={x:0,y:1};break;case"down":p=1,b=0,u={x:0,y:0}}return new r(s({scale:{x:1},origin:u,duration:.6},i),{scale:{x:p,y:b}})};var u=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return f.use=f.use.bind(f,e),f}f.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,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,b as Scale,f as Wipe};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{c as d,A as y,a as m,r as b,b as g,M as w,P as k,s as O}from"./pop-531fd7cc.js";import x from"@babel/runtime/helpers/extends";import L from"@babel/runtime/helpers/objectWithoutProperties";import j from"@babel/runtime/helpers/toConsumableArray";import A from"@babel/runtime/helpers/get";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 E(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){l(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 S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var C=function(s){o(C,v);var a,l,p,w,k,O,x,L,j,A,P=S(C);function C(e){var t;for(var r in n(this,C),(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(C,[{key:"update",value:function(){var e=this;this.elements.forEach((function(t){var r;d(t),null===(r=e.animations.default)||void 0===r||r.setInitial(t)}))}},{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():Object.keys(e).length?new y(E({},e),this.props.initial):null}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){(e.type===C||e.type.prototype instanceof C)&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(A=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.resizeEventListener=this.onResize.bind(this),m("resize",this.resizeEventListener),this.update(!0),!("fonts"in document)||"loaded"===document.fonts.status){e.next=7;break}return e.next=6,document.fonts.ready;case 6:this.update(!0);case 7:(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),m("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll());case 8:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"componentDidUpdate",value:(j=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.update();case 1:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){b("scroll",this.scrollEventListener),b("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;return this.elements.forEach((function(e){var i=e.getBoundingClientRect().y;r=r&&i+e.clientHeight*(1-t.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+e.clientHeight*t.viewportMargin})),this.elements.length||this.children.forEach((function(t){var i=t.animatable.inViewport(),o=e(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(L=t(u.mark((function t(){var r,n,i,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(Date.now()-this.scrollDelta<350)){t.next=2;break}return t.abrupt("return");case 2:this.scrollDelta=Date.now(),r=this.inViewport(),n=e(r,2),i=n[0],o=n[1],!this.inView&&i&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return L.apply(this,arguments)})},{key:"onResize",value:(x=t(u.mark((function e(){var t;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(t=this.nextResize)&&void 0!==t&&t.cancel&&this.nextResize.cancel(),this.nextResize=g.delay(this.update.bind(this),.25);case 2:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"onLeave",value:(k=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"onFocus",value:(w=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"onBlur",value:(p=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"onClick",value:(l=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=t(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,d,y,m,b,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,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(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+y,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&g.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=E(E({},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]=E(E({},t[i]),e[i]));return n}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,s=n.useElements,a=void 0!==s&&s,l=n.useEvents,u=void 0!==l&&l;if(!h(e))return e;var p={};e.type===C||e.type.prototype instanceof C||(a&&(p={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(p=E(E({},p),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===C||e.type.prototype instanceof C)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(p=E(E(E({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:a?o:-1}}}));var v=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return f(e,p,v)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,c.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),C}();l(C,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var D=["levels","animations"];function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function I(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 F=function(e){o(r,v);var t=I(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return i(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||c.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=L(n,D),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(C,x({animate:o},i),c.map(e,(function(e){return h(e)?f(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,M({},r))}},{key:"shouldComponentUpdate",value:function(e){return e.animations===this.props.animations}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function U(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return V(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return V(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}l(F,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[w,k]});var q=function(e){o(v,C);var r,s,l,p=H(v);function v(e){var t,r,i;return n(this,v),(i=p.call(this,e)).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.state={useLayout:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none",fontSize:"unset"}},i}return i(v,[{key:"layoutUpdate",value:function(){var e,t=getComputedStyle(this.element).position,r=!1;"absolute"===t||"fixed"===t?e={top:this.element.offsetTop,left:this.element.offsetLeft}:(e={position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},r=!0),this.setState({childStyles:e,parentStyles:B(B({},this.state.parentStyles),{},{width:this.element.offsetWidth,height:this.element.offsetHeight}),useLayout:r})}},{key:"update",value:(l=t(u.mark((function e(){var t,r,n,i,o=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>0&&void 0!==o[0]&&o[0],n=o.length>1&&void 0!==o[1]?o[1]:this.props.active,i=null===(t=this.element)||void 0===t?void 0:t.Lively,this.element=this.elements[0],this.element){e.next=6;break}return e.abrupt("return");case 6:if(!r||!this.props.useLayout){e.next=8;break}return e.abrupt("return",this.layoutUpdate());case 8:if(i?(this.element.Lively=i,O(this.element,i.style)):d(this.element),!this.parent.props){e.next=11;break}return e.abrupt("return");case 11:return e.next=13,g.sleep(.001);case 13:this.setUniqueId(),this.animations={default:this.createUnmorphAnimation()},n||this.animations.default.setInitial(this.element),this.children.forEach((function(e){var t=e.animatable;t&&(t.setUniqueId(),t.animations={default:t.createUnmorphAnimation()},n||t.animations.default.setInitial(t.element))}));case 17:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"componentDidUpdate",value:(s=t(u.mark((function e(t){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.update(!1,t.active);case 2:t.active===this.props.active||this.parent.props||this.morph(this.props.active);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"morph",value:(r=t(u.mark((function e(t){var r,n;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t&&this.element.setAttribute("lively-morph-target",!0),e.next=3,g.sleep(.001);case 3:t?this.play("default",{immediate:!0}):(r=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(r.removeAttribute("lively-morph-target"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)}))}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,o=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=v.properties;this.props.useLayout&&s.push.apply(s,j(v.layoutProperties));var a,l={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},u=U(s);try{for(u.s();!(a=u.n()).done;){var p=a.value;this.props.ignore.includes(p)||(l[p]=p in n?n[p]:o?[i[p],o[p],o[p]]:[i[p],i[p],i[p]])}}catch(e){u.e(e)}finally{u.f()}return new y(l)}},{key:"createMorphAnimation",value:function(e){var t,r;if(!e)return this.createAnimation(null,{opacity:[1,0,0],interact:[!0,!1,!1]});var n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;this.x=i.x-n.x,this.y=i.y-n.y,this.parent.props&&(this.x-=this.parent.x,this.y-=this.parent.y);var o=parseInt(i.width)/parseInt(n.width),s=parseInt(i.height)/parseInt(n.height);return this.createAnimation(e,{position:[{x:0,y:0},{x:this.x,y:this.y},{x:this.x,y:this.y}],scale:[{x:1,y:1},{x:o,y:s},{x:o,y:s}],opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var r=e.type!==v?{}:{parent:function(){return t}};return f(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!h(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,style:B(B({},t.props.style),this.state.childStyles)},i=A(a(v.prototype),"render",this).call(this,f(t,n,r));return this.state.useLayout?f(t,{style:this.state.parentStyles},i):i}}]),v}();l(q,"properties",["position","scale","opacity","backgroundColor","color","interact"]),l(q,"layoutProperties",["borderRadius","fontSize"]),l(q,"defaultProps",{id:null,group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]});export{C as Animatable,F as Animate,q as Morph};
1
+ import{A as t}from"./animatable-2a9b9c4f.js";export{A as Animatable}from"./animatable-2a9b9c4f.js";import e from"@babel/runtime/helpers/extends";import r from"@babel/runtime/helpers/objectWithoutProperties";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import a from"@babel/runtime/helpers/possibleConstructorReturn";import s from"@babel/runtime/helpers/getPrototypeOf";import u from"@babel/runtime/helpers/defineProperty";import l,{Children as p,isValidElement as c,cloneElement as h,Component as f}from"react";import{M as m,P as y}from"./pop-e25984d4.js";import{p as v,A as d,c as b,i as g,a as w}from"./animation-f6683b75.js";import O from"@babel/runtime/helpers/toConsumableArray";import k from"@babel/runtime/helpers/asyncToGenerator";import x from"@babel/runtime/helpers/get";import j from"@babel/runtime/regenerator";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/typeof";var P=["levels","animations"];function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function L(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach((function(e){u(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function C(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=s(t);if(e){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return a(this,r)}}var R=function(a){o(u,f);var s=C(u);function u(t){var e;return n(this,u),(e=s.call(this,t)).levels=e.props.levels,e.animations=v(e.props.animations,e.levels),e}return i(u,[{key:"makeAnimatable",value:function(n){var i=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(o<1||p.count(n)<1)return n;var a=this.props;a.levels,a.animations;var s=r(a,P),u=this.animations[this.levels-o];return o===this.levels&&(s.ref=function(t){return i.animatable=t}),l.createElement(t,e({animate:u},s),p.map(n,(function(t){return c(t)?h(t,{},i.makeAnimatable(t.props.children,o-1)):t})))}},{key:"play",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(e=this.animatable)||void 0===e||e.play(t,L({},r))}},{key:"shouldComponentUpdate",value:function(t){return t.animations===this.props.animations}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),u}();function I(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 U(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 U(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,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 U(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function D(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function K(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?D(Object(r),!0).forEach((function(e){u(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function E(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=s(t);if(e){var i=s(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return a(this,r)}}u(R,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[m,y]});var M=function(e){o(f,t);var r,a,u,l=E(f);function f(t){var e,r,i;return n(this,f),(i=l.call(this,t)).parent=(null===(e=(r=i.props).parent)||void 0===e?void 0:e.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"},i}return i(f,[{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:(u=k(j.mark((function t(){var e,r,n,i,o,a,s,u,l=arguments;return j.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=l.length>0&&void 0!==l[0]?l[0]:{},r=e.mount,n=void 0===r?!this.useLayout:r,i=e.active,o=void 0===i?this.props.active:i,this.element=this.elements[0],this.element){t.next=4;break}return t.abrupt("return");case 4:if(!this.props.useLayout||!n){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(b(this.element),this.hasUpdated=!1,!this.parent.props){t.next=12;break}return t.abrupt("return");case 12:return t.next=14,d.sleep(.001);case 14:this.setUniqueId(),this.animations={default:this.animationFromKeyframes.apply(this,O(this.unmorphKeyframes()))},this.animations.default.setToLast(this.element,!o),a=I(this.children);try{for(a.s();!(s=a.n()).done;)(u=s.value.animatable).setUniqueId(),u.animations={default:u.animationFromKeyframes.apply(u,O(u.unmorphKeyframes()))},u.animations.default.setToLast(u.element,!o)}catch(t){a.e(t)}finally{a.f()}case 19:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"setUniqueId",value:function(){this.parent.id&&(this.id=this.parent.id),"id"in this||("Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++),"id"in this&&this.element.setAttribute("lively-morph-id",this.id.toString())}},{key:"componentDidUpdate",value:(a=k(j.mark((function t(e){var r=this;return j.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Object.keys(e).reduce((function(t,n){return e[n]!=r.props[n]?[].concat(O(t),[n]):t}),[]),t.next=3,this.update({mount:!1,active:e.active});case 3:e.active!==this.props.active&&this.morph(this.props.active);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"morph",value:(r=k(j.mark((function t(e){var r,n;return j.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e&&this.element.setAttribute("lively-morph-target",!0),t.next=3,d.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"),(n=r.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(n),this.play(n,{immediate:!0}));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return r.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.animationFromKeyframes.apply(this,O(this.morphKeyframes(this.element,e)));var r,n=I(this.children);try{for(n.s();!(r=n.n()).done;){r.value.animatable.createAnimations(t)}}catch(t){n.e(t)}finally{n.f()}}},{key:"animationFromKeyframes",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=O(f.properties);this.props.useLayout&&n.push.apply(n,O(f.layoutProperties));var i,o={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0},duration:this.props.duration},a=I(n);try{var s=function(){var n=i.value;if(e.props.ignore.includes(n))return"continue";var a="auto";if(n in t&&(a=n),!(a in t))return"continue";o[n]=t[a].map((function(t){if(!g(t))return t in r?r[t][n]:t;var e={};for(var i in t)t[i]in r?e[i]=r[t[i]][n]:e[i]=t[i];return e}))};for(a.s();!(i=a.n()).done;)s()}catch(t){a.e(t)}finally{a.f()}return new w(o)}},{key:"morphKeyframes",value:function(t,e){var r,n;if(!e)return[{opacity:[1,0,0],interact:[!0,!1,!1]}];t=null===(r=t.Lively)||void 0===r?void 0:r.initials,e=null===(n=e.Lively)||void 0===n?void 0:n.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);var i=parseInt(e.width)/parseInt(t.width),o=parseInt(e.height)/parseInt(t.height);return[{auto:["from","to",{set:"to",end:"from"}],position:["from","to",{set:"to",end:"from"}],scale:["from","to",{set:"to",end:"from"}],opacity:[1,1,0],interact:[!0,!0,!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:i,y:o}})}]}},{key:"unmorphKeyframes",value:function(){return[{auto:["from","from","from"],position:[{x:0,y:0}],scale:[{x:1,y:1}],opacity:[0,0,1],interact:[!1,!1,!0]},{from:this.element.Lively.initials}]}},{key:"getChildren",value:function(t){var e=this;return p.map(t,(function(t){if(!c(t))return t;var r=t.type!==f?{}:{parent:function(){return e},duration:e.props.duration};return h(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),n={"lively-morph-group":this.group,style:K(K({},e.props.style),this.childStyles)},i=x(s(f.prototype),"render",this).call(this,h(e,n,r));return this.useLayout?h(e,{style:this.parentStyles},i):i}}]),f}();u(M,"properties",["position","scale","opacity","backgroundColor","color","interact","zIndex"]),u(M,"layoutProperties",["borderRadius","fontSize"]),u(M,"defaultProps",{group:0,active:!1,useLayout:!1,interpolate:"ease",duration:1.5,ignore:[]});export{R as Animate,M as Morph};
@@ -0,0 +1 @@
1
+ import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import{a as r}from"./animation-f6683b75.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 s(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 a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}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),s="0px",a="20px";switch(c){case"down":a="-20px";break;case"left":s="20px",a="0px";break;case"right":s="-20px",a="0px"}return new r(i({position:{x:"0px",y:"0px"},opacity:1,duration:.5},p),{position:{x:s,y:a},opacity:0})},a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(s({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{c as M,a as P};
@@ -0,0 +1 @@
1
+ import e,{cloneElement as t}from"react";import{A as r}from"./animatable-2a9b9c4f.js";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/helpers/inherits";import"@babel/runtime/helpers/possibleConstructorReturn";import"@babel/runtime/helpers/getPrototypeOf";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/regenerator";import"./animation-f6683b75.js";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/objectWithoutProperties";function i(t){var i=t.children,a=t.className,o=t.style,l=t.duration;if("string"!=typeof i)return i;var n=i.split("");return e.createElement("div",{className:a,style:o},e.createElement(r,{whileViewport:!0,animate:{opacity:1,position:{y:0},rotation:0,duration:.8},initial:{opacity:0,position:{y:"100%"},rotation:10},stagger:(l-.8)/(n.length-1)},n.map((function(t,r){return e.createElement("span",{style:{display:"inline-block"},key:r},/\s/.test(t)?" ":t)}))))}function a(i){var a,o=i.children,l=i.color,n=i.duration,s=(null===(a=o.props)||void 0===a?void 0:a.children)||[];return Array.isArray(s)||(s=[s]),s.unshift(e.createElement(r,{key:0,initial:{clip:{right:0}},animate:{clip:{left:1},duration:n/2}},e.createElement("div",{style:{position:"absolute",inset:0,backgroundColor:l}}))),e.createElement(r,{whileViewport:!0,animate:{clip:{right:0},duration:n/2},initial:{clip:{right:1}}},t(o,{},s))}i.defaultProps={style:{},className:"",duration:1.6},a.defaultProps={color:"grey",duration:1.6};export{a as ColorWipe,i as WriteOn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinityfx/lively",
3
- "version": "0.0.12",
3
+ "version": "0.1.0",
4
4
  "description": "Zero configuration, performant react animation library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -16,6 +16,10 @@
16
16
  "./hooks": {
17
17
  "import": "./dist/esm/hooks.js",
18
18
  "require": "./dist/cjs/hooks.js"
19
+ },
20
+ "./prebuild": {
21
+ "import": "./dist/esm/prebuild.js",
22
+ "require": "./dist/cjs/prebuild.js"
19
23
  }
20
24
  },
21
25
  "types": "./types/index.d.ts",
@@ -9,6 +9,7 @@ declare interface Animatable {
9
9
  noCascade?: boolean;
10
10
  onMount?: string | boolean;
11
11
  onUnmount?: string | boolean;
12
+ onClick?: string | boolean;
12
13
  whileViewport?: string | boolean;
13
14
  whileHover?: string | boolean;
14
15
  whileFocus?: string | boolean;
@@ -16,14 +17,16 @@ declare interface Animatable {
16
17
 
17
18
  export class Animatable extends React.Component<Animatable> {
18
19
 
19
- private toAnimation;
20
+ private update;
20
21
 
21
- private countNestedLevels;
22
+ private toAnimation;
22
23
 
23
24
  private inViewport;
24
25
 
25
26
  private onScroll;
26
27
 
28
+ private onResize;
29
+
27
30
  private onEnter;
28
31
 
29
32
  private onLeave;
@@ -34,8 +37,6 @@ export class Animatable extends React.Component<Animatable> {
34
37
 
35
38
  private onClick;
36
39
 
37
- setInitial(animationName: string, reset?: boolean): Promise<void>;
38
-
39
40
  play(animationName: string, { callback, reverse, immediate, cascade, groupAdjust, cascadeDelay, staggerDelay }?: {
40
41
  callback?: Function;
41
42
  reverse?: boolean;
@@ -46,10 +47,10 @@ export class Animatable extends React.Component<Animatable> {
46
47
  staggerDelay?: number;
47
48
  }): Promise<void>;
48
49
 
49
- private style;
50
-
51
50
  private mergeProperties;
52
51
 
53
52
  private deepClone;
53
+
54
+ private countNestedLevels;
54
55
 
55
56
  }
@@ -6,9 +6,11 @@ declare interface Animate {
6
6
  animations?: array;
7
7
  onMount?: string | boolean;
8
8
  onUnmount?: string | boolean;
9
+ onClick?: string | boolean;
9
10
  whileViewport?: string | boolean;
10
11
  whileHover?: string | boolean;
11
12
  whileFocus?: string | boolean;
13
+ levels?: number;
12
14
  }
13
15
 
14
16
  export class Animate extends React.Component<Animate> {
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export as namespace Lively;
2
2
 
3
3
  export { Animatable } from './animatable';
4
+ export { Animate } from './animate';
4
5
  export { Morph } from './morph';
package/types/morph.d.ts CHANGED
@@ -4,23 +4,31 @@ declare interface Morph {
4
4
  active?: boolean;
5
5
  group?: number;
6
6
  useLayout?: boolean;
7
+ interpolate?: string;
8
+ duration?: number;
9
+ ignore?: string[];
7
10
  }
8
11
 
9
12
  export class Morph extends React.Component<Morph> {
10
13
 
11
- private getParentPosition;
14
+ private static properties;
15
+ private static layoutProperties;
12
16
 
13
- private positionKeyframes;
17
+ private layoutUpdate;
14
18
 
15
- private scaleKeyframes;
19
+ private update;
16
20
 
17
- private createMorphAnimation;
21
+ private setUniqueId;
22
+
23
+ private morph;
18
24
 
19
- private createResetAnimation;
25
+ private createAnimations;
20
26
 
21
- private parentStyle;
27
+ private createAnimation;
28
+
29
+ private createMorphAnimation;
22
30
 
23
- private childStyle;
31
+ private createUnmorphAnimation;
24
32
 
25
33
  private getChildren;
26
34
 
@@ -1 +0,0 @@
1
- "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/toConsumableArray"),a=require("@babel/runtime/helpers/typeof"),o=require("@babel/runtime/helpers/classCallCheck"),s=require("@babel/runtime/helpers/createClass"),l=require("@babel/runtime/regenerator");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(e),d=c(t),f=c(i),y=c(n),v=c(r),p=c(a),h=c(o),g=c(s),b=c(l),m=function(){function e(){h.default(this,e),this.queue=[],this.tick()}var t;return g.default(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=f.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),k=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=y.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},x=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=y.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},w=function(e,t){for(var i in e.style={},t)e.style[i]=t[i]},L=["delay","duration","repeat","interpolate","origin","useLayout"],O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.delay,n=void 0===i?0:i,r=t.duration,a=void 0===r?1:r,o=t.repeat,s=void 0===o?1:o,l=t.interpolate,c=void 0===l?"ease":l,u=t.origin,f=void 0===u?{x:.5,y:.5}:u,y=t.useLayout,v=void 0!==y&&y,p=d.default(t,L),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h.default(this,e),this.useLayout=v,this.keyframes=this.getKeyframes(p,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation="spring"===c?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":c,this.origin=this.originToStyle(f),this.repeat=s}var t;return g.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===p.default(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(v.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],a,r));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return k(i);if(i.match(/^rgba?\(.*\)$/i))return x(i);var a=parseFloat(i),o=i.match(/[^0-9\.]*$/i);return isNaN(a)?e.initials[t]:("%"===o&&(a/=100),o?[a,o]:a)}if("object"===p.default(i)){var s=Object.keys(i);("x"in i||"y"in i)&&(s=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(s=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(s=["left","right","top","bottom"]),s.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),a=Math.floor(r),o=e[a];if(a===e.length-1)return o;var s=e[a+1];if("object"===p.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=y.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[r]=t.toString(a,"px");break;case"backgroundColor":case"color":i[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"interact":i.pointerEvents=a?"all":"none";break;case"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t;e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=(null===(t=e.Lively)||void 0===t?void 0:t.keyframe)||this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),l=t[i],c=t.padding?1:o/(0===s?1e-6:s);"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(u,") * ");e.style[n]=d+.5*c,e.style[r]=d+1/c*.5}},{key:"apply",value:(t=f.default(b.default.mark((function e(t,i){var n,r,a=this,o=arguments;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],!("active"in i)){e.next=11;break}if("start"!==(r=Object.keys(i.active)[0])&&!n){e.next=10;break}if(t.style.display=i.active[r]?"":"none",n){e.next=8;break}return e.next=8,m.sleep(.001);case 8:e.next=11;break;case 10:m.delay((function(){t.style.display=i.active[r]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var n=y.default(e,2),r=n[0],o=n[1];return"width"===r?a.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===r?a.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===r||"padding"===r&&(i.width||i.height)||(t.style[r]=o))})),t.Lively.keyframe=i;case 13:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"start",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.immediate,r=void 0!==n&&n,a=i.reverse,o=void 0!==a&&a,s=i.repeat,l=void 0===s?this.repeat:s;!e.Lively.animating||r?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.index=1,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),this.getNext(e,o,l)):e.Lively.queue.push([this,{reverse:o,repeat:l}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?e.next=m.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}),e.Lively.animating=!0)}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=y.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.Lively.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.Lively.index++,e.Lively.next=m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();u.default(O,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var j=["direction"];function S(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function q(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?S(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E.use=E.use.bind(E,e),E}function P(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function A(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?P(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):P(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return D.use=D.use.bind(D,e),D}E.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,i=void 0===t?"up":t,n=d.default(e,j),r="0px",a="20px";switch(i){case"down":a="-20px";break;case"left":r="20px",a="0px";break;case"right":r="-20px",a="0px"}return new O(q({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},D.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new O(A({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=O,exports.AnimationQueue=m,exports.Move=E,exports.Pop=D,exports.addEventListener=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},exports.cacheElementStyles=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),w(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,l=t.borderRadius,c=t.padding,u=t.fontSize,d=e.getBoundingClientRect(),f=d.x,y=d.y;e.Lively.initials={x:f,y:y,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:l.split(" ")[0],padding:c.split(" ")[0]}},exports.removeEventListener=function(e,t){var i,n;"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]},exports.setStyles=w;
@@ -1 +0,0 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import s from"@babel/runtime/helpers/createClass";import c from"@babel/runtime/regenerator";var l=function(){function e(){o(this,e),this.queue=[],this.tick()}var t;return s(e,[{key:"uuid",value:function(){return Math.floor(1e6*Math.random()).toString(16).padStart("0",6)}},{key:"tick",value:(t=i(c.mark((function e(){var t,i;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"cancel",value:function(e){var t=this.search(e);this.queue[t].id===e.id&&this.queue.splice(t,1),delete e.cancel}},{key:"delay",value:function(e,t){var i=this;if(e instanceof Function){var n=this.uuid(),r=Date.now()+1e3*t,a={timestamp:r,id:n,cancel:function(){return i.cancel(a)}};return this.insert({callback:function(){delete a.cancel,e()},timestamp:r,id:n}),a}}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:function(e,t){return this.get().delay(e,t)}},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),u=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(a.padStart(2,a),16),b:parseInt(o.padStart(2,o),16),a:void 0!==s?parseInt(s,16):255}},y=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},d=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},p=function(e,t){var i,n;"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]},v=function(e,t){for(var i in e.style={},t)e.style[i]=t[i]},f=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),v(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,c=t.borderRadius,l=t.padding,u=t.fontSize,y=e.getBoundingClientRect(),d=y.x,p=y.y;e.Lively.initials={x:d,y:p,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:c.split(" ")[0],padding:l.split(" ")[0]}},h=["delay","duration","repeat","interpolate","origin","useLayout"],g=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.delay,r=void 0===n?0:n,a=i.duration,s=void 0===a?1:a,c=i.repeat,l=void 0===c?1:c,u=i.interpolate,y=void 0===u?"ease":u,d=i.origin,p=void 0===d?{x:.5,y:.5}:d,v=i.useLayout,f=void 0!==v&&v,g=t(i,h),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.useLayout=f,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation="spring"===y?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":y,this.origin=this.originToStyle(p),this.repeat=l}var d;return s(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===a(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,o=function(o){var s=o in n?n[o]:e.initials[o];Array.isArray(t[o])||(t[o]=[t[o]]),t[o]=t[o].length>1?t[o]:[s].concat(r(t[o])),t[o]=t[o].map((function(e){return i.sanitize(o,e)})),a=t[o].length>a?t[o].length:a};for(var s in t)o(s);return new Array(a).fill(0).map((function(n,r){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],r,a));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return u(i);if(i.match(/^rgba?\(.*\)$/i))return y(i);var o=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(o)?e.initials[t]:("%"===s&&(o/=100),s?[o,s]:o)}if("object"===a(i)){var c=Object.keys(i);("x"in i||"y"in i)&&(c=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(c=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(c=["left","right","top","bottom"]),c.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),o=Math.floor(r),s=e[o];if(o===e.length-1)return s;var c=e[o+1];if("object"===a(s)){var l={};return Object.keys(s).forEach((function(e){l[e]=n.interpolate(s[e],c[e],r-o)})),l}return this.interpolate(s,c,r-o)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var r=n(e,2),a=r[0],o=r[1];switch(a){case"position":i.transform+="translate(".concat(t.toString(o.x,"px"),", ").concat(t.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),t.useLayout){i.width=t.toLength(o.x),i.height=t.toLength(o.y);break}i.transform+="scale(".concat(t.toString(o.x,"%"),", ").concat(t.toString(o.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(o),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(o.top,"%")," ").concat(t.toString(o.right,"%")," ").concat(t.toString(o.bottom,"%")," ").concat(t.toString(o.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[a]=t.toString(o,"px");break;case"backgroundColor":case"color":i[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":i.pointerEvents=o?"all":"none";break;case"opacity":case"active":i[a]=o}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t;e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=(null===(t=e.Lively)||void 0===t?void 0:t.keyframe)||this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),c=t[i],l=t.padding?1:o/(0===s?1e-6:s);"string"==typeof c&&(c="calc(".concat(c," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(c," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var y="calc(min(calc(".concat(a," * ").concat(c,"), ").concat(u,") * ");e.style[n]=y+.5*l,e.style[r]=y+1/l*.5}},{key:"apply",value:(d=i(c.mark((function e(t,i){var r,a,o=this,s=arguments;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],!("active"in i)){e.next=11;break}if("start"!==(a=Object.keys(i.active)[0])&&!r){e.next=10;break}if(t.style.display=i.active[a]?"":"none",r){e.next=8;break}return e.next=8,l.sleep(.001);case 8:e.next=11;break;case 10:l.delay((function(){t.style.display=i.active[a]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var r=n(e,2),a=r[0],s=r[1];return"width"===a?o.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===a?o.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===a||"padding"===a&&(i.width||i.height)||(t.style[a]=s))})),t.Lively.keyframe=i;case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return d.apply(this,arguments)})},{key:"start",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.immediate,r=void 0!==n&&n,a=i.reverse,o=void 0!==a&&a,s=i.repeat,c=void 0===s?this.repeat:s;!e.Lively.animating||r?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.index=1,null!==(t=e.Lively.next)&&void 0!==t&&t.cancel&&e.Lively.next.cancel(),this.getNext(e,o,c)):e.Lively.queue.push([this,{reverse:o,repeat:c}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,c=void 0!==s&&s;e.style&&(this.delay||r?e.next=l.delay((function(){return t.start(e,{immediate:o,reverse:c})}),this.delay+r):this.start(e,{immediate:o,reverse:c}),e.Lively.animating=!0)}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=n(a,2),s=o[0],c=o[1];return s?s.start(e,c):void(r>1&&this.start(e,{reverse:i,repeat:r-1}))}var u=e.Lively.index;i&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){t.apply(e,t.keyframes[u])})),e.Lively.index++,e.Lively.next=l.delay((function(){return t.getNext(e,i,r)}),this.delta)}}]),e}();e(g,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var b=["direction"];function m(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function k(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?m(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function w(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return w.use=w.use.bind(w,e),w}function L(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function x(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?L(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O.use=O.use.bind(O,e),O}w.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.direction,n=void 0===i?"up":i,r=t(e,b),a="0px",o="20px";switch(n){case"down":o="-20px";break;case"left":a="20px",o="0px";break;case"right":a="-20px",o="0px"}return new g(k({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:a,y:o},opacity:0})},O.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new g(x({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{g as A,w as M,O as P,d as a,l as b,f as c,p as r,v as s};