qarl 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var R=Object.create;var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var q=(t,s,e)=>s in t?L(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var N=(t,s)=>()=>(s||t((s={exports:{}}).exports,s),s.exports);var Y=(t,s,e,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of V(s))!G.call(t,r)&&r!==e&&L(t,r,{get:()=>s[r],enumerable:!(i=j(s,r))||i.enumerable});return t};var z=(t,s,e)=>(e=t!=null?R(B(t)):{},Y(s||!t||!t.__esModule?L(e,"default",{value:t,enumerable:!0}):e,t));var y=(t,s,e)=>(q(t,typeof s!="symbol"?s+"":s,e),e);var k=N(($,b)=>{"use strict";var K=Object.prototype.hasOwnProperty,g="~";function T(){}Object.create&&(T.prototype=Object.create(null),new T().__proto__||(g=!1));function H(t,s,e){this.fn=t,this.context=s,this.once=e||!1}function F(t,s,e,i,r){if(typeof e!="function")throw new TypeError("The listener must be a function");var n=new H(e,i||t,r),a=g?g+s:s;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],n]:t._events[a].push(n):(t._events[a]=n,t._eventsCount++),t}function D(t,s){--t._eventsCount===0?t._events=new T:delete t._events[s]}function f(){this._events=new T,this._eventsCount=0}f.prototype.eventNames=function(){var s=[],e,i;if(this._eventsCount===0)return s;for(i in e=this._events)K.call(e,i)&&s.push(g?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s};f.prototype.listeners=function(s){var e=g?g+s:s,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a};f.prototype.listenerCount=function(s){var e=g?g+s:s,i=this._events[e];return i?i.fn?1:i.length:0};f.prototype.emit=function(s,e,i,r,n,a){var p=g?g+s:s;if(!this._events[p])return!1;var o=this._events[p],l=arguments.length,m,h;if(o.fn){switch(o.once&&this.removeListener(s,o.fn,void 0,!0),l){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,i),!0;case 4:return o.fn.call(o.context,e,i,r),!0;case 5:return o.fn.call(o.context,e,i,r,n),!0;case 6:return o.fn.call(o.context,e,i,r,n,a),!0}for(h=1,m=new Array(l-1);h<l;h++)m[h-1]=arguments[h];o.fn.apply(o.context,m)}else{var I=o.length,c;for(h=0;h<I;h++)switch(o[h].once&&this.removeListener(s,o[h].fn,void 0,!0),l){case 1:o[h].fn.call(o[h].context);break;case 2:o[h].fn.call(o[h].context,e);break;case 3:o[h].fn.call(o[h].context,e,i);break;case 4:o[h].fn.call(o[h].context,e,i,r);break;default:if(!m)for(c=1,m=new Array(l-1);c<l;c++)m[c-1]=arguments[c];o[h].fn.apply(o[h].context,m)}}return!0};f.prototype.on=function(s,e,i){return F(this,s,e,i,!1)};f.prototype.once=function(s,e,i){return F(this,s,e,i,!0)};f.prototype.removeListener=function(s,e,i,r){var n=g?g+s:s;if(!this._events[n])return this;if(!e)return D(this,n),this;var a=this._events[n];if(a.fn)a.fn===e&&(!r||a.once)&&(!i||a.context===i)&&D(this,n);else{for(var p=0,o=[],l=a.length;p<l;p++)(a[p].fn!==e||r&&!a[p].once||i&&a[p].context!==i)&&o.push(a[p]);o.length?this._events[n]=o.length===1?o[0]:o:D(this,n)}return this};f.prototype.removeAllListeners=function(s){var e;return s?(e=g?g+s:s,this._events[e]&&D(this,e)):(this._events=new T,this._eventsCount=0),this};f.prototype.off=f.prototype.removeListener;f.prototype.addListener=f.prototype.on;f.prefixed=g;f.EventEmitter=f;typeof b<"u"&&(b.exports=f)});var U=z(k(),1);var Q=U.default;var C={processors:[],time:0,loop:!1,mode:null,delay:0,repeat:0,target:null,easing:t=>t,reversed:!1,repeatDelay:0,autoApplyProcessors:!1};var _={PLAY:"play",STOP:"stop",BEGIN:"begin",UPDATE:"update",REPEAT:"repeat",COMPLETE:"complete"};var x=Math.PI*2,v=Math.pow,E={reverse:t=>1-t,linear:t=>t,yoyo:t=>1-Math.abs(1-t*2),inQuad:t=>v(t,2),outQuad:t=>1-(1-t)*(1-t),inOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,inCubic:t=>v(t,3),outCubic:t=>--t*t*t+1,inOutCubic:t=>t<.5?4*v(t,3):(t-1)*(2*t-2)*(2*t-2)+1,inQuart:t=>v(t,4),outQuart:t=>1- --t*v(t,3),inOutQuart:t=>t<.5?8*v(t,4):1-8*--t*t*t*t,inQuint:t=>v(t,5),outQuint:t=>1+--t*v(t,4),inOutQuint:t=>t<.5?16*v(t,5):1+16*--t*t*t*t*t,inSine:t=>1-Math.cos(t*Math.PI/2),outSine:t=>Math.sin(t*Math.PI/2),inOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,inBack:(t,s=1.70158)=>t*t*((s+1)*t-s),outBack:(t,s=1.70158)=>(t-=1)*t*((s+1)*t+s)+1,inOutBack:(t,s=1.70158)=>(t*=2)<1?.5*(t*t*((s*1.525+1)*t-s*1.525)):.5*((t-=2)*t*((s*1.525+1)*t+s*1.525)+2),inExpo:t=>t===0?0:Math.pow(2,10*(t-1)),outExpo:t=>t===1?1:1-Math.pow(2,-10*t),inOutExpo:t=>t===0?0:t===1?1:t<.5?.5*Math.pow(2,20*t-10):1-.5*Math.pow(2,-20*t+10),inElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-e/x*Math.asin(1/s))*x/e),outElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:s*Math.pow(2,-10*t)*Math.sin((t-e/x*Math.asin(1/s))*x/e)+1,inOutElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:t<.5?-.5*s*Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*x/e):.5*s*Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*x/e)+1};var O={pingPong:function(t){return t<=.5?this._easing(t*2):1-this._easing((t-.5)*2)},yoyo:function(t){return this._easing(E.yoyo(t))},bounce:function(t){return E.yoyo(this._easing(t))}};var J=0,d=class d extends Q{constructor(e={},i){super();y(this,"_reversedEasing",e=>this.settings.easing(1-e));y(this,"_stepDelay",e=>{this.remainingDelay-=e,this.lastDeltaTime=e,!(this.remainingDelay>0)&&(this.emit(_.BEGIN),this.step=this._stepTime,this.step(Math.abs(this.remainingDelay)),this.remainingDelay=this.settings.delay)});y(this,"_stepTime",(e=0)=>{this.elapsedTime+=e,this.lastDeltaTime=e,this.elapsedTime>=this.time?(this.elapsedTime=this.time,this._update(),this._complete()):this._update()});this.index=J++,this.overrides=e,this.settings={},this.reset(e),i&&(this.manager=i),this.lastDeltaTime=0}on(...e){return super.on(...e),this}off(...e){return super.off(...e),this}once(...e){return super.once(...e),this}onComplete(...e){return super.on(_.COMPLETE,...e),this}onUpdate(...e){return super.on(_.UPDATE,...e),this}onceComplete(...e){return super.once(_.COMPLETE,...e),this}static _noop(){}static mergeConfigs(e,i){e!==i&&Object.keys(i).forEach(r=>{typeof i[r]=="object"&&i[r]!==null?((!e[r]||typeof e[r]!="object")&&(e[r]={}),d.mergeConfigs(e[r],i[r])):e[r]=i[r]})}static lerp(e,i,r){return e+(i-e)*r}_processState(){this.step=d._noop,this.progress=0,this.easeValue=0,this.elapsedTime=0,this.promise=null,this._resolve=d._noop,this._refreshDynamicProps()}_refreshDynamicProps(){this.applyProcessors(this.settings);let{target:e,time:i,repeat:r,loop:n,reversed:a,delay:p}=this.settings;this.target=e,this.time=Math.max(i,0),this.repeat=r>0?r:n?1/0:0,this.reversed=a,this.remainingDelay=p,this._processEasing()}_processEasing(){let e=typeof this.settings.easing=="string"?E[this.settings.easing]||E.linear:this.settings.easing;this._easing=this.reversed?this._reversedEasing:e;let i=typeof this.settings.mode=="string"?O[this.settings.mode]:this.settings.mode;this._calculateEasing=i?i.bind(this):this._easing}_update(){this.progress=this.elapsedTime/this.time,this.easeValue=this._calculateEasing(this.progress),this.emit(_.UPDATE,this)}_complete(){this.repeat-- >0?this._repeat():(this._resolve(),this.stop(!1),this.emit(_.COMPLETE))}_repeat(e=!0){this.remainingDelay=this.settings.repeatDelay,this.elapsedTime=0,this.remainingDelay>0&&(this.step=this._stepDelay),this._update(),e&&this.emit(_.REPEAT)}reset(e=this.constructor.DEFAULTS){return this.settings={...this.constructor.DEFAULTS,...e},this._processState(),this}applyProcessors(e=this.settings){e.processors.forEach(i=>{d.mergeConfigs(e,i.call(this,e)||{})})}tweak(e={}){return d.mergeConfigs(this.settings,e),this._refreshDynamicProps(),this}seek(e=0,i=!0){return this.elapsedTime=Math.min(Math.max(e,0),this.time),i&&this._update(),this}setProgress(e=0,i=!0){return this.seek(this.time*e,i)}reverse(e=!1){return this.reversed=!this.reversed,this.seek(this.time-this.elapsedTime,e),this._processEasing(),this}play(e=!0){return this.isPlaying?this:(this.settings.autoApplyProcessors&&this._refreshDynamicProps(),e&&this.emit(_.PLAY),this.remainingDelay>0?this.step=this._stepDelay:(this.step=this._stepTime,this.emit(_.BEGIN)),this.manager&&this.manager.addToActive(this),this)}playPromise(e=this.promise){return this.play(),this.promise=e||new Promise(i=>{this._resolve=i}),this.promise}stop(e=!0){return this._processState(),e&&this.emit(_.STOP),this.manager&&this.manager.removeFromActive(this),this}pause(){return this.step=d._noop,this.manager&&this.manager.removeFromActive(this),this}replay(e=!1){return this.stop(e),this.play(e),this}get isPlaying(){return this.step!==d._noop}remove(){this.stop(),this.manager.remove(this)}};y(d,"DEFAULTS",C);var u=d;var P=class extends u{_preparePropertySetters(){this.propertySetters=this.properties.map(s=>{let e=s.split("."),i=e.pop();return r=>{let n=this.target;for(let a=0;a<e.length;a++)n=n[e[a]];n[i]=r}})}_generatePath(){let s=this.settings.points,e=Math.max(this.settings.smoothing,1),i=[];this.totalLength=0;function r(n,a,p,o,l){let m=l*l,h=m*l;return n.map((I,c)=>.5*(2*a[c]+(-n[c]+p[c])*l+(2*n[c]-5*a[c]+4*p[c]-o[c])*m+(-n[c]+3*a[c]-3*p[c]+o[c])*h))}for(let n=0;n<s.length-1;n++){let a=s[n===0?n:n-1],p=s[n],o=s[n+1],l=s[n+2<s.length?n+2:n+1];for(let m=0;m<e;m++){let h=r(a,p,o,l,m/e);i.push(h),i.length>1&&(this.totalLength+=this._calculateDistance(i[i.length-2],h))}}return i.push(s[s.length-1]),i}_calculateDistance(s,e){return Math.sqrt(s.reduce((i,r,n)=>i+Math.pow(e[n]-s[n],2),0))}_refreshDynamicProps(){super._refreshDynamicProps(),this.path=this._generatePath(),!this.target||this.path.length===0?this._setTargetProperties=u._noop:(this._tryToSetupProperties(),this._preparePropertySetters())}_tryToSetupProperties(){if(this.settings.properties)this.properties=this.settings.properties;else if(this.path[0].length<=3){let s=[["position.x"],["position.x","position.y"],["position.x","position.y","position.z"]];this.properties=s[this.path[0].length-1]}else this.properties=[]}_setTargetProperties(s){for(let e=0;e<this.propertySetters.length;e++)this.propertySetters[e](s[e])}_clamp(s,e,i){return Math.max(e,Math.min(s,i))}_getInterpolatedPosition(){let s=this.path.length-1,e=this.easeValue*s,i=this._clamp(e,0,s),r=i>=s?s-1:Math.floor(i),n=Math.min(r+1,s),a=e-r,p=this.path[r],o=this.path[n];return p.map((l,m)=>u.lerp(l,o[m],a))}_update(){super._update(),this._setTargetProperties(this._getInterpolatedPosition())}};y(P,"DEFAULTS",{...u.DEFAULTS,properties:null,points:[],smoothing:20});var A=class extends u{_refreshDynamicProps(){super._refreshDynamicProps(),this._processFromTo()}_processFromTo(){this._lerps=[],this.target&&(this._setupStates(),this._createLerps())}_setupStates(){this._from=this.settings.from||this._createState(this.settings.to||{},this.target),this._to=this.settings.to||this._createState(this.settings.from||{},this.target)}_createState(s={},e={},i={}){let r=(n,a,p)=>{for(let o in n)typeof n[o]=="object"?(p[o]={},r(n[o],a[o],p[o])):p[o]=a[o]};return r(s,e,i),i}_createLerpStep(s,e,i,r){if(this.settings.dynamic)return()=>{s[r]=u.lerp(e[r],i[r],this.easeValue)};{let n=e[r],a=i[r]-n;return()=>{s[r]=n+a*this.easeValue}}}_createLerps(s=this.target,e=this._from,i=this._to){for(let r in i)typeof i[r]=="object"?this._createLerps(s[r],e[r],i[r]):this._lerps.push(this._createLerpStep(s,e,i,r))}_update(){super._update();for(let s of this._lerps)s()}from(s={}){return this.tweak({from:s}),this}to(s={}){return this.tweak({to:s}),this}swap(){return this.tweak({from:this.settings.to,to:this.settings.from}),this}};y(A,"DEFAULTS",{...u.DEFAULTS,dynamic:!1,from:null,to:null});function w(t){return t.target?t.creator?t.creator.prototype instanceof u?t.creator:(console.error("Invalid creator provided. Using default creator."),u):t.points?P:t.from||t.to?A:u:u}var S=class{constructor(){y(this,"update",s=>{this.activeAnimations.forEach(e=>{e.step(s)})});this.activeAnimations=new Map,this.allAnimations=new Map}create({on:s={},once:e={},...i}){let r=w(i),n=new r(i,this);return Object.keys(s).forEach(a=>{n.on(a,s[a])}),Object.keys(e).forEach(a=>{n.once(a,e[a])}),this.add(n),n}getActiveAnimations(){return Array.from(this.activeAnimations.values())}getAllAnimations(){return Array.from(this.allAnimations.values())}remove({index:s}={}){s&&(this.activeAnimations.delete(s),this.allAnimations.delete(s))}add(s){this.allAnimations.set(s.index,s)}addToActive(s){this.activeAnimations.set(s.index,s)}removeFromActive(s){this.activeAnimations.delete(s.index)}stopAll(){this.activeAnimations.forEach(s=>{s.stop()})}removeAll(){this.stopAll(),this.activeAnimations.clear(),this.allAnimations.clear()}};var W=new S;var M=class t{constructor(s,e={}){this.callback=s,this.options={maxDeltaTime:100,...e},this.isRunning=!1,this.lastTime=0,this.animationId=null}static start(s,e={}){let i=new t(s,e);return i.start(),i}start(){if(this.isRunning)return;this.isRunning=!0;let s=e=>{if(!this.isRunning)return;let i=Math.min(e-this.lastTime,this.options.maxDeltaTime);this.lastTime=e,this.callback(i),this.isRunning&&(this.animationId=requestAnimationFrame(s))};requestAnimationFrame(e=>{this.lastTime=e,s(e)})}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}get running(){return this.isRunning}};function X(t,s){let e=new w(t),i=new e(t);return M.start(i.step.bind(i)),s?i.playPromise():i.play()}export{u as Core,P as Curve,C as DEFAULTS,_ as EVENTS,A as FromTo,W as GlobalManager,M as Loop,S as Manager,E as easings,O as modes,X as play};
|
|
1
|
+
var R=Object.create;var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var q=(t,s,e)=>s in t?L(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var N=(t,s)=>()=>(s||t((s={exports:{}}).exports,s),s.exports);var Y=(t,s,e,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of V(s))!G.call(t,r)&&r!==e&&L(t,r,{get:()=>s[r],enumerable:!(i=j(s,r))||i.enumerable});return t};var z=(t,s,e)=>(e=t!=null?R(B(t)):{},Y(s||!t||!t.__esModule?L(e,"default",{value:t,enumerable:!0}):e,t));var y=(t,s,e)=>(q(t,typeof s!="symbol"?s+"":s,e),e);var k=N(($,b)=>{"use strict";var K=Object.prototype.hasOwnProperty,g="~";function T(){}Object.create&&(T.prototype=Object.create(null),new T().__proto__||(g=!1));function H(t,s,e){this.fn=t,this.context=s,this.once=e||!1}function F(t,s,e,i,r){if(typeof e!="function")throw new TypeError("The listener must be a function");var n=new H(e,i||t,r),a=g?g+s:s;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],n]:t._events[a].push(n):(t._events[a]=n,t._eventsCount++),t}function D(t,s){--t._eventsCount===0?t._events=new T:delete t._events[s]}function f(){this._events=new T,this._eventsCount=0}f.prototype.eventNames=function(){var s=[],e,i;if(this._eventsCount===0)return s;for(i in e=this._events)K.call(e,i)&&s.push(g?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s};f.prototype.listeners=function(s){var e=g?g+s:s,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a};f.prototype.listenerCount=function(s){var e=g?g+s:s,i=this._events[e];return i?i.fn?1:i.length:0};f.prototype.emit=function(s,e,i,r,n,a){var p=g?g+s:s;if(!this._events[p])return!1;var o=this._events[p],l=arguments.length,m,h;if(o.fn){switch(o.once&&this.removeListener(s,o.fn,void 0,!0),l){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,i),!0;case 4:return o.fn.call(o.context,e,i,r),!0;case 5:return o.fn.call(o.context,e,i,r,n),!0;case 6:return o.fn.call(o.context,e,i,r,n,a),!0}for(h=1,m=new Array(l-1);h<l;h++)m[h-1]=arguments[h];o.fn.apply(o.context,m)}else{var I=o.length,c;for(h=0;h<I;h++)switch(o[h].once&&this.removeListener(s,o[h].fn,void 0,!0),l){case 1:o[h].fn.call(o[h].context);break;case 2:o[h].fn.call(o[h].context,e);break;case 3:o[h].fn.call(o[h].context,e,i);break;case 4:o[h].fn.call(o[h].context,e,i,r);break;default:if(!m)for(c=1,m=new Array(l-1);c<l;c++)m[c-1]=arguments[c];o[h].fn.apply(o[h].context,m)}}return!0};f.prototype.on=function(s,e,i){return F(this,s,e,i,!1)};f.prototype.once=function(s,e,i){return F(this,s,e,i,!0)};f.prototype.removeListener=function(s,e,i,r){var n=g?g+s:s;if(!this._events[n])return this;if(!e)return D(this,n),this;var a=this._events[n];if(a.fn)a.fn===e&&(!r||a.once)&&(!i||a.context===i)&&D(this,n);else{for(var p=0,o=[],l=a.length;p<l;p++)(a[p].fn!==e||r&&!a[p].once||i&&a[p].context!==i)&&o.push(a[p]);o.length?this._events[n]=o.length===1?o[0]:o:D(this,n)}return this};f.prototype.removeAllListeners=function(s){var e;return s?(e=g?g+s:s,this._events[e]&&D(this,e)):(this._events=new T,this._eventsCount=0),this};f.prototype.off=f.prototype.removeListener;f.prototype.addListener=f.prototype.on;f.prefixed=g;f.EventEmitter=f;typeof b<"u"&&(b.exports=f)});var U=z(k(),1);var Q=U.default;var C={processors:[],time:0,loop:!1,mode:null,delay:0,repeat:0,target:null,easing:t=>t,reversed:!1,repeatDelay:0,autoApplyProcessors:!1};var _={PLAY:"play",STOP:"stop",BEGIN:"begin",UPDATE:"update",REPEAT:"repeat",COMPLETE:"complete"};var x=Math.PI*2,v=Math.pow,E={reverse:t=>1-t,linear:t=>t,yoyo:t=>1-Math.abs(1-t*2),inQuad:t=>v(t,2),outQuad:t=>1-(1-t)*(1-t),inOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,inCubic:t=>v(t,3),outCubic:t=>--t*t*t+1,inOutCubic:t=>t<.5?4*v(t,3):(t-1)*(2*t-2)*(2*t-2)+1,inQuart:t=>v(t,4),outQuart:t=>1- --t*v(t,3),inOutQuart:t=>t<.5?8*v(t,4):1-8*--t*t*t*t,inQuint:t=>v(t,5),outQuint:t=>1+--t*v(t,4),inOutQuint:t=>t<.5?16*v(t,5):1+16*--t*t*t*t*t,inSine:t=>1-Math.cos(t*Math.PI/2),outSine:t=>Math.sin(t*Math.PI/2),inOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,inBack:(t,s=1.70158)=>t*t*((s+1)*t-s),outBack:(t,s=1.70158)=>(t-=1)*t*((s+1)*t+s)+1,inOutBack:(t,s=1.70158)=>(t*=2)<1?.5*(t*t*((s*1.525+1)*t-s*1.525)):.5*((t-=2)*t*((s*1.525+1)*t+s*1.525)+2),inExpo:t=>t===0?0:Math.pow(2,10*(t-1)),outExpo:t=>t===1?1:1-Math.pow(2,-10*t),inOutExpo:t=>t===0?0:t===1?1:t<.5?.5*Math.pow(2,20*t-10):1-.5*Math.pow(2,-20*t+10),inElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:-s*Math.pow(2,10*(t-1))*Math.sin((t-1-e/x*Math.asin(1/s))*x/e),outElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:s*Math.pow(2,-10*t)*Math.sin((t-e/x*Math.asin(1/s))*x/e)+1,inOutElastic:(t,s=1,e=.5)=>t===0?0:t===1?1:t<.5?-.5*s*Math.pow(2,20*t-10)*Math.sin((20*t-11.125)*x/e):.5*s*Math.pow(2,-20*t+10)*Math.sin((20*t-11.125)*x/e)+1};var O={pingPong:function(t){return t<=.5?this._easing(t*2):1-this._easing((t-.5)*2)},yoyo:function(t){return this._easing(E.yoyo(t))},bounce:function(t){return E.yoyo(this._easing(t))}};var J=0,d=class d extends Q{constructor(e={},i){super();y(this,"_reversedEasing",e=>this.settings.easing(1-e));y(this,"_stepDelay",e=>{this.remainingDelay-=e,this.lastDeltaTime=e,!(this.remainingDelay>0)&&(this.emit(_.BEGIN),this.step=this._stepTime,this.step(Math.abs(this.remainingDelay)),this.remainingDelay=this.settings.delay)});y(this,"_stepTime",(e=0)=>{this.elapsedTime+=e,this.lastDeltaTime=e,this.elapsedTime>=this.time?(this.elapsedTime=this.time,this._update(),this._complete()):this._update()});this.index=J++,this.overrides=e,this.settings={},this.reset(e),i&&(this.manager=i),this.lastDeltaTime=0}on(...e){return super.on(...e),this}off(...e){return super.off(...e),this}once(...e){return super.once(...e),this}onComplete(...e){return super.on(_.COMPLETE,...e),this}onUpdate(...e){return super.on(_.UPDATE,...e),this}onceComplete(...e){return super.once(_.COMPLETE,...e),this}static _noop(){}static mergeConfigs(e,i){e!==i&&Object.keys(i).forEach(r=>{typeof i[r]=="object"&&i[r]!==null?((!e[r]||typeof e[r]!="object")&&(e[r]={}),d.mergeConfigs(e[r],i[r])):e[r]=i[r]})}static lerp(e,i,r){return e+(i-e)*r}_resetState(){this.step=d._noop,this.progress=0,this.easeValue=0,this.elapsedTime=0,this.promise=null,this._resolve=d._noop}_processState(){this._resetState(),this._refreshDynamicProps()}_refreshDynamicProps(){this.applyProcessors(this.settings);let{target:e,time:i,repeat:r,loop:n,reversed:a,delay:p}=this.settings;this.target=e,this.time=Math.max(i,0),this.repeat=r>0?r:n?1/0:0,this.reversed=a,this.remainingDelay=p,this._processEasing()}_processEasing(){let e=typeof this.settings.easing=="string"?E[this.settings.easing]||E.linear:this.settings.easing;this._easing=this.reversed?this._reversedEasing:e;let i=typeof this.settings.mode=="string"?O[this.settings.mode]:this.settings.mode;this._calculateEasing=i?i.bind(this):this._easing}_update(){this.progress=this.elapsedTime/this.time,this.easeValue=this._calculateEasing(this.progress),this.emit(_.UPDATE,this)}_complete(){this.repeat-- >0?this._repeat():(this._resolve(),this.stop(!1),this.emit(_.COMPLETE))}_repeat(e=!0){this.remainingDelay=this.settings.repeatDelay,this.elapsedTime=0,this.remainingDelay>0&&(this.step=this._stepDelay),this._update(),e&&this.emit(_.REPEAT)}reset(e=this.constructor.DEFAULTS){return this.settings={...this.constructor.DEFAULTS,...e},this._processState(),this}applyProcessors(e=this.settings){e.processors.forEach(i=>{d.mergeConfigs(e,i.call(this,e)||{})})}tweak(e={}){return d.mergeConfigs(this.settings,e),this._refreshDynamicProps(),this}seek(e=0,i=!0){return this.elapsedTime=Math.min(Math.max(e,0),this.time),i&&this._update(),this}setProgress(e=0,i=!0){return this.seek(this.time*e,i)}reverse(e=!1){return this.reversed=!this.reversed,this.seek(this.time-this.elapsedTime,e),this._processEasing(),this}play(e=!0){return this.isPlaying?this:(this.settings.autoApplyProcessors&&this._refreshDynamicProps(),e&&this.emit(_.PLAY),this.remainingDelay>0?this.step=this._stepDelay:(this.step=this._stepTime,this.emit(_.BEGIN)),this.manager&&this.manager.addToActive(this),this)}playPromise(e=this.promise){return this.play(),this.promise=e||new Promise(i=>{this._resolve=i}),this.promise}stop(e=!0){return this._resetState(),e&&this.emit(_.STOP),this.manager&&this.manager.removeFromActive(this),this}pause(){return this.step=d._noop,this.manager&&this.manager.removeFromActive(this),this}replay(e=!1){return this.stop(e),this.play(e),this}get isPlaying(){return this.step!==d._noop}remove(){this.stop(),this.manager.remove(this)}};y(d,"DEFAULTS",C);var u=d;var P=class extends u{_preparePropertySetters(){this.propertySetters=this.properties.map(s=>{let e=s.split("."),i=e.pop();return r=>{let n=this.target;for(let a=0;a<e.length;a++)n=n[e[a]];n[i]=r}})}_generatePath(){let s=this.settings.points,e=Math.max(this.settings.smoothing,1),i=[];this.totalLength=0;function r(n,a,p,o,l){let m=l*l,h=m*l;return n.map((I,c)=>.5*(2*a[c]+(-n[c]+p[c])*l+(2*n[c]-5*a[c]+4*p[c]-o[c])*m+(-n[c]+3*a[c]-3*p[c]+o[c])*h))}for(let n=0;n<s.length-1;n++){let a=s[n===0?n:n-1],p=s[n],o=s[n+1],l=s[n+2<s.length?n+2:n+1];for(let m=0;m<e;m++){let h=r(a,p,o,l,m/e);i.push(h),i.length>1&&(this.totalLength+=this._calculateDistance(i[i.length-2],h))}}return i.push(s[s.length-1]),i}_calculateDistance(s,e){return Math.sqrt(s.reduce((i,r,n)=>i+Math.pow(e[n]-s[n],2),0))}_refreshDynamicProps(){super._refreshDynamicProps(),this.path=this._generatePath(),!this.target||this.path.length===0?this._setTargetProperties=u._noop:(this._tryToSetupProperties(),this._preparePropertySetters())}_tryToSetupProperties(){if(this.settings.properties)this.properties=this.settings.properties;else if(this.path[0].length<=3){let s=[["position.x"],["position.x","position.y"],["position.x","position.y","position.z"]];this.properties=s[this.path[0].length-1]}else this.properties=[]}_setTargetProperties(s){for(let e=0;e<this.propertySetters.length;e++)this.propertySetters[e](s[e])}_clamp(s,e,i){return Math.max(e,Math.min(s,i))}_getInterpolatedPosition(){let s=this.path.length-1,e=this.easeValue*s,i=this._clamp(e,0,s),r=i>=s?s-1:Math.floor(i),n=Math.min(r+1,s),a=e-r,p=this.path[r],o=this.path[n];return p.map((l,m)=>u.lerp(l,o[m],a))}_update(){super._update(),this._setTargetProperties(this._getInterpolatedPosition())}};y(P,"DEFAULTS",{...u.DEFAULTS,properties:null,points:[],smoothing:20});var A=class extends u{_refreshDynamicProps(){super._refreshDynamicProps(),this._processFromTo()}_processFromTo(){this._lerps=[],this.target&&(this._setupStates(),this._createLerps())}_setupStates(){this._from=this.settings.from||this._createState(this.settings.to||{},this.target),this._to=this.settings.to||this._createState(this.settings.from||{},this.target)}_createState(s={},e={},i={}){let r=(n,a,p)=>{for(let o in n)typeof n[o]=="object"?(p[o]={},r(n[o],a[o],p[o])):p[o]=a[o]};return r(s,e,i),i}_createLerpStep(s,e,i,r){if(this.settings.dynamic)return()=>{s[r]=u.lerp(e[r],i[r],this.easeValue)};{let n=e[r],a=i[r]-n;return()=>{s[r]=n+a*this.easeValue}}}_createLerps(s=this.target,e=this._from,i=this._to){for(let r in i)typeof i[r]=="object"?this._createLerps(s[r],e[r],i[r]):this._lerps.push(this._createLerpStep(s,e,i,r))}_update(){super._update();for(let s of this._lerps)s()}from(s={}){return this.tweak({from:s}),this}to(s={}){return this.tweak({to:s}),this}swap(){return this.tweak({from:this.settings.to,to:this.settings.from}),this}};y(A,"DEFAULTS",{...u.DEFAULTS,dynamic:!1,from:null,to:null});function w(t){return t.target?t.creator?t.creator.prototype instanceof u?t.creator:(console.error("Invalid creator provided. Using default creator."),u):t.points?P:t.from||t.to?A:u:u}var S=class{constructor(){y(this,"update",s=>{this.activeAnimations.forEach(e=>{e.step(s)})});this.activeAnimations=new Map,this.allAnimations=new Map}create({on:s={},once:e={},...i}){let r=w(i),n=new r(i,this);return Object.keys(s).forEach(a=>{n.on(a,s[a])}),Object.keys(e).forEach(a=>{n.once(a,e[a])}),this.add(n),n}getActiveAnimations(){return Array.from(this.activeAnimations.values())}getAllAnimations(){return Array.from(this.allAnimations.values())}remove({index:s}={}){s&&(this.activeAnimations.delete(s),this.allAnimations.delete(s))}add(s){this.allAnimations.set(s.index,s)}addToActive(s){this.activeAnimations.set(s.index,s)}removeFromActive(s){this.activeAnimations.delete(s.index)}stopAll(){this.activeAnimations.forEach(s=>{s.stop()})}removeAll(){this.stopAll(),this.activeAnimations.clear(),this.allAnimations.clear()}};var W=new S;var M=class t{constructor(s,e={}){this.callback=s,this.options={maxDeltaTime:100,...e},this.isRunning=!1,this.lastTime=0,this.animationId=null}static start(s,e={}){let i=new t(s,e);return i.start(),i}start(){if(this.isRunning)return;this.isRunning=!0;let s=e=>{if(!this.isRunning)return;let i=Math.min(e-this.lastTime,this.options.maxDeltaTime);this.lastTime=e,this.callback(i),this.isRunning&&(this.animationId=requestAnimationFrame(s))};requestAnimationFrame(e=>{this.lastTime=e,s(e)})}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}get running(){return this.isRunning}};function X(t,s){let e=new w(t),i=new e(t);return M.start(i.step.bind(i)),s?i.playPromise():i.play()}export{u as Core,P as Curve,C as DEFAULTS,_ as EVENTS,A as FromTo,W as GlobalManager,M as Loop,S as Manager,E as easings,O as modes,X as play};
|