UNPKG

@ionic/core

Version:
4 lines • 5.33 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{c as e}from"./p-BpRUsN_W.js";import{w as o}from"./p-Co7eql8D.js";let t;const i=(e,o,i)=>{const n=o.startsWith("animation")?(r=e,void 0===t&&(t=void 0===r.style.animationName&&void 0!==r.style.webkitAnimationName?"-webkit-":""),t):"";var r;e.style.setProperty(n+o,i)},n=(e=[],o)=>{if(void 0!==o){const t=Array.isArray(o)?o:[o];return[...e,...t]}return e},r=t=>{let r,a,s,d,f,l,c,v,m,u,p,y=[],g=[],A=[],b=!1,C={},E=[],h=[],R={},S=0,k=!1,w=!1,D=!0,T=!1,W=!0,F=!1;const j=t,I=[],K=[],M=[],q=[],x=[],B=[],N=[],P=[],U=[],_=[],z=[],G="function"==typeof AnimationEffect||void 0!==o&&"function"==typeof o.AnimationEffect,H="function"==typeof Element&&"function"==typeof Element.prototype.animate&&G,J=()=>z,L=(e,o)=>{const t=o.findIndex((o=>o.c===e));t>-1&&o.splice(t,1)},O=(e,o)=>((o?.oneTimeCallback?K:I).push({c:e,o}),p),Q=()=>{H&&(z.forEach((e=>{e.cancel()})),z.length=0)},V=()=>{B.forEach((e=>{e?.parentNode&&e.parentNode.removeChild(e)})),B.length=0},X=()=>void 0!==f?f:c?c.getFill():"both",Y=()=>void 0!==v?v:void 0!==l?l:c?c.getDirection():"normal",Z=()=>k?"linear":void 0!==s?s:c?c.getEasing():"linear",$=()=>w?0:void 0!==m?m:void 0!==a?a:c?c.getDuration():0,ee=()=>void 0!==d?d:c?c.getIterations():1,oe=()=>void 0!==u?u:void 0!==r?r:c?c.getDelay():0,te=()=>{0!==S&&(S--,0===S&&((()=>{U.forEach((e=>e())),_.forEach((e=>e()));const e=D?1:0,o=E,t=h,n=R;q.forEach((e=>{const r=e.classList;o.forEach((e=>r.add(e))),t.forEach((e=>r.remove(e)));for(const o in n)n.hasOwnProperty(o)&&i(e,o,n[o])})),m=void 0,v=void 0,u=void 0,I.forEach((o=>o.c(e,p))),K.forEach((o=>o.c(e,p))),K.length=0,W=!0,D&&(T=!0),D=!0})(),c&&c.animationFinish()))},ie=()=>{(()=>{N.forEach((e=>e())),P.forEach((e=>e()));const e=g,o=A,t=C;q.forEach((n=>{const r=n.classList;e.forEach((e=>r.add(e))),o.forEach((e=>r.remove(e)));for(const e in t)t.hasOwnProperty(e)&&i(n,e,t[e])}))})(),y.length>0&&H&&(q.forEach((e=>{const o=e.animate(y,{id:j,delay:oe(),duration:$(),easing:Z(),iterations:ee(),fill:X(),direction:Y()});o.pause(),z.push(o)})),z.length>0&&(z[0].onfinish=()=>{te()})),b=!0},ne=e=>{e=Math.min(Math.max(e,0),.9999),H&&z.forEach((o=>{o.currentTime=o.effect.getComputedTiming().delay+$()*e,o.pause()}))},re=e=>{z.forEach((e=>{e.effect.updateTiming({delay:oe(),duration:$(),easing:Z(),iterations:ee(),fill:X(),direction:Y()})})),void 0!==e&&ne(e)},ae=(e=!1,o=!0,t)=>(e&&x.forEach((i=>{i.update(e,o,t)})),H&&re(t),p),se=()=>{b&&(H?z.forEach((e=>{e.pause()})):q.forEach((e=>{i(e,"animation-play-state","paused")})),F=!0)},de=e=>new Promise((o=>{e?.sync&&(w=!0,O((()=>w=!1),{oneTimeCallback:!0})),b||ie(),T&&(H&&(ne(0),re()),T=!1),W&&(S=x.length+1,W=!1);const t=()=>{L(i,K),o()},i=()=>{L(t,M),o()};O(i,{oneTimeCallback:!0}),M.push({c:t,o:{oneTimeCallback:!0}}),x.forEach((e=>{e.play()})),H?(z.forEach((e=>{e.play()})),0!==y.length&&0!==q.length||te()):te(),F=!1})),fe=(e,o)=>{const t=y[0];return void 0===t||void 0!==t.offset&&0!==t.offset?y=[{offset:0,[e]:o},...y]:t[e]=o,p};return p={parentAnimation:c,elements:q,childAnimations:x,id:j,animationFinish:te,from:fe,to:(e,o)=>{const t=y[y.length-1];return void 0===t||void 0!==t.offset&&1!==t.offset?y=[...y,{offset:1,[e]:o}]:t[e]=o,p},fromTo:(e,o,t)=>fe(e,o).to(e,t),parent:e=>(c=e,p),play:de,pause:()=>(x.forEach((e=>{e.pause()})),se(),p),stop:()=>{x.forEach((e=>{e.stop()})),b&&(Q(),b=!1),k=!1,w=!1,W=!0,v=void 0,m=void 0,u=void 0,S=0,T=!1,D=!0,F=!1,M.forEach((e=>e.c(0,p))),M.length=0},destroy:e=>(x.forEach((o=>{o.destroy(e)})),(e=>{Q(),e&&V()})(e),q.length=0,x.length=0,y.length=0,I.length=0,K.length=0,b=!1,W=!0,p),keyframes:e=>{const o=y!==e;return y=e,o&&(e=>{H&&J().forEach((o=>{const t=o.effect;if(t.setKeyframes)t.setKeyframes(e);else{const i=new KeyframeEffect(t.target,e,t.getTiming());o.effect=i}}))})(y),p},addAnimation:e=>{if(null!=e)if(Array.isArray(e))for(const o of e)o.parent(p),x.push(o);else e.parent(p),x.push(e);return p},addElement:o=>{if(null!=o)if(1===o.nodeType)q.push(o);else if(o.length>=0)for(let e=0;e<o.length;e++)q.push(o[e]);else e("createAnimation - Invalid addElement value.");return p},update:ae,fill:e=>(f=e,ae(!0),p),direction:e=>(l=e,ae(!0),p),iterations:e=>(d=e,ae(!0),p),duration:e=>(H||0!==e||(e=1),a=e,ae(!0),p),easing:e=>(s=e,ae(!0),p),delay:e=>(r=e,ae(!0),p),getWebAnimations:J,getKeyframes:()=>y,getFill:X,getDirection:Y,getDelay:oe,getIterations:ee,getEasing:Z,getDuration:$,afterAddRead:e=>(U.push(e),p),afterAddWrite:e=>(_.push(e),p),afterClearStyles:(e=[])=>{for(const o of e)R[o]="";return p},afterStyles:(e={})=>(R=e,p),afterRemoveClass:e=>(h=n(h,e),p),afterAddClass:e=>(E=n(E,e),p),beforeAddRead:e=>(N.push(e),p),beforeAddWrite:e=>(P.push(e),p),beforeClearStyles:(e=[])=>{for(const o of e)C[o]="";return p},beforeStyles:(e={})=>(C=e,p),beforeRemoveClass:e=>(A=n(A,e),p),beforeAddClass:e=>(g=n(g,e),p),onFinish:O,isRunning:()=>0!==S&&!F,progressStart:(e=!1,o)=>(x.forEach((t=>{t.progressStart(e,o)})),se(),k=e,b||ie(),ae(!1,!0,o),p),progressStep:e=>(x.forEach((o=>{o.progressStep(e)})),ne(e),p),progressEnd:(e,o,t)=>(k=!1,x.forEach((i=>{i.progressEnd(e,o,t)})),void 0!==t&&(m=t),T=!1,D=!0,0===e?(v="reverse"===Y()?"normal":"reverse","reverse"===v&&(D=!1),H?(ae(),ne(1-o)):(u=(1-o)*$()*-1,ae(!1,!1))):1===e&&(H?(ae(),ne(o)):(u=o*$()*-1,ae(!1,!1))),void 0===e||c||de(),p)}};export{r as c}