@infinityfx/lively 0.0.4 → 0.0.7
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 +40 -3
- package/dist/cjs/animations.js +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/pop-3b6d66e5.js +1 -0
- package/dist/esm/animations.js +1 -1
- package/dist/esm/hooks.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/pop-443325e9.js +1 -0
- package/package.json +1 -1
- package/dist/cjs/pop-b7e362c3.js +0 -1
- package/dist/esm/pop-262b0878.js +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
# Lively
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@infinityfx/lively)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
Lightweight, zero-configuration react animation library.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## Table of contents
|
|
12
|
+
- [Get started](#get-started)
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Usage](#usage)
|
|
15
|
+
- [Components](#components)
|
|
16
|
+
|
|
17
|
+
## Get started
|
|
18
|
+
|
|
19
|
+
### Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
$ npm i @infinityfx/lively
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Usage
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import { Animate } from '@infinityfx/lively';
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
<Animate onMount>
|
|
33
|
+
<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.
|
|
35
|
+
</div>
|
|
36
|
+
</Animate>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Components
|
|
40
|
+
- Animatable
|
|
41
|
+
- Animate
|
|
42
|
+
- Morph
|
|
43
|
+
|
|
44
|
+
More documentation coming soon!
|
package/dist/cjs/animations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-3b6d66e5.js"),t=require("@babel/runtime/helpers/objectWithoutProperties");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/regenerator");var o=n(e),i=n(t);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(u({opacity:1,duration:.65},e),{opacity:0})};var p=["direction"];function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=i.default(e,p),c=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":c=1,u=0,a={x:0,y:1};break;case"down":c=1,u=0,a={x:0,y:0}}return new r.Animation(l({scale:{x:1},origin:a,duration:.6},o),{scale:{x:c,y:u}})};var f=["direction"];function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return d.use=d.use.bind(d,e),d}d.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,c=i.default(e,f);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(y({clip:o.default({},n,0)},c),{clip:o.default({},n,1)})},exports.Move=r.Move,exports.Pop=r.Pop,exports.Fade=a,exports.Scale=b,exports.Wipe=d;
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(e);exports.useUnmount=function(e){var t=r.useState(e),n=u.default(t,2),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(e);exports.useUnmount=function(e){var t=r.useState(e),n=u.default(t,2),o=n[0],a=n[1],c=r.useRef();return r.useEffect((function(){var r;e&&a(!0),!e&&null!==(r=c.current)&&void 0!==r&&r.props.onUnmount&&c.current.play(c.current.props.onUnmount,{reverse:!0,immediate:!0,callback:function(){a(!1)}})}),[e]),[o,c]};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),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-b7e362c3.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),d=require("@babel/runtime/helpers/get");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/toConsumableArray");var y=v(e),m=v(t),b=v(r),g=v(n),w=v(i),k=v(o),E=v(a),O=v(s),x=v(l),A=v(u),P=v(p),j=v(h),C=v(f),L=v(d);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 D(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){x.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 R(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var M=function(e){k.default(h,e);var t,r,n,i,o,a,s,l,u=R(h);function h(e){var t;for(var r in g.default(this,h),(t=u.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return w.default(h,[{key:"toAnimation",value:function(e){return!e||"object"!==b.default(e)&&"function"!=typeof e?null:"use"in e?e.use():new c.Animation(D({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){e.type===h&&(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:function(){var e=this;this.elements.forEach((function(t){var r;null===(r=e.animations.default)||void 0===r||r.setInitial(t,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{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=y.default(A.default.mark((function e(){var t,r,n,i;return A.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:"onEnter",value:(s=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"onLeave",value:(a=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onFocus",value:(o=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"onBlur",value:(i=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onClick",value:(n=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setInitial",value:(r=y.default(A.default.mark((function e(t){var r,n,i=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=y.default(A.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 A.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:"style",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=D(D({},e),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return t}},{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=D(D({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===b.default(e[n])&&"object"===b.default(t[n])&&(r[n]=D(D({},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,f={};e.type===h||e.type.prototype instanceof h||(s&&(f={style:this.style(null===(c=e.props)||void 0===c?void 0:c.style),ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(f=D(D({},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)}}),u=!1));!(e.type===h||e.type.prototype instanceof h)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(f=D(D(D({},f),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 d=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return Object.values(f).length?p.cloneElement(e,f,d):e}},{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})}))}}]),h}(p.Component);x.default(M,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var q=["levels","animations"];function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){x.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var B=function(e){k.default(r,e);var t=F(r);function r(e){var n;return g.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 w.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,q),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),P.default.createElement(M,j.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,V({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(p.Component);function H(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return U(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 U(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 U(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){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}x.default(B,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var G=function(e){k.default(r,e);var t=T(r);function r(e){var n;return g.default(this,r),(n=t.call(this,e)).id=n.props.parentGroup+n.props.group,n}return w.default(r,[{key:"componentDidMount",value:function(){var e=this;this.element=this.elements[0],this.element&&(c.Animation.setInitial(this.element),this.animations.transition=this.createResetAnimation(),this.element.setAttribute("uitools-morph-id",this.id),this.element.setAttribute("uitools-morph-active",this.props.active),c.AnimationQueue.delay((function(){for(var t=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),r=0;r<t.length;r++)t[r]!==e.element&&(e.animations[r]=e.createMorphAnimation(t[r]));e.props.active||e.props.parentGroup.length||e.setInitial("transition")}),.001))}},{key:"componentDidUpdate",value:function(){var e=this;"true"===this.element.getAttribute("uitools-morph-active")!==this.props.active&&(this.element.setAttribute("uitools-morph-active",this.props.active),c.AnimationQueue.delay((function(){if(e.props.active)e.play("transition");else{for(var t=0,r=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),n=0;n<r.length;n++)if(r[n]!==e.element&&"true"===r[n].getAttribute("uitools-morph-active")){t=n;break}e.play(t.toString())}}),.001))}},{key:"getParentPosition",value:function(e){var t,r=this.props.useLayout?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return(null==r?void 0:r.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,i=null===(r=e.UITools)||void 0===r?void 0:r.initialStyles,o=i.x-n.x,a=i.y-n.y;if(this.props.parentGroup.length){var s=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-s.x,a-=l.y-s.y}return this.props.useLayout||(o+=(i.clientWidth-n.clientWidth)/2,a+=(i.clientHeight-n.clientHeight)/2),[{x:0,y:0},{x:o,y:a},{x:o,y:a}]}},{key:"scaleKeyframes",value:function(e,t){var r=t.clientWidth/e.clientWidth,n=t.clientHeight/e.clientHeight;return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createMorphAnimation",value:function(e){var t,n,i,o=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,a=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles,s={useLayout:this.props.useLayout},l=H(r.properties);try{for(l.s();!(i=l.n()).done;){var u=i.value;if(!this.props.ignore.includes(u))switch(u){case"position":s[u]=this.positionKeyframes(e);break;case"scale":s[u]=this.scaleKeyframes(o,a);break;case"opacity":s[u]=[1,1,0];break;default:s[u]=[o[u],a[u],a[u]]}}}catch(e){l.e(e)}finally{l.f()}return new c.Animation(s)}},{key:"createResetAnimation",value:function(){var e,t,n=null===(e=this.element.UITools)||void 0===e?void 0:e.initialStyles,i={useLayout:this.props.useLayout},o=H(r.properties);try{for(o.s();!(t=o.n()).done;){var a=t.value;if(!this.props.ignore.includes(a))switch(a){case"position":i[a]={x:0,y:0};break;case"scale":i[a]={x:1,y:1};break;case"opacity":i[a]=[0,0,1];break;default:i[a]=[n[a],n[a],n[a]]}}}catch(e){o.e(e)}finally{o.f()}return new c.Animation(i)}},{key:"parentStyle",value:function(){return{position:"relative",background:"transparent",border:"none",pointerEvents:"none"}}},{key:"childStyle",value:function(){return{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"}}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var n=e.type!==r?{}:{parentGroup:t.props.parentGroup+t.props.group};return p.cloneElement(e,n,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 n=this.getChildren(t.props.children),i=this.props.useLayout?{style:this.childStyle()}:{},o=L.default(O.default(r.prototype),"render",this).call(this,p.cloneElement(t,i,n));return this.props.useLayout?p.cloneElement(t,{style:this.parentStyle()},o):o}}]),r}(M);x.default(G,"properties",["position","scale","opacity","backgroundColor","color","borderRadius"]),x.default(G,"defaultProps",{group:0,parentGroup:"",active:!1,useLayout:!1,ignore:[]}),exports.Animatable=M,exports.Animate=B,exports.Morph=G;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/typeof"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/defineProperty"),u=require("@babel/runtime/regenerator"),p=require("react"),c=require("./pop-3b6d66e5.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),v=require("@babel/runtime/helpers/toConsumableArray"),d=require("@babel/runtime/helpers/get");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=y(e),b=y(t),g=y(r),w=y(n),k=y(i),O=y(o),E=y(a),x=y(s),L=y(l),j=y(u),P=y(p),A=y(h),C=y(f),S=y(v),D=y(d);function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?M(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var I=function(e){O.default(v,e);var t,r,n,i,o,a,s,l,u,h,f=q(v);function v(e){var t;for(var r in w.default(this,v),(t=f.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return k.default(v,[{key:"toAnimation",value:function(e){return!e||"object"!==g.default(e)&&"function"!=typeof e?null:"use"in e?e.use():new c.Animation(R({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){e.type===v&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(h=b.default(j.default.mark((function e(){var t=this;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.elements.forEach((function(e){var r;null===(r=t.animations.default)||void 0===r||r.setInitial(e,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll()),this.resizeEventListener=this.onResize.bind(this),c.addEventListener("resize",this.resizeEventListener);case 4:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),c.removeEventListener("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;return this.elements.forEach((function(n){var i=n.getBoundingClientRect().y;t=t&&i+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,r=r&&i>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),i=m.default(n,2),o=i[0],a=i[1];t=t&&o,r=r&&a})),[t,r]}},{key:"onScroll",value:(u=b.default(j.default.mark((function e(){var t,r,n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),r=m.default(t,2),n=r[0],i=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&i&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"onResize",value:(l=b.default(j.default.mark((function e(){return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return l.apply(this,arguments)})},{key:"onEnter",value:(s=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"onLeave",value:(a=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onFocus",value:(o=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"onBlur",value:(i=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onClick",value:(n=b.default(j.default.mark((function e(t){var r,n=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setInitial",value:(r=b.default(j.default.mark((function e(t){var r,n,i=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=b.default(j.default.mark((function e(t){var r,n,i,o,a,s,l,u,p,h,f,v,d,y,m,b,g=this,w=arguments;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=w.length>1&&void 0!==w[1]?w[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,l=r.cascade,u=void 0!==l&&l,p=r.groupAdjust,h=void 0===p?0:p,f=r.cascadeDelay,v=void 0===f?0:f,d=r.staggerDelay,y=void 0===d?0:d,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in g.props?g.props.parentLevel-g.props.group:g.level+h;v=o?m.duration:v;var n=o?r*v:(g.props.parentLevel-r)*v;n=g.props.stagger*t+n+y,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:s})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:i<0?0:g.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&c.AnimationQueue.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=R(R({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===g.default(e[n])&&"object"===g.default(t[n])&&(r[n]=R(R({},t[n]),e[n]));return r}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,a=n.useElements,s=void 0!==a&&a,l=n.useEvents,u=void 0!==l&&l;if(!p.isValidElement(e))return e;var c={};e.type===v||e.type.prototype instanceof v||(s&&(c={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(c=R(R({},c),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===v||e.type.prototype instanceof v)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(c=R(R(R({},c),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:s?o:-1}}}));var h=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return p.cloneElement(e,c,h)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,p.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),v}(p.Component);L.default(I,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var V=["levels","animations"];function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var z=function(e){O.default(r,e);var t=H(r);function r(e){var n;return w.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=new Array(n.levels).fill(0).map((function(e,t){return t<n.props.animations.length?n.props.animations[t]:n.props.animations[n.props.animations.length-1]})),n}return k.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||p.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=C.default(n,V),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),P.default.createElement(I,A.default({animate:o},i),p.Children.map(e,(function(e){return p.isValidElement(e)?p.cloneElement(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,B({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(p.Component);function G(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?G(Object(r),!0).forEach((function(t){L.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function K(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return T(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var i=x.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}L.default(z,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var W=function(e){O.default(i,e);var t,r,n=N(i);function i(e){var t;return w.default(this,i),(t=n.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useContainer:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none"}},t}return k.default(i,[{key:"setUniqueId",value:function(){if(!this.props.parentGroup.length){"Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++,this.element.setAttribute("lively-morph-id",this.id);var e,t=K(this.children);try{for(t.s();!(e=t.n()).done;){var r=e.value.animatable;r&&(r.id=this.id),null==r||r.element.setAttribute("lively-morph-id",this.id)}}catch(e){t.e(e)}finally{t.f()}}}},{key:"reset",value:function(){this.element=this.elements[0],this.layoutOffset=this.props.useLayout&&this.state.useContainer,this.setUniqueId(),c.cacheElementStyles(this.element),this.animations={},this.animations.default=this.createUnmorphAnimation(),this.props.active||this.props.parentGroup.length||this.setInitial()}},{key:"componentDidMount",value:(r=b.default(j.default.mark((function e(){var t,r;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.element=this.elements[0],this.element){e.next=3;break}return e.abrupt("return");case 3:this.props.useLayout&&(t=getComputedStyle(this.element),"absolute"===(r=t.position)||"fixed"===r?this.setState({childStyles:{top:this.element.offsetTop,left:this.element.offsetLeft}}):this.setState({childStyles:{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},parentStyles:U({width:this.element.offsetWidth,height:this.element.offsetHeight},this.state.parentStyles),useContainer:!0})),this.reset();case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"componentDidUpdate",value:(t=b.default(j.default.mark((function e(t,r){var n,i;return j.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.useContainer!==this.state.useContainer&&this.reset(),t.active!==this.props.active){e.next=3;break}return e.abrupt("return");case 3:return this.props.active&&this.element.setAttribute("lively-morph-target",!0),e.next=6,c.AnimationQueue.sleep(.001);case 6:this.props.active?this.play("default"):(n=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(n.removeAttribute("lively-morph-target"),(i=n.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));t&&(this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)})))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,a=i.y-n.y;if(this.props.parentGroup.length){var s=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-s.x,a-=l.y-s.y}return[{x:0,y:0},{x:o,y:a},{x:o,y:a}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,a=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=i.properties;this.props.useLayout&&s.push.apply(s,S.default(i.layoutProperties));var l,u={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0}},p=K(s);try{for(p.s();!(l=p.n()).done;){var h=l.value;this.props.ignore.includes(h)||(u[h]=h in n?n[h]:a?[o[h],a[h],a[h]]:[o[h],o[h],o[h]])}}catch(e){p.e(e)}finally{p.f()}return new c.Animation(u)}},{key:"createMorphAnimation",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var r=e.type!==i?{}:{parentGroup:t.props.parentGroup+t.props.group};return p.cloneElement(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!p.isValidElement(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:U(U({},t.props.style),this.state.childStyles)},o=D.default(x.default(i.prototype),"render",this).call(this,p.cloneElement(t,n,r));return this.state.useContainer?p.cloneElement(t,{style:this.state.parentStyles},o):o}}]),i}(I);L.default(W,"properties",["position","scale","opacity","backgroundColor","color","interact"]),L.default(W,"layoutProperties",["borderRadius","fontSize"]),L.default(W,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",ignore:[]}),exports.Animatable=I,exports.Animate=z,exports.Morph=W;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/toConsumableArray"),a=require("@babel/runtime/helpers/typeof"),o=require("@babel/runtime/helpers/classCallCheck"),s=require("@babel/runtime/helpers/createClass"),l=require("@babel/runtime/regenerator");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(e),d=c(t),f=c(i),p=c(n),y=c(r),v=c(a),h=c(o),g=c(s),b=c(l),m=function(){function e(){h.default(this,e),this.queue=[],this.tick()}var t,i;return g.default(e,[{key:"tick",value:(i=f.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:(t=f.default(b.default.mark((function e(t,i){return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),k=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},w=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},x=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,l=t.borderRadius,c=t.padding,u=t.fontSize,d=e.getBoundingClientRect(),f=d.x,p=d.y;e.Lively.initials={x:f,y:p,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:l.split(" ")[0],padding:c.split(" ")[0]}},L=["delay","duration","repeat","interpolate","origin","useLayout"],O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.delay,n=void 0===i?0:i,r=t.duration,a=void 0===r?1:r,o=t.repeat,s=void 0===o?1:o,l=t.interpolate,c=void 0===l?"ease":l,u=t.origin,f=void 0===u?{x:.5,y:.5}:u,p=t.useLayout,y=void 0!==p&&p,v=d.default(t,L),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h.default(this,e),this.useLayout=y,this.keyframes=this.getKeyframes(v,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation="spring"===c?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":c,this.origin=this.originToStyle(f),this.repeat=s}var t;return g.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===v.default(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(y.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],a,r));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return k(i);if(i.match(/^rgba?\(.*\)$/i))return w(i);var a=parseFloat(i),o=i.match(/[^0-9\.]*$/i);return isNaN(a)?e.initials[t]:("%"===o&&(a/=100),o?[a,o]:a)}if("object"===v.default(i)){var s=Object.keys(i);("x"in i||"y"in i)&&(s=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(s=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(s=["left","right","top","bottom"]),s.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),a=Math.floor(r),o=e[a];if(a===e.length-1)return o;var s=e[a+1];if("object"===v.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=p.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[r]=t.toString(a,"px");break;case"backgroundColor":case"color":i[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"interact":i.pointerEvents=a?"all":"none";break;case"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&x(e),e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),l=t[i],c=t.padding?1:o/s;"string"==typeof l&&(l="calc(".concat(l," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(l," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var d="calc(min(calc(".concat(a," * ").concat(l,"), ").concat(u,") * ");e.style[n]=d+.5*c,e.style[r]=d+1/c*.5}},{key:"apply",value:(t=f.default(b.default.mark((function e(t,i){var n,r,a=this,o=arguments;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],!("active"in i)){e.next=11;break}if("start"!==(r=Object.keys(i.active)[0])&&!n){e.next=10;break}if(t.style.display=i.active[r]?"":"none",n){e.next=8;break}return e.next=8,m.sleep(.001);case 8:e.next=11;break;case 10:m.delay((function(){t.style.display=i.active[r]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var n=p.default(e,2),r=n[0],o=n[1];return"width"===r?a.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===r?a.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===r||"padding"===r&&(i.width||i.height)||(t.style[r]=o))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.Lively.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.animating=!0,e.Lively.index=1,this.getNext(e,a,s)):e.Lively.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?m.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var r=e.Lively.queue.shift()||[],a=p.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.Lively.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.Lively.index++,m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}]),e}();u.default(O,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var j=["direction"];function S(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function q(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?S(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E.use=E.use.bind(E,e),E}function P(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function A(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?P(Object(i),!0).forEach((function(t){u.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):P(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return D.use=D.use.bind(D,e),D}E.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,i=void 0===t?"up":t,n=d.default(e,j),r="0px",a="20px";switch(i){case"down":a="-20px";break;case"left":r="20px",a="0px";break;case"right":r="-20px",a="0px"}return new O(q({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},D.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new O(A({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=O,exports.AnimationQueue=m,exports.Move=E,exports.Pop=D,exports.addEventListener=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},exports.cacheElementStyles=x,exports.removeEventListener=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]};
|
package/dist/esm/animations.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-443325e9.js";export{M as Move,P as Pop}from"./pop-443325e9.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.use=i.use.bind(i,e),i}i.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(o({opacity:1,duration:.65},e),{opacity:0})};var c=["direction"];function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u.use=u.use.bind(u,e),u}u.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,u=1,b={x:0,y:.5};switch(o){case"left":b.x=1;break;case"up":p=1,u=0,b={x:0,y:1};break;case"down":p=1,u=0,b={x:0,y:0}}return new r(s({scale:{x:1},origin:b,duration:.6},i),{scale:{x:p,y:u}})};var b=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O.use=O.use.bind(O,e),O}O.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,b);return["left","right","top","bottom"].includes(i)||(i="right"),new r(l({clip:e({},i,0)},c),{clip:e({},i,1)})};export{i as Fade,u as Scale,O as Wipe};
|
package/dist/esm/hooks.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"@babel/runtime/helpers/slicedToArray";import{useState as
|
|
1
|
+
import r from"@babel/runtime/helpers/slicedToArray";import{useState as n,useRef as e,useEffect as o}from"react";function t(t){var u=n(t),c=r(u,2),i=c[0],a=c[1],m=e();return o((function(){var r;t&&a(!0),!t&&null!==(r=m.current)&&void 0!==r&&r.props.onUnmount&&m.current.play(m.current.props.onUnmount,{reverse:!0,immediate:!0,callback:function(){a(!1)}})}),[t]),[i,m]}export{t as useUnmount};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{A as y,a as d,r as m,b,M as g,P as w}from"./pop-262b0878.js";import k from"@babel/runtime/helpers/extends";import O from"@babel/runtime/helpers/objectWithoutProperties";import x from"@babel/runtime/helpers/get";import"@babel/runtime/helpers/toConsumableArray";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 j(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 A(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 E=function(s){o(E,v);var a,l,p,g,w,k,O,x,P=A(E);function E(e){var t;for(var r in n(this,E),(t=P.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return i(E,[{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():new y(j({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){e.type===E&&(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:function(){var e=this;this.elements.forEach((function(t){var r;null===(r=e.animations.default)||void 0===r||r.setInitial(t,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),d("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){m("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{key:"inViewport",value:function(){var e=this,r=!0,n=!0;return this.elements.forEach((function(t){var i=t.getBoundingClientRect().y;r=r&&i+t.clientHeight*(1-e.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+t.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var i=e.animatable.inViewport(),o=t(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(x=e(u.mark((function e(){var r,n,i,o;return u.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(),r=this.inViewport(),n=t(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 e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=e(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=e(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=e(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:(g=e(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 g.apply(this,arguments)})},{key:"onClick",value:(p=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setInitial",value:(l=e(u.mark((function e(t){var r,n,i=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=e(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,y,d,m,g,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,y=r.staggerDelay,d=void 0===y?0:y,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:g=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+d,g=n>g?n:g,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&b.delay(n,g+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"style",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=j(j({},e),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return t}},{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=j(j({},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]=j(j({},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,v={};e.type===E||e.type.prototype instanceof E||(a&&(v={style:this.style(null===(p=e.props)||void 0===p?void 0:p.style),ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(v=j(j({},v),{},{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===E||e.type.prototype instanceof E)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(v=j(j(j({},v),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 y=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return Object.values(v).length?f(e,v,y):e}},{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})}))}}]),E}();l(E,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var L=["levels","animations"];function C(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(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(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 R=function(e){o(r,v);var t=D(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=O(n,L),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(E,k({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,S({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function I(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,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 M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function F(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(R,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[g,w]});var V=function(e){o(r,E);var t=F(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).id=i.props.parentGroup+i.props.group,i}return i(r,[{key:"componentDidMount",value:function(){var e=this;this.element=this.elements[0],this.element&&(y.setInitial(this.element),this.animations.transition=this.createResetAnimation(),this.element.setAttribute("uitools-morph-id",this.id),this.element.setAttribute("uitools-morph-active",this.props.active),b.delay((function(){for(var t=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),r=0;r<t.length;r++)t[r]!==e.element&&(e.animations[r]=e.createMorphAnimation(t[r]));e.props.active||e.props.parentGroup.length||e.setInitial("transition")}),.001))}},{key:"componentDidUpdate",value:function(){var e=this;"true"===this.element.getAttribute("uitools-morph-active")!==this.props.active&&(this.element.setAttribute("uitools-morph-active",this.props.active),b.delay((function(){if(e.props.active)e.play("transition");else{for(var t=0,r=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),n=0;n<r.length;n++)if(r[n]!==e.element&&"true"===r[n].getAttribute("uitools-morph-active")){t=n;break}e.play(t.toString())}}),.001))}},{key:"getParentPosition",value:function(e){var t,r=this.props.useLayout?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return(null==r?void 0:r.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,i=null===(r=e.UITools)||void 0===r?void 0:r.initialStyles,o=i.x-n.x,s=i.y-n.y;if(this.props.parentGroup.length){var a=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-a.x,s-=l.y-a.y}return this.props.useLayout||(o+=(i.clientWidth-n.clientWidth)/2,s+=(i.clientHeight-n.clientHeight)/2),[{x:0,y:0},{x:o,y:s},{x:o,y:s}]}},{key:"scaleKeyframes",value:function(e,t){var r=t.clientWidth/e.clientWidth,n=t.clientHeight/e.clientHeight;return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createMorphAnimation",value:function(e){var t,n,i,o=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,s=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles,a={useLayout:this.props.useLayout},l=I(r.properties);try{for(l.s();!(i=l.n()).done;){var u=i.value;if(!this.props.ignore.includes(u))switch(u){case"position":a[u]=this.positionKeyframes(e);break;case"scale":a[u]=this.scaleKeyframes(o,s);break;case"opacity":a[u]=[1,1,0];break;default:a[u]=[o[u],s[u],s[u]]}}}catch(e){l.e(e)}finally{l.f()}return new y(a)}},{key:"createResetAnimation",value:function(){var e,t,n=null===(e=this.element.UITools)||void 0===e?void 0:e.initialStyles,i={useLayout:this.props.useLayout},o=I(r.properties);try{for(o.s();!(t=o.n()).done;){var s=t.value;if(!this.props.ignore.includes(s))switch(s){case"position":i[s]={x:0,y:0};break;case"scale":i[s]={x:1,y:1};break;case"opacity":i[s]=[0,0,1];break;default:i[s]=[n[s],n[s],n[s]]}}}catch(e){o.e(e)}finally{o.f()}return new y(i)}},{key:"parentStyle",value:function(){return{position:"relative",background:"transparent",border:"none",pointerEvents:"none"}}},{key:"childStyle",value:function(){return{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"}}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var n=e.type!==r?{}:{parentGroup:t.props.parentGroup+t.props.group};return f(e,n,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 n=this.getChildren(t.props.children),i=this.props.useLayout?{style:this.childStyle()}:{},o=x(a(r.prototype),"render",this).call(this,f(t,i,n));return this.props.useLayout?f(t,{style:this.parentStyle()},o):o}}]),r}();l(V,"properties",["position","scale","opacity","backgroundColor","color","borderRadius"]),l(V,"defaultProps",{group:0,parentGroup:"",active:!1,useLayout:!1,ignore:[]});export{E as Animatable,R as Animate,V as Morph};
|
|
1
|
+
import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{A as y,a as d,r as m,b as g,M as b,P as w,c as k}from"./pop-443325e9.js";import O from"@babel/runtime/helpers/extends";import x from"@babel/runtime/helpers/objectWithoutProperties";import P from"@babel/runtime/helpers/toConsumableArray";import j from"@babel/runtime/helpers/get";function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var C=function(s){o(C,v);var a,l,p,b,w,k,O,x,P,j,L=E(C);function C(e){var t;for(var r in n(this,C),(t=L.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return i(C,[{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():new y(A({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){e.type===C&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:(j=t(u.mark((function e(){var t=this;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.elements.forEach((function(e){var r;null===(r=t.animations.default)||void 0===r||r.setInitial(e,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),d("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll()),this.resizeEventListener=this.onResize.bind(this),d("resize",this.resizeEventListener);case 4:case"end":return e.stop()}}),e,this)}))),function(){return j.apply(this,arguments)})},{key:"componentWillUnmount",value:function(){m("scroll",this.scrollEventListener),m("resize",this.resizeEventListener)}},{key:"inViewport",value:function(){var t=this,r=!0,n=!0;return this.elements.forEach((function(e){var i=e.getBoundingClientRect().y;r=r&&i+e.clientHeight*(1-t.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+e.clientHeight*t.viewportMargin})),this.elements.length||this.children.forEach((function(t){var i=t.animatable.inViewport(),o=e(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(P=t(u.mark((function t(){var r,n,i,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(Date.now()-this.scrollDelta<350)){t.next=2;break}return t.abrupt("return");case 2:this.scrollDelta=Date.now(),r=this.inViewport(),n=e(r,2),i=n[0],o=n[1],!this.inView&&i&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return P.apply(this,arguments)})},{key:"onResize",value:(x=t(u.mark((function e(){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"onLeave",value:(k=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"onFocus",value:(w=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"onBlur",value:(b=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"onClick",value:(p=t(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setInitial",value:(l=t(u.mark((function e(t){var r,n,i=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=t(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,y,d,m,b,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,y=r.staggerDelay,d=void 0===y?0:y,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+d,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&g.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=A(A({},t),e);for(var i in n)["children","parentLevel","ref"].includes(i)?delete n[i]:Array.isArray(e[i])||Array.isArray(t[i])||"object"===r(e[i])&&"object"===r(t[i])&&(n[i]=A(A({},t[i]),e[i]));return n}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,s=n.useElements,a=void 0!==s&&s,l=n.useEvents,u=void 0!==l&&l;if(!h(e))return e;var p={};e.type===C||e.type.prototype instanceof C||(a&&(p={ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(p=A(A({},p),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1)),!(e.type===C||e.type.prototype instanceof C)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(p=A(A(A({},p),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:a?o:-1}}}));var v=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return f(e,p,v)}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,c.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),C}();l(C,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var S=["levels","animations"];function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var I=function(e){o(r,v);var t=R(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return i(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||c.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=x(n,S),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(C,O({animate:o},i),c.map(e,(function(e){return h(e)?f(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,M({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return H(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return H(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}l(I,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[b,w]});var G=function(e){o(p,C);var r,s,l=z(p);function p(e){var t;return n(this,p),(t=l.call(this,e)).layoutOffset=!1,t.group=t.props.parentGroup+t.props.group,t.state={useContainer:!1,childStyles:{},parentStyles:{position:"relative",background:"transparent",border:"none",pointerEvents:"none",backdropFilter:"none"}},t}return i(p,[{key:"setUniqueId",value:function(){if(!this.props.parentGroup.length){"Lively"in window||(window.Lively={}),"Morph"in window.Lively||(window.Lively.Morph={}),this.group in window.Lively.Morph||(window.Lively.Morph[this.group]=0),this.id=window.Lively.Morph[this.group]++,this.element.setAttribute("lively-morph-id",this.id);var e,t=B(this.children);try{for(t.s();!(e=t.n()).done;){var r=e.value.animatable;r&&(r.id=this.id),null==r||r.element.setAttribute("lively-morph-id",this.id)}}catch(e){t.e(e)}finally{t.f()}}}},{key:"reset",value:function(){this.element=this.elements[0],this.layoutOffset=this.props.useLayout&&this.state.useContainer,this.setUniqueId(),k(this.element),this.animations={},this.animations.default=this.createUnmorphAnimation(),this.props.active||this.props.parentGroup.length||this.setInitial()}},{key:"componentDidMount",value:(s=t(u.mark((function e(){var t,r;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.element=this.elements[0],this.element){e.next=3;break}return e.abrupt("return");case 3:this.props.useLayout&&(t=getComputedStyle(this.element),"absolute"===(r=t.position)||"fixed"===r?this.setState({childStyles:{top:this.element.offsetTop,left:this.element.offsetLeft}}):this.setState({childStyles:{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"},parentStyles:V({width:this.element.offsetWidth,height:this.element.offsetHeight},this.state.parentStyles),useContainer:!0})),this.reset();case 5:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"componentDidUpdate",value:(r=t(u.mark((function e(t,r){var n,i;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.useContainer!==this.state.useContainer&&this.reset(),t.active!==this.props.active){e.next=3;break}return e.abrupt("return");case 3:return this.props.active&&this.element.setAttribute("lively-morph-target",!0),e.next=6,g.sleep(.001);case 6:this.props.active?this.play("default"):(n=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-target="true"]')))&&(n.removeAttribute("lively-morph-target"),(i=n.getAttribute("lively-morph-id"))in this.animations||this.createAnimations(i),this.play(i));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"createAnimations",value:function(e){var t=document.querySelector('[lively-morph-group="'.concat(this.group,'"][lively-morph-id="').concat(e,'"]'));t&&(this.animations[e]=this.createMorphAnimation(t),this.children.forEach((function(t){var r=t.animatable;return null==r?void 0:r.createAnimations(e)})))}},{key:"getParentPosition",value:function(e){var t,r,n,i=this.layoutOffset?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return"true"===i.getAttribute("lively-morph-layout")&&(i=null===(r=i)||void 0===r?void 0:r.parentElement),(null===(n=i)||void 0===n?void 0:n.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials,o=i.x-n.x,s=i.y-n.y;if(this.props.parentGroup.length){var a=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-a.x,s-=l.y-a.y}return[{x:0,y:0},{x:o,y:s},{x:o,y:s}]}},{key:"scaleKeyframes",value:function(e,t){var r=parseInt(t.width)/parseInt(e.width),n=parseInt(t.height)/parseInt(e.height);return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createAnimation",value:function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,o=null==e||null===(r=e.Lively)||void 0===r?void 0:r.initials,s=p.properties;this.props.useLayout&&s.push.apply(s,P(p.layoutProperties));var a,l={useLayout:this.props.useLayout,interpolate:this.props.interpolate,origin:{x:0,y:0}},u=B(s);try{for(u.s();!(a=u.n()).done;){var c=a.value;this.props.ignore.includes(c)||(l[c]=c in n?n[c]:o?[i[c],o[c],o[c]]:[i[c],i[c],i[c]])}}catch(e){u.e(e)}finally{u.f()}return new y(l)}},{key:"createMorphAnimation",value:function(e){var t,r,n=null===(t=this.element.Lively)||void 0===t?void 0:t.initials,i=null===(r=e.Lively)||void 0===r?void 0:r.initials;return this.createAnimation(e,{position:this.positionKeyframes(e),scale:this.scaleKeyframes(n,i),opacity:[1,1,0],interact:[!0,!0,!1]})}},{key:"createUnmorphAnimation",value:function(){return this.createAnimation(null,{position:{x:0,y:0},scale:{x:1,y:1},opacity:[0,0,1],interact:[!1,!1,!0]})}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var r=e.type!==p?{}:{parentGroup:t.props.parentGroup+t.props.group};return f(e,r,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!h(t))return t;var r=this.getChildren(t.props.children),n={"lively-morph-group":this.group,"lively-morph-layout":this.layoutOffset.toString(),style:V(V({},t.props.style),this.state.childStyles)},i=j(a(p.prototype),"render",this).call(this,f(t,n,r));return this.state.useContainer?f(t,{style:this.state.parentStyles},i):i}}]),p}();l(G,"properties",["position","scale","opacity","backgroundColor","color","interact"]),l(G,"layoutProperties",["borderRadius","fontSize"]),l(G,"defaultProps",{id:null,group:0,parentGroup:"",active:!1,useLayout:!1,interpolate:"ease",ignore:[]});export{C as Animatable,I as Animate,G as Morph};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/toConsumableArray";import a from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import s from"@babel/runtime/helpers/createClass";import c from"@babel/runtime/regenerator";var l=function(){function e(){o(this,e),this.queue=[],this.tick()}var t,n;return s(e,[{key:"tick",value:(n=i(c.mark((function e(){var t,i;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"Lively"in window||(window.Lively={}),"AnimationLoop"in window.Lively||(window.Lively.AnimationQueue=new e),window.Lively.AnimationQueue}},{key:"delay",value:(t=i(c.mark((function e(t,i){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),u=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(a.padStart(2,a),16),b:parseInt(o.padStart(2,o),16),a:void 0!==s?parseInt(s,16):255}},p=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=n(t,5);i[0];var r=i[1],a=i[2],o=i[3],s=i[4];return{r:parseInt(r),g:parseInt(a),b:parseInt(o),a:void 0!==s?parseInt(s):255}},y=function(e,t){var i;if(t instanceof Function){null!==(i=window.Lively)&&void 0!==i&&i.Events||(window.Lively={Events:{}}),e in window.Lively.Events||(window.Lively.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.Lively.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))})));var n=window.Lively.Events[e];t.Lively={ListenerID:n.unique},n[n.unique++]=t}},d=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.Lively)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.Lively)&&void 0!==r&&r.ListenerID&&delete window.Lively.Events[e][t.Lively.ListenerID]},f=function(e){"Lively"in e||(e.Lively={queue:[],initials:{}}),e.Lively.style||(e.Lively.style=function(e){for(var t={},i=0;i<e.style.length;i++)t[e.style[i]]=e.style[e.style[i]];return t}(e),e.Lively.style.transitionProperty="transform, opacity, clip-path, border-radius, font-size, background-color, color, width, height, padding",e.Lively.style.willChange="transform"),e.style={},function(e,t){for(var i in t)e.style[i]=t[i]}(e,e.Lively.style);var t=getComputedStyle(e),i=t.paddingLeft,n=t.paddingRight,r=t.paddingTop,a=t.paddingBottom,o=t.backgroundColor,s=t.color,c=t.borderRadius,l=t.padding,u=t.fontSize,p=e.getBoundingClientRect(),y=p.x,d=p.y;e.Lively.initials={x:y,y:d,paddingLeft:i,paddingRight:n,paddingTop:r,paddingBottom:a,backgroundColor:o,color:s,fontSize:u,width:e.offsetWidth+"px",height:e.offsetHeight+"px",borderRadius:c.split(" ")[0],padding:l.split(" ")[0]}},v=["delay","duration","repeat","interpolate","origin","useLayout"],h=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.delay,r=void 0===n?0:n,a=i.duration,s=void 0===a?1:a,c=i.repeat,l=void 0===c?1:c,u=i.interpolate,p=void 0===u?"ease":u,y=i.origin,d=void 0===y?{x:.5,y:.5}:y,f=i.useLayout,h=void 0!==f&&f,g=t(i,v),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.useLayout=h,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation="spring"===p?"cubic-bezier(0.65, 0.34, 0.7, 1.42)":p,this.origin=this.originToStyle(d),this.repeat=l}var y;return s(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===a(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,o=function(o){var s=o in n?n[o]:e.initials[o];Array.isArray(t[o])||(t[o]=[t[o]]),t[o]=t[o].length>1?t[o]:[s].concat(r(t[o])),t[o]=t[o].map((function(e){return i.sanitize(o,e)})),a=t[o].length>a?t[o].length:a};for(var s in t)o(s);return new Array(a).fill(0).map((function(n,r){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],r,a));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return u(i);if(i.match(/^rgba?\(.*\)$/i))return p(i);var o=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(o)?e.initials[t]:("%"===s&&(o/=100),s?[o,s]:o)}if("object"===a(i)){var c=Object.keys(i);("x"in i||"y"in i)&&(c=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(c=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(c=["left","right","top","bottom"]),c.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("number"!=typeof e||"number"!=typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),o=Math.floor(r),s=e[o];if(o===e.length-1)return s;var c=e[o+1];if("object"===a(s)){var l={};return Object.keys(s).forEach((function(e){l[e]=n.interpolate(s[e],c[e],r-o)})),l}return this.interpolate(s,c,r-o)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var r=n(e,2),a=r[0],o=r[1];switch(a){case"position":i.transform+="translate(".concat(t.toString(o.x,"px"),", ").concat(t.toString(o.y,"px"),") ");break;case"scale":if("number"==typeof o&&(o={x:o,y:o}),t.useLayout){i.width=t.toLength(o.x),i.height=t.toLength(o.y);break}i.transform+="scale(".concat(t.toString(o.x,"%"),", ").concat(t.toString(o.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(o),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(o.top,"%")," ").concat(t.toString(o.right,"%")," ").concat(t.toString(o.bottom,"%")," ").concat(t.toString(o.left,"%"),")");break;case"borderRadius":case"padding":case"fontSize":i[a]=t.toString(o,"px");break;case"backgroundColor":case"color":i[a]="rgba(".concat(o.r,", ").concat(o.g,", ").concat(o.b,", ").concat(o.a,")");break;case"interact":i.pointerEvents=o?"all":"none";break;case"opacity":case"active":i[a]=o}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&f(e),e.style.transitionDuration="0s",e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin;var i=this.keyframes[0];this.apply(e,i,!0)}},{key:"setLength",value:function(e,t,i,n,r){var a=e.Lively.initials[i],o=parseInt(e.Lively.initials[n]),s=parseInt(e.Lively.initials[r]),c=t[i],l=t.padding?1:o/s;"string"==typeof c&&(c="calc(".concat(c," / ").concat(a,")"));var u=t.padding?t.padding:o+s+"px";e.style[i]="max(calc(".concat(a," * ").concat(c," - ").concat("border-box"!==e.style.boxSizing?"0px":u,"), 0px)");var p="calc(min(calc(".concat(a," * ").concat(c,"), ").concat(u,") * ");e.style[n]=p+.5*l,e.style[r]=p+1/l*.5}},{key:"apply",value:(y=i(c.mark((function e(t,i){var r,a,o=this,s=arguments;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],!("active"in i)){e.next=11;break}if("start"!==(a=Object.keys(i.active)[0])&&!r){e.next=10;break}if(t.style.display=i.active[a]?"":"none",r){e.next=8;break}return e.next=8,l.sleep(.001);case 8:e.next=11;break;case 10:l.delay((function(){t.style.display=i.active[a]?"":"none"}),this.delta);case 11:Object.entries(i).forEach((function(e){var r=n(e,2),a=r[0],s=r[1];return"width"===a?o.setLength(t,i,"width","paddingLeft","paddingRight"):"height"===a?o.setLength(t,i,"height","paddingTop","paddingBottom"):void("active"===a||"padding"===a&&(i.width||i.height)||(t.style[a]=s))}));case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return y.apply(this,arguments)})},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.Lively.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.Lively.animating=!0,e.Lively.index=1,this.getNext(e,a,s)):e.Lively.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,c=void 0!==s&&s;e.style&&(this.delay||r?l.delay((function(){return t.start(e,{immediate:o,reverse:c})}),this.delay+r):this.start(e,{immediate:o,reverse:c}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.Lively.index===this.keyframes.length){e.Lively.animating=!1;var a=e.Lively.queue.shift()||[],o=n(a,2),s=o[0],c=o[1];return s?s.start(e,c):void(r>1&&this.start(e,{reverse:i,repeat:r-1}))}var u=e.Lively.index;i&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){t.apply(e,t.keyframes[u])})),e.Lively.index++,l.delay((function(){return t.getNext(e,i,r)}),this.delta)}}]),e}();e(h,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,padding:0,fontSize:"1em",backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255},active:{start:!0},interact:!0});var g=["direction"];function b(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function m(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?b(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function k(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return k.use=k.use.bind(k,e),k}function w(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function x(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){e(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L.use=L.use.bind(L,e),L}k.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.direction,n=void 0===i?"up":i,r=t(e,g),a="0px",o="20px";switch(n){case"down":o="-20px";break;case"left":a="20px",o="0px";break;case"right":a="-20px",o="0px"}return new h(m({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:a,y:o},opacity:0})},L.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new h(x({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})};export{h as A,k as M,L as P,y as a,l as b,f as c,d as r};
|
package/package.json
CHANGED
package/dist/cjs/pop-b7e362c3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/typeof"),a=require("@babel/runtime/helpers/classCallCheck"),o=require("@babel/runtime/helpers/createClass"),s=require("@babel/runtime/helpers/asyncToGenerator"),l=require("@babel/runtime/regenerator");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),d=u(t),p=u(i),f=u(n),h=u(r),v=u(a),y=u(o),g=u(s),b=u(l),m=function(){function e(){v.default(this,e),this.queue=[],this.tick()}var t,i;return y.default(e,[{key:"tick",value:(i=g.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new e),window.UITools.AnimationQueue}},{key:"delay",value:(t=g.default(b.default.mark((function e(t,i){return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),w=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},k=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},I=["delay","duration","repeat","interpolate","origin","useLayout"],x=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,p=void 0===c?{x:.5,y:.5}:c,f=t.useLayout,h=void 0!==f&&f,y=d.default(t,I),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v.default(this,e),this.useLayout=h,this.keyframes=this.getKeyframes(y,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation=u,this.origin=this.originToStyle(p),this.repeat=s}return y.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===h.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(f.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 w(i);if(i.match(/^rgba?\(.*\)$/i))return k(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"===h.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("string"==typeof e||"string"==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"===h.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=p.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":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"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i&&e.setInitial(t),t.style.transitionDuration="0s";var n=this.keyframes[0];this.apply(t,n,!0)}},{key:"test",value:function(e,t,i,n,r,a){var o=n+r+((i-=t-(e="string"==typeof e?parseInt(e)/t:e)*t)<0?i:0),s=n/(n+r);return{size:(i<0?0:i)+"px",padStart:(n=a?e*n:o*s)+"px",padEnd:(r=a?e*r:o*(1-s))+"px"}}},{key:"apply",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=function(){var n=e.UITools.initialStyles;Object.entries(t).forEach((function(t){var r=p.default(t,2),a=r[0],o=r[1];if("width"===a){var s=n.clientWidth,l=n.width,u=n.paddingLeft,c=n.paddingRight,d=n.includePadding,f=i.test(o,s,l,u,c,d),h=f.size,v=f.padStart,y=f.padEnd;return e.style.width=h,e.style.paddingLeft=v,void(e.style.paddingRight=y)}if("height"===a){var g=n.clientHeight,b=n.height,m=n.paddingTop,w=n.paddingBottom,k=n.includePadding,I=i.test(o,g,b,m,w,k),x=I.size,T=I.padStart,O=I.padEnd;return e.style.height=x,e.style.paddingTop=T,void(e.style.paddingBottom=O)}"active"!==a&&(e.style[a]=o)}))};if("active"in t){var a=Object.keys(t.active)[0];"start"===a||n?(e.style.display=t.active[a]?"":"none",n?r():m.delay(r,.01)):(m.delay((function(){e.style.display=t.active[a]?"":"none"}),this.delta),r())}else r()}},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.UITools.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin,e.UITools.animating=!0,e.UITools.index=1,this.getNext(e,a,s)):e.UITools.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?m.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.UITools.index===this.keyframes.length){e.UITools.animating=!1;var r=e.UITools.queue.shift()||[],a=p.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.UITools.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.UITools.index++,m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}],[{key:"setInitial",value:function(e){var t=getComputedStyle(e),i=t.width,n=t.height,r=t.paddingLeft,a=t.paddingRight,o=t.paddingTop,s=t.paddingBottom,l=t.borderRadius,u=t.boxSizing,c=t.backgroundColor,d=t.color,p=e.getBoundingClientRect(),f=p.x,h=p.y;"UITools"in e||(e.UITools={}),"queue"in e.UITools||(e.UITools.queue=[]),"initialStyles"in e.UITools||(e.UITools.initialStyles={x:f,y:h,includePadding:"border-box"===u,clientWidth:e.clientWidth,clientHeight:e.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(r),paddingRight:parseInt(a),paddingTop:parseInt(o),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:c,color:d})}}]),e}();c.default(x,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}});var T=["direction"];function O(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 U(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){c.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j.use=j.use.bind(j,e),j}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){c.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}j.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,T),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 x(U({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},E.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new x(q({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=x,exports.AnimationQueue=m,exports.Move=j,exports.Pop=E,exports.addEventListener=function(e,t){var i;t instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),e in window.UITools.Events||(window.UITools.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.UITools.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))}))),t.UITools={ListenerID:window.UITools.Events[e].unique},window.UITools.Events[e][window.UITools.Events[e].unique]=t,window.UITools.Events[e].unique++)},exports.removeEventListener=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.UITools)&&void 0!==r&&r.ListenerID&&delete window.UITools.Events[e][t.UITools.ListenerID]};
|
package/dist/esm/pop-262b0878.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/slicedToArray";import n from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import a from"@babel/runtime/helpers/createClass";import s from"@babel/runtime/helpers/asyncToGenerator";import l from"@babel/runtime/regenerator";var c=function(){function t(){o(this,t),this.queue=[],this.tick()}var e,i;return a(t,[{key:"tick",value:(i=s(l.mark((function t(){var e,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){t.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>e)){t.next=6;break}return this.queue.splice(0,i),t.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,t.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,r=this.queue.length-1;n<=r;)if(e=n+r>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;r=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"delay",value:function(t,e){t instanceof Function&&this.insert({callback:t,timestamp:Date.now()+1e3*e})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new t),window.UITools.AnimationQueue}},{key:"delay",value:(e=s(l.mark((function t(e,i){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.get().delay(e,i));case 1:case"end":return t.stop()}}),t,this)}))),function(t,i){return e.apply(this,arguments)})},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),t}(),u=function(t){var e=t.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=i(e,5);n[0];var r=n[1],o=n[2],a=n[3],s=n[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(o.padStart(2,o),16),b:parseInt(a.padStart(2,a),16),a:void 0!==s?parseInt(s,16):255}},d=function(t){var e=t.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=i(e,5);n[0];var r=n[1],o=n[2],a=n[3],s=n[4];return{r:parseInt(r),g:parseInt(o),b:parseInt(a),a:void 0!==s?parseInt(s):255}},p=function(t,e){var i;e instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),t in window.UITools.Events||(window.UITools.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.UITools.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))}))),e.UITools={ListenerID:window.UITools.Events[t].unique},window.UITools.Events[t][window.UITools.Events[t].unique]=e,window.UITools.Events[t].unique++)},f=function(t,e){var i,n,r;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&null!==(r=e.UITools)&&void 0!==r&&r.ListenerID&&delete window.UITools.Events[t][e.UITools.ListenerID]},h=["delay","duration","repeat","interpolate","origin","useLayout"],y=function(){function t(){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,l=i.repeat,c=void 0===l?1:l,u=i.interpolate,d=void 0===u?"ease":u,p=i.origin,f=void 0===p?{x:.5,y:.5}:p,y=i.useLayout,v=void 0!==y&&y,g=e(i,h),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,t),this.useLayout=v,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation=d,this.origin=this.originToStyle(f),this.repeat=c}return a(t,[{key:"originToStyle",value:function(t){var e=.5,i=.5;if("object"===r(t))e=t.x,i=t.y;else if("string"==typeof t)switch(t){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}else e=i=t;return"".concat(100*e,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(e){var i=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=0,a=function(a){var s=a in r?r[a]:t.initials[a];Array.isArray(e[a])||(e[a]=[e[a]]),e[a]=e[a].length>1?e[a]:[s].concat(n(e[a])),e[a]=e[a].map((function(t){return i.sanitize(a,t)})),o=e[a].length>o?e[a].length:o};for(var s in e)a(s);return new Array(o).fill(0).map((function(n,r){var a={};for(var s in e)s in t.initials&&(a[s]=i.interpolateKeyframe(e[s],r,o));return i.keyframeToStyle(a)}))}},{key:"sanitize",value:function(e,i){var n=this,o=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 d(i);var a=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(a)?t.initials[e]:("%"===s&&(a/=100),s?[a,s]:a)}if("object"===r(i)){var l=Object.keys(i);("x"in i||"y"in i)&&(l=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(l=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(l=["left","right","top","bottom"]),l.forEach((function(t){i[t]=n.sanitize(e,i[t],t)}))}return void 0!==i?i:o?t.initials[e][o]:t.initials[e]}},{key:"interpolate",value:function(t,e,i){if("string"==typeof t||"string"==typeof e)return i>.5?e:t;var n=!1;Array.isArray(t)&&(n=t[1],t=t[0]),Array.isArray(e)&&(n=e[1],e=e[0]);var r=t*(1-i)+e*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(t,e,i){var n=this;if(t.length===i)return t[e];var o=e*((t.length-1)/(i-1)),a=Math.floor(o),s=t[a];if(a===t.length-1)return s;var l=t[a+1];if("object"===r(s)){var c={};return Object.keys(s).forEach((function(t){c[t]=n.interpolate(s[t],l[t],o-a)})),c}return this.interpolate(s,l,o-a)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(t){var e=this,n={transform:""};return Object.entries(t).forEach((function(t){var r=i(t,2),o=r[0],a=r[1];switch(o){case"position":n.transform+="translate(".concat(e.toString(a.x,"px"),", ").concat(e.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),e.useLayout){n.width=e.toLength(a.x),n.height=e.toLength(a.y);break}n.transform+="scale(".concat(e.toString(a.x,"%"),", ").concat(e.toString(a.y,"%"),") ");break;case"rotation":n.transform+="rotate(".concat((e.toString(a),"deg"),") ");break;case"clip":n.clipPath="inset(".concat(e.toString(a.top,"%")," ").concat(e.toString(a.right,"%")," ").concat(e.toString(a.bottom,"%")," ").concat(e.toString(a.left,"%"),")");break;case"borderRadius":n[o]=e.toString(a,"px");break;case"backgroundColor":case"color":n[o]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"opacity":case"active":n[o]=a}})),n.transform.length||delete n.transform,n}},{key:"setInitial",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i&&t.setInitial(e),e.style.transitionDuration="0s";var n=this.keyframes[0];this.apply(e,n,!0)}},{key:"test",value:function(t,e,i,n,r,o){var a=n+r+((i-=e-(t="string"==typeof t?parseInt(t)/e:t)*e)<0?i:0),s=n/(n+r);return{size:(i<0?0:i)+"px",padStart:(n=o?t*n:a*s)+"px",padEnd:(r=o?t*r:a*(1-s))+"px"}}},{key:"apply",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=function(){var r=t.UITools.initialStyles;Object.entries(e).forEach((function(e){var o=i(e,2),a=o[0],s=o[1];if("width"===a){var l=r.clientWidth,c=r.width,u=r.paddingLeft,d=r.paddingRight,p=r.includePadding,f=n.test(s,l,c,u,d,p),h=f.size,y=f.padStart,v=f.padEnd;return t.style.width=h,t.style.paddingLeft=y,void(t.style.paddingRight=v)}if("height"===a){var g=r.clientHeight,b=r.height,m=r.paddingTop,w=r.paddingBottom,k=r.includePadding,I=n.test(s,g,b,m,w,k),x=I.size,T=I.padStart,O=I.padEnd;return t.style.height=x,t.style.paddingTop=T,void(t.style.paddingBottom=O)}"active"!==a&&(t.style[a]=s)}))};if("active"in e){var a=Object.keys(e.active)[0];"start"===a||r?(t.style.display=e.active[a]?"":"none",r?o():c.delay(o,.01)):(c.delay((function(){t.style.display=e.active[a]?"":"none"}),this.delta),o())}else o()}},{key:"start",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.immediate,n=void 0!==i&&i,r=e.reverse,o=void 0!==r&&r,a=e.repeat,s=void 0===a?this.repeat:a;!t.UITools.animating||n?(this.setInitial(t),t.style.transitionDuration="".concat(this.delta,"s"),t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,t.UITools.animating=!0,t.UITools.index=1,this.getNext(t,o,s)):t.UITools.queue.push([this,{reverse:o,repeat:s}])}},{key:"play",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,o=i.immediate,a=void 0!==o&&o,s=i.reverse,l=void 0!==s&&s;t.style&&(this.delay||r?c.delay((function(){return e.start(t,{immediate:a,reverse:l})}),this.delay+r):this.start(t,{immediate:a,reverse:l}))}},{key:"getNext",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(t.UITools.index===this.keyframes.length){t.UITools.animating=!1;var o=t.UITools.queue.shift()||[],a=i(o,2),s=a[0],l=a[1];return s?s.start(t,l):void(r>1&&this.start(t,{reverse:n,repeat:r-1}))}var u=t.UITools.index;n&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){e.apply(t,e.keyframes[u])})),t.UITools.index++,c.delay((function(){return e.getNext(t,n,r)}),this.delta)}}],[{key:"setInitial",value:function(t){var e=getComputedStyle(t),i=e.width,n=e.height,r=e.paddingLeft,o=e.paddingRight,a=e.paddingTop,s=e.paddingBottom,l=e.borderRadius,c=e.boxSizing,u=e.backgroundColor,d=e.color,p=t.getBoundingClientRect(),f=p.x,h=p.y;"UITools"in t||(t.UITools={}),"queue"in t.UITools||(t.UITools.queue=[]),"initialStyles"in t.UITools||(t.UITools.initialStyles={x:f,y:h,includePadding:"border-box"===c,clientWidth:t.clientWidth,clientHeight:t.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(r),paddingRight:parseInt(o),paddingTop:parseInt(a),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:u,color:d})}}]),t}();t(y,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}});var v=["direction"];function g(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function b(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?g(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return m.use=m.use.bind(m,t),m}function w(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function k(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return I.use=I.use.bind(I,t),I}m.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.direction,n=void 0===i?"up":i,r=e(t,v),o="0px",a="20px";switch(n){case"down":a="-20px";break;case"left":o="20px",a="0px";break;case"right":o="-20px",a="0px"}return new y(b({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:o,y:a},opacity:0})},I.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new y(k({opacity:1,scale:1,duration:.25},t),{opacity:0,scale:.85})};export{y as A,m as M,I as P,p as a,c as b,f as r};
|