react-ui-animate
Version:
React library for gestures and animation
3 lines (2 loc) • 22.9 kB
JavaScript
var t=require("@raidipesh78/re-motion"),e=require("react"),n=require("react/jsx-runtime"),o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){return r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};function s(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function u(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}function c(t,e){return void 0===t&&(t={}),e?t:(t.onStart,t.onChange,t.onComplete,s(t,["onStart","onChange","onComplete"]))}function l(t){return"object"==typeof t&&null!==t&&"type"in t&&"string"==typeof t.type}function f(e,n){var o,i,r,s,a,u,c=n.type,l=n.to,v=n.options,p=void 0===v?{}:v;switch(c){case"spring":return t.spring(e,l,p);case"timing":return t.timing(e,l,p);case"decay":return t.decay(e,null!==(o=p.velocity)&&void 0!==o?o:0,p);case"delay":return t.delay(null!==(i=p.delay)&&void 0!==i?i:0);case"sequence":var d=(null!==(r=p.animations)&&void 0!==r?r:[]).map((function(t){return f(e,t)}));return t.sequence(d,p);case"loop":var h=p.animation;if(!h)return console.warn("[buildAnimation] loop missing `animation` descriptor"),{start:function(){},pause:function(){},resume:function(){},cancel:function(){},reset:function(){}};var m="sequence"===h.type?t.sequence((null!==(a=null===(s=h.options)||void 0===s?void 0:s.animations)&&void 0!==a?a:[]).map((function(t){return f(e,t)})),h.options):f(e,h);return t.loop(m,null!==(u=p.iterations)&&void 0!==u?u:0,p);default:return console.warn("Unsupported animation type: ".concat(c)),{start:function(){},pause:function(){},resume:function(){},cancel:function(){},reset:function(){}}}}function v(e,n){var o=Object.entries(e).filter((function(t){var e=a(t,1)[0];return"decay"===n.type||"delay"===n.type||void 0!==n.to[e]})).map((function(t,e){var o=a(t,2),i=o[0];return f(o[1],{type:n.type,to:"decay"===n.type||"delay"===n.type?n.to:n.to[i],options:c(n.options,0===e)})}));return t.parallel(o)}function p(n){var o=e.useRef(null),i=e.useMemo((function(){return Array.isArray(n)?n.map((function(e){return new t.MotionValue(e)})):"object"==typeof n?Object.fromEntries(Object.entries(n).map((function(e){var n=a(e,2),o=n[0],i=n[1];return[o,new t.MotionValue(i)]}))):new t.MotionValue(n)}),[]);return[i,function(e){var s=null;s=Array.isArray(n)?function(e,n){var o,i;if(!l(n))return n.forEach((function(t,n){var o;null===(o=e[n])||void 0===o||o.set(t)})),null;var s=n,a=Object.fromEntries(e.map((function(t,e){return[e.toString(),t]})));switch(s.type){case"sequence":var u=s.options.animations.map((function(e){var n,o;return"delay"===e.type?t.delay(null!==(o=null===(n=e.options)||void 0===n?void 0:n.delay)&&void 0!==o?o:0):v(a,r(r({},e),{to:Array.isArray(e.to)?Object.fromEntries(e.to.map((function(t,e){return[e.toString(),t]}))):e.to}))}));return t.sequence(u,s.options);case"loop":var f=s.options.animation;if("sequence"===f.type){var p=f.options.animations.map((function(t){return v(a,r(r({},t),{to:Array.isArray(t.to)?Object.fromEntries(t.to.map((function(t,e){return[e.toString(),t]}))):t.to}))})),d=t.sequence(p,c(f.options,!0));return t.loop(d,null!==(o=s.options.iterations)&&void 0!==o?o:0,c(s.options,!0))}var h=v(a,f);return t.loop(h,null!==(i=s.options.iterations)&&void 0!==i?i:0,c(s.options,!0));default:return v(a,s)}}(i,e):"object"==typeof n?function(e,n){var o,i;if(l(n))switch(n.type){case"sequence":var r=n.options.animations.map((function(n){var o;return"delay"===n.type?t.delay(null!==(o=n.options.delay)&&void 0!==o?o:0):v(e,n)}));return t.sequence(r,n.options);case"loop":var s=n.options.animation;if("sequence"===s.type){r=s.options.animations.map((function(t){return v(e,t)}));return t.loop(t.sequence(r,c(s.options,!0)),null!==(o=n.options.iterations)&&void 0!==o?o:0,c(n.options,!0))}return t.loop(v(e,s),null!==(i=n.options.iterations)&&void 0!==i?i:0,c(n.options,!0));default:return v(e,n)}return Object.entries(n).forEach((function(t){var n,o=a(t,2),i=o[0],r=o[1];null===(n=e[i])||void 0===n||n.set(r)})),null}(i,e):function(e,n){var o,i,r,s,a,u,c,l,v;if("number"==typeof n||"string"==typeof n)return e.set(n),null;if("sequence"===n.type){var p=(null!==(i=null===(o=n.options)||void 0===o?void 0:o.animations)&&void 0!==i?i:[]).map((function(t){return f(e,t)}));return t.sequence(p,n.options)}if("loop"===n.type){var d=null===(r=n.options)||void 0===r?void 0:r.animation;if(!d)return null;if("sequence"===d.type){p=(null!==(a=null===(s=d.options)||void 0===s?void 0:s.animations)&&void 0!==a?a:[]).map((function(t){return f(e,t)}));return t.loop(t.sequence(p),null!==(c=null===(u=n.options)||void 0===u?void 0:u.iterations)&&void 0!==c?c:0,n.options)}return t.loop(f(e,d),null!==(v=null===(l=n.options)||void 0===l?void 0:l.iterations)&&void 0!==v?v:0,n.options)}return f(e,n)}(i,e),o.current=s,s&&s.start()},{start:function(){var t;return null===(t=o.current)||void 0===t?void 0:t.start()},pause:function(){var t;return null===(t=o.current)||void 0===t?void 0:t.pause()},resume:function(){var t;return null===(t=o.current)||void 0===t?void 0:t.resume()},cancel:function(){var t;return null===(t=o.current)||void 0===t?void 0:t.cancel()},reset:function(){var t;return null===(t=o.current)||void 0===t?void 0:t.reset()}}]}"function"==typeof SuppressedError&&SuppressedError;var d={Timing:{BOUNCE:{duration:500,easing:t.Easing.bounce},EASE_IN:{duration:500,easing:t.Easing.in(t.Easing.ease)},EASE_OUT:{duration:500,easing:t.Easing.out(t.Easing.ease)},EASE_IN_OUT:{duration:500,easing:t.Easing.inOut(t.Easing.ease)},POWER1:{duration:500,easing:t.Easing.bezier(.17,.42,.51,.97)},POWER2:{duration:500,easing:t.Easing.bezier(.07,.11,.13,1)},POWER3:{duration:500,easing:t.Easing.bezier(.09,.7,.16,1.04)},POWER4:{duration:500,easing:t.Easing.bezier(.05,.54,0,1.03)},LINEAR:{duration:500,easing:t.Easing.linear}},Spring:{ELASTIC:{mass:1,damping:18,stiffness:250},EASE:{mass:1,damping:20,stiffness:158},STIFF:{mass:1,damping:18,stiffness:350},WOBBLE:{mass:1,damping:8,stiffness:250}}},h=function(t,e){var n,o,i;return{type:"spring",to:t,options:{stiffness:null!==(n=null==e?void 0:e.stiffness)&&void 0!==n?n:d.Spring.EASE.stiffness,damping:null!==(o=null==e?void 0:e.damping)&&void 0!==o?o:d.Spring.EASE.damping,mass:null!==(i=null==e?void 0:e.mass)&&void 0!==i?i:d.Spring.EASE.mass,onStart:null==e?void 0:e.onStart,onChange:null==e?void 0:e.onChange,onComplete:null==e?void 0:e.onComplete}}};function m(t,n){void 0===n&&(n={});var o=n,i=o.from,s=void 0===i?0:i,u=o.enter,c=void 0===u?1:u,f=o.exit,v=void 0===f?0:f,d=a(e.useState(t),2),m=d[0],y=d[1],E=e.useRef(!0),g=a(p(s),2),w=g[0],x=g[1],T=e.useMemo((function(){return l(c)?c:h(c)}),[c]),L=e.useMemo((function(){return l(v)?r(r({},v),{options:r(r({},v.options),{onComplete:function(){var t,e;null===(e=null===(t=v.options)||void 0===t?void 0:t.onComplete)||void 0===e||e.call(t),y(!1)}})}):h(v,{onComplete:function(){return y(!1)}})}),[v]);return e.useEffect((function(){if(E.current)return E.current=!1,void(t&&(y(!0),queueMicrotask((function(){return x(T)}))));t?(y(!0),queueMicrotask((function(){return x(T)}))):queueMicrotask((function(){return x(L)}))}),[t]),function(t){return t(w,m)}}function y(t,e,n){return Math.min(Math.max(t,e),n)}function E(t,e,n){return 0===e||Math.abs(e)===1/0?function(t,e){return Math.pow(t,5*e)}(t,n):t*e*n/(e+n*t)}var g=function(){function t(){this.changeListeners=new Set,this.endListeners=new Set}return t.prototype.onChange=function(t){return this.changeListeners.add(t),this},t.prototype.onEnd=function(t){return this.endListeners.add(t),this},t.prototype.emitChange=function(t){this.changeListeners.forEach((function(e){return e(t)}))},t.prototype.emitEnd=function(t){this.endListeners.forEach((function(e){return e(t)}))},t.VELOCITY_LIMIT=20,t}(),w=function(t){function e(e){void 0===e&&(e={});var n=t.call(this)||this;return n.prev={x:0,y:0},n.lastTime=0,n.movement={x:0,y:0},n.velocity={x:0,y:0},n.start={x:0,y:0},n.offset={x:0,y:0},n.pointerCaptured=!1,n.activePointerId=null,n.attachedEls=new Set,n.activeEl=null,n.pointerDownPos={x:0,y:0},n.thresholdPassed=!1,n.config=e,n}return i(e,t),e.prototype.attach=function(t){var e=this;if(t===window)return function(){};var n=Array.isArray(t)?t:[t],o=this.onDown.bind(this),i=this.onMove.bind(this),r=this.onUp.bind(this);return n.forEach((function(t){e.attachedEls.add(t),t.addEventListener("pointerdown",o,{passive:!1})})),window.addEventListener("pointermove",i,{passive:!1}),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r),function(){n.forEach((function(t){t.removeEventListener("pointerdown",o),e.attachedEls.delete(t)})),window.removeEventListener("pointermove",i),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r)}},e.prototype.onDown=function(t){var e,n,o;if(0===t.button){var i=t.currentTarget;this.attachedEls.has(i)&&(this.activeEl=i,this.activePointerId=t.pointerId,this.pointerCaptured=!1,this.start=!1===this.thresholdPassed&&0===this.start.x&&0===this.start.y?null!==(o=null===(n=(e=this.config).initial)||void 0===n?void 0:n.call(e))&&void 0!==o?o:{x:0,y:0}:r({},this.offset),this.offset=r({},this.start),this.movement={x:0,y:0},this.velocity={x:0,y:0},this.pointerDownPos={x:t.clientX,y:t.clientY},this.thresholdPassed=!1,this.prev={x:t.clientX,y:t.clientY},this.lastTime=t.timeStamp,this.emitChange({down:!0,movement:{x:0,y:0},offset:r({},this.offset),velocity:{x:0,y:0},event:t,cancel:this.cancel.bind(this)}))}},e.prototype.onMove=function(t){var e;if(this.activePointerId===t.pointerId&&this.activeEl){var n=null!==(e=this.config.threshold)&&void 0!==e?e:0;if(!this.thresholdPassed){var o=t.clientX-this.pointerDownPos.x,i=t.clientY-this.pointerDownPos.y;if(Math.hypot(o,i)<n)return;this.thresholdPassed=!0,this.activeEl.setPointerCapture(t.pointerId),this.pointerCaptured=!0}this.pointerCaptured&&t.preventDefault();var s=Math.max((t.timeStamp-this.lastTime)/1e3,1e-6);this.lastTime=t.timeStamp;var a=(t.clientX-this.prev.x)/s/1e3,u=(t.clientY-this.prev.y)/s/1e3;this.velocity={x:y(a,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT),y:y(u,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT)};var c={x:t.clientX-this.pointerDownPos.x,y:t.clientY-this.pointerDownPos.y};this.movement={x:"y"===this.config.axis?0:c.x,y:"x"===this.config.axis?0:c.y},this.offset={x:this.start.x+this.movement.x,y:this.start.y+this.movement.y},this.prev={x:t.clientX,y:t.clientY},this.emitChange({down:!0,movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:this.cancel.bind(this)})}},e.prototype.onUp=function(t){this.activePointerId===t.pointerId&&this.activeEl&&(this.activeEl.releasePointerCapture(t.pointerId),this.emitEnd({down:!1,movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:this.cancel.bind(this)}),this.activePointerId=null,this.pointerCaptured=!1)},e.prototype.cancel=function(){this.activeEl&&null!==this.activePointerId&&(this.activeEl.releasePointerCapture(this.activePointerId),this.activePointerId=null,this.activeEl=null)},e}(g);function x(t,n,o,i){var s=T(o),a=T(i);if(n!==window){var u=Array.isArray(n)?n:[n],c=e.useRef([]);c.current.length!==u.length&&(c.current=u.map((function(e,n){var o=new t(a.current),i=function(t){return s.current(r(r({},t),{index:n}))};return o.onChange(i).onEnd(i),o}))),e.useEffect((function(){var t=u.map((function(t,e){var n=t.current;return n?c.current[e].attach(n):null})).filter((function(t){return!!t}));return function(){return t.forEach((function(t){return t()}))}}),[u.map((function(t){return t.current}))])}else{var l=e.useRef();if(!l.current){var f=new t(a.current),v=function(t){return s.current(r(r({},t),{index:0}))};f.onChange(v).onEnd(v),l.current=f}e.useEffect((function(){var t=l.current.attach(window);return function(){t()}}),[n])}}function T(t){var n=e.useRef(t);return e.useEffect((function(){n.current=t}),[t]),n}var L=function(t){function e(){var e=t.apply(this,u([],a(arguments),!1))||this;return e.attachedEls=new Set,e.prev={x:0,y:0},e.lastTime=0,e.movement={x:0,y:0},e.offset={x:0,y:0},e.velocity={x:0,y:0},e.startPos=null,e}return i(e,t),e.prototype.attach=function(t){var e=this,n=Array.isArray(t)?t:[t],o=this.onMove.bind(this),i=this.onLeave.bind(this);return n.forEach((function(t){e.attachedEls.add(t),t.addEventListener("pointermove",o,{passive:!1}),t.addEventListener("pointerleave",i)})),function(){n.forEach((function(t){t.removeEventListener("pointermove",o),t.removeEventListener("pointerleave",i),e.attachedEls.delete(t)}))}},e.prototype.cancel=function(){},e.prototype.onMove=function(t){var e=this,n=t.timeStamp;null===this.startPos&&(this.startPos={x:t.clientX,y:t.clientY},this.prev={x:t.clientX,y:t.clientY},this.lastTime=n);var o=Math.max((n-this.lastTime)/1e3,1e-6);this.lastTime=n;var i=t.clientX-this.prev.x,s=t.clientY-this.prev.y;this.prev={x:t.clientX,y:t.clientY},this.movement={x:t.clientX-this.startPos.x,y:t.clientY-this.startPos.y};var a=t.currentTarget,u=a instanceof HTMLElement?a.getBoundingClientRect():{left:0,top:0};this.offset={x:t.clientX-u.left,y:t.clientY-u.top};var c=i/o/1e3,l=s/o/1e3;this.velocity={x:y(c,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT),y:y(l,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT)},this.emitChange({movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:function(){return e.onLeave(t)}})},e.prototype.onLeave=function(t){this.emitEnd({movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:function(){}})},e}(g);var I=function(t){function e(){var e=t.apply(this,u([],a(arguments),!1))||this;return e.attachedEls=new Set,e.movement={x:0,y:0},e.offset={x:0,y:0},e.velocity={x:0,y:0},e.prevScroll={x:0,y:0},e.lastTime=0,e}return i(e,t),e.prototype.attach=function(t){var e=this,n=Array.isArray(t)?t:[t],o=this.onScroll.bind(this);return n.forEach((function(t){e.attachedEls.add(t),t.addEventListener("scroll",o,{passive:!0})})),function(){n.forEach((function(t){t.removeEventListener("scroll",o),e.attachedEls.delete(t)})),null!=e.endTimeout&&(clearTimeout(e.endTimeout),e.endTimeout=void 0)}},e.prototype.cancel=function(){},e.prototype.onScroll=function(t){var e=this,n=Date.now(),o=Math.max((n-this.lastTime)/1e3,1e-6);this.lastTime=n;var i=t.currentTarget,s=i instanceof HTMLElement?i.scrollLeft:window.scrollX,a=i instanceof HTMLElement?i.scrollTop:window.scrollY,u=s-this.prevScroll.x,c=a-this.prevScroll.y;this.prevScroll={x:s,y:a},this.movement={x:u,y:c},this.offset={x:s,y:a};var l=u/o/1e3,f=c/o/1e3;this.velocity={x:y(l,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT),y:y(f,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT)},this.emitChange({movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:function(){null!=e.endTimeout&&clearTimeout(e.endTimeout)}}),null!=this.endTimeout&&clearTimeout(this.endTimeout),this.endTimeout=window.setTimeout((function(){e.emitEnd({movement:r({},e.movement),offset:r({},e.offset),velocity:r({},e.velocity),event:t,cancel:function(){}})}),150)},e}(g);function C(t,n){var o=void 0===n?{}:n,i=o.target,r=o.axis,s=void 0===r?"y":r,u=o.offset,c=void 0===u?["start start","end end"]:u,l=o.animate,f=void 0===l||l,v=o.toDescriptor,d=void 0===v?function(t){return h(t)}:v,m=a(p(0),2),y=m[0],E=m[1],g=a(p(0),2),w=g[0],T=g[1],L=e.useRef([0,0]);return e.useEffect((function(){var e,n=t instanceof Window?window:t.current,o=null!==(e=null==i?void 0:i.current)&&void 0!==e?e:document.documentElement;L.current=function(t,e,n,o){var i=a(t,2),r=i[0],s=i[1];return[M(r,e,n,o),M(s,e,n,o)]}(c,o,n,s)}),[t,i,s,c]),x(I,t,(function(t){var e="y"===s?t.offset.y:t.offset.x,n=a(L.current,2),o=n[0],i=n[1],r=i===o?e<o?0:1:(e-o)/(i-o),u=Math.min(Math.max(r,0),1),c=f?d:function(t){return t};"y"===s?(E(c(u)),T(0)):(T(c(u)),E(0))})),{scrollYProgress:y,scrollXProgress:w}}function b(t,e){return t instanceof HTMLElement?"y"===e?t.clientHeight:t.clientWidth:"y"===e?window.innerHeight:window.innerWidth}function M(t,e,n,o){var i=a(t.trim().split(/\s+/),2),r=i[0],s=i[1],u=void 0===s?r:s;if(n instanceof HTMLElement){var c=e.getBoundingClientRect(),l=n.getBoundingClientRect(),f=function(t,e){return t instanceof HTMLElement?"y"===e?t.scrollTop:t.scrollLeft:"y"===e?window.scrollY:window.scrollX}(n,o),v=("y"===o?c.top-l.top:c.left-l.left)+f,p="y"===o?c.height:c.width,d=b(n,o);return O(r,v,p,d)-O(u,0,d,d)}return S(r,o,e,!1)-S(u,o,window,!0)}function O(t,e,n,o){if("start"===t)return e;if("center"===t)return e+n/2;if("end"===t)return e+n;var i=t.match(/^(-?\d+(?:\.\d+)?)(px|%|vw|vh)?$/);if(!i)throw new Error("Invalid edge marker “".concat(t,"”"));var r=parseFloat(i[1]);switch(i[2]){case"px":return e+r;case"%":return e+r/100*n;case"vw":case"vh":return e+r/100*o;default:return e+r*n}}function S(t,e,n,o){var i=n;return O(t,o?0:function(){if(!(n instanceof HTMLElement))throw new Error("Expected HTMLElement for element-relative edge");var t=n.getBoundingClientRect(),o="y"===e?window.pageYOffset||window.scrollY:window.pageXOffset||window.scrollX;return("y"===e?t.top:t.left)+o}(),o?b(n,e):function(){if(!(n instanceof HTMLElement))throw new Error;var t=n.getBoundingClientRect();return"y"===e?t.height:t.width}(),b(i,e))}var P=function(t){function e(){var e=t.apply(this,u([],a(arguments),!1))||this;return e.attachedEls=new Set,e.movement={x:0,y:0},e.offset={x:0,y:0},e.velocity={x:0,y:0},e.lastTime=0,e}return i(e,t),e.prototype.attach=function(t){var e=this,n=Array.isArray(t)?t:[t],o=this.onWheel.bind(this);return n.forEach((function(t){e.attachedEls.add(t),t.addEventListener("wheel",o,{passive:!1})})),function(){n.forEach((function(t){t.removeEventListener("wheel",o),e.attachedEls.delete(t)})),null!=e.endTimeout&&(clearTimeout(e.endTimeout),e.endTimeout=void 0)}},e.prototype.cancel=function(){},e.prototype.onWheel=function(t){var e=this;t.preventDefault();var n=t.timeStamp,o=Math.max((n-this.lastTime)/1e3,1e-6);this.lastTime=n;var i=t.deltaX,s=t.deltaY;this.movement={x:i,y:s},this.offset.x+=i,this.offset.y+=s;var a=i/o/1e3,u=s/o/1e3;this.velocity={x:y(a,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT),y:y(u,-g.VELOCITY_LIMIT,g.VELOCITY_LIMIT)},this.emitChange({movement:r({},this.movement),offset:r({},this.offset),velocity:r({},this.velocity),event:t,cancel:function(){null!=e.endTimeout&&clearTimeout(e.endTimeout)}}),null!=this.endTimeout&&clearTimeout(this.endTimeout),this.endTimeout=window.setTimeout((function(){e.emitEnd({movement:r({},e.movement),offset:r({},e.offset),velocity:r({},e.velocity),event:t,cancel:function(){}})}),150)},e}(g);Object.defineProperty(exports,"Easing",{enumerable:!0,get:function(){return t.Easing}}),Object.defineProperty(exports,"animate",{enumerable:!0,get:function(){return t.motion}}),Object.defineProperty(exports,"combine",{enumerable:!0,get:function(){return t.combine}}),Object.defineProperty(exports,"makeAnimated",{enumerable:!0,get:function(){return t.makeMotion}}),exports.Config=d,exports.Mount=function(t){var e=t.state,o=t.children,i=m(e,s(t,["state","children"]));return n.jsx(n.Fragment,{children:i((function(t,e){return e&&o(t)}))})},exports.clamp=y,exports.move=function(t,e,n){var o=t[e],i=t.length,r=e-n;if(r>0)return u(u(u(u([],a(t.slice(0,n)),!1),[o],!1),a(t.slice(n,e)),!1),a(t.slice(e+1,i)),!1);if(r<0){var s=n+1;return u(u(u(u([],a(t.slice(0,e)),!1),a(t.slice(e+1,s)),!1),[o],!1),a(t.slice(s,i)),!1)}return t},exports.rubberClamp=function(t,e,n,o){return void 0===o&&(o=.15),0===o?y(t,e,n):t<e?-E(e-t,n-e,o)+e:t>n?+E(t-n,n-e,o)+n:t},exports.snapTo=function(t,e,n){var o=t+.2*e,i=function(t){return Math.abs(t-o)},r=n.map(i),s=Math.min.apply(Math,u([],a(r),!1));return n.reduce((function(t,e){return i(e)===s?e:t}))},exports.to=function(e,n,o,i){return t.to(n,o,i)(e)},exports.useDrag=function(t,e,n){return x(w,t,e,n)},exports.useInView=function(t,n){void 0===n&&(n={});var o=n.root,i=n.rootMargin,r=n.threshold,s=n.once,u=void 0!==s&&s,c=a(e.useState(!1),2),l=c[0],f=c[1];return e.useEffect((function(){var e=t.current;if(e){var n=new IntersectionObserver((function(t){var e=a(t,1)[0];e.isIntersecting?(f(!0),u&&(n.unobserve(e.target),n.disconnect())):u||f(!1)}),{root:null!=o?o:null,rootMargin:i,threshold:r});return n.observe(e),function(){return n.disconnect()}}}),[t,o,i,r,u]),l},exports.useMount=m,exports.useMove=function(t,e){return x(L,t,e)},exports.useOutsideClick=function(t,n,o){void 0===o&&(o=[]);var i=e.useRef(n);e.useEffect((function(){i.current=n}),u([n],a(o),!1)),e.useEffect((function(){function e(e){var n=t.current,o=e.target;n&&o&&o.isConnected&&(n.contains(o)||i.current(e))}return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),function(){document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}}),[t])},exports.useScroll=function(t,e){return"function"==typeof e?x(I,t,e):C(t,e)},exports.useValue=p,exports.useWheel=function(t,e){return x(P,t,e)},exports.withDecay=function(t,e){return{type:"decay",options:{velocity:t,clamp:null==e?void 0:e.clamp,onStart:null==e?void 0:e.onStart,onChange:null==e?void 0:e.onChange,onComplete:null==e?void 0:e.onComplete}}},exports.withDelay=function(t){return{type:"delay",options:{delay:t}}},exports.withLoop=function(t,e,n){return void 0===e&&(e=1/0),{type:"loop",options:{animation:t,iterations:e,onStart:null==n?void 0:n.onStart,onComplete:null==n?void 0:n.onComplete}}},exports.withSequence=function(t,e){return{type:"sequence",options:{animations:t,onStart:null==e?void 0:e.onStart,onComplete:null==e?void 0:e.onComplete}}},exports.withSpring=h,exports.withTiming=function(t,e){return{type:"timing",to:t,options:{duration:null==e?void 0:e.duration,easing:null==e?void 0:e.easing,onStart:null==e?void 0:e.onStart,onChange:null==e?void 0:e.onChange,onComplete:null==e?void 0:e.onComplete}}};
//# sourceMappingURL=index.js.map