@ionic/core
Version:
Base components for Ionic
4 lines • 5.37 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{j as e}from"./p-4DxY6_gG.js";import{w as o}from"./p-ZjP4CjeZ.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,l,f,c,v,m,u,p,y=[],g=[],A=[],b=!1,C={},E=[],h=[],S={},j=0,k=!1,R=!1,w=!0,D=!1,T=!0,F=!1;const W=t,x=[],I=[],K=[],M=[],P=[],Z=[],G=[],Y=[],_=[],q=[],z=[],B="function"==typeof AnimationEffect||void 0!==o&&"function"==typeof o.AnimationEffect,H="function"==typeof Element&&"function"==typeof Element.prototype.animate&&B,J=()=>z,L=(e,o)=>{const t=o.findIndex((o=>o.c===e));t>-1&&o.splice(t,1)},N=(e,o)=>(((null==o?void 0:o.oneTimeCallback)?I:x).push({c:e,o}),p),O=()=>{H&&(z.forEach((e=>{e.cancel()})),z.length=0)},Q=()=>{Z.forEach((e=>{(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)})),Z.length=0},U=()=>void 0!==l?l:c?c.getFill():"both",V=()=>void 0!==v?v:void 0!==f?f:c?c.getDirection():"normal",X=()=>k?"linear":void 0!==s?s:c?c.getEasing():"linear",$=()=>R?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!==j&&(j--,0===j&&((()=>{_.forEach((e=>e())),q.forEach((e=>e()));const e=w?1:0,o=E,t=h,n=S;M.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,x.forEach((o=>o.c(e,p))),I.forEach((o=>o.c(e,p))),I.length=0,T=!0,w&&(D=!0),w=!0})(),c&&c.animationFinish()))},ie=()=>{(()=>{G.forEach((e=>e())),Y.forEach((e=>e()));const e=g,o=A,t=C;M.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&&(M.forEach((e=>{const o=e.animate(y,{id:W,delay:oe(),duration:$(),easing:X(),iterations:ee(),fill:U(),direction:V()});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:X(),iterations:ee(),fill:U(),direction:V()})})),void 0!==e&&ne(e)},ae=(e=!1,o=!0,t)=>(e&&P.forEach((i=>{i.update(e,o,t)})),H&&re(t),p),se=()=>{b&&(H?z.forEach((e=>{e.pause()})):M.forEach((e=>{i(e,"animation-play-state","paused")})),F=!0)},de=e=>new Promise((o=>{(null==e?void 0:e.sync)&&(R=!0,N((()=>R=!1),{oneTimeCallback:!0})),b||ie(),D&&(H&&(ne(0),re()),D=!1),T&&(j=P.length+1,T=!1);const t=()=>{L(i,I),o()},i=()=>{L(t,K),o()};N(i,{oneTimeCallback:!0}),K.push({c:t,o:{oneTimeCallback:!0}}),P.forEach((e=>{e.play()})),H?(z.forEach((e=>{e.play()})),0!==y.length&&0!==M.length||te()):te(),F=!1})),le=(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:M,childAnimations:P,id:W,animationFinish:te,from:le,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)=>le(e,o).to(e,t),parent:e=>(c=e,p),play:de,pause:()=>(P.forEach((e=>{e.pause()})),se(),p),stop:()=>{P.forEach((e=>{e.stop()})),b&&(O(),b=!1),k=!1,R=!1,T=!0,v=void 0,m=void 0,u=void 0,j=0,D=!1,w=!0,F=!1,K.forEach((e=>e.c(0,p))),K.length=0},destroy:e=>(P.forEach((o=>{o.destroy(e)})),(e=>{O(),e&&Q()})(e),M.length=0,P.length=0,y.length=0,x.length=0,I.length=0,b=!1,T=!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),P.push(o);else e.parent(p),P.push(e);return p},addElement:o=>{if(null!=o)if(1===o.nodeType)M.push(o);else if(o.length>=0)for(let e=0;e<o.length;e++)M.push(o[e]);else e("createAnimation - Invalid addElement value.");return p},update:ae,fill:e=>(l=e,ae(!0),p),direction:e=>(f=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:U,getDirection:V,getDelay:oe,getIterations:ee,getEasing:X,getDuration:$,afterAddRead:e=>(_.push(e),p),afterAddWrite:e=>(q.push(e),p),afterClearStyles:(e=[])=>{for(const o of e)S[o]="";return p},afterStyles:(e={})=>(S=e,p),afterRemoveClass:e=>(h=n(h,e),p),afterAddClass:e=>(E=n(E,e),p),beforeAddRead:e=>(G.push(e),p),beforeAddWrite:e=>(Y.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:N,isRunning:()=>0!==j&&!F,progressStart:(e=!1,o)=>(P.forEach((t=>{t.progressStart(e,o)})),se(),k=e,b||ie(),ae(!1,!0,o),p),progressStep:e=>(P.forEach((o=>{o.progressStep(e)})),ne(e),p),progressEnd:(e,o,t)=>(k=!1,P.forEach((i=>{i.progressEnd(e,o,t)})),void 0!==t&&(m=t),D=!1,w=!0,0===e?(v="reverse"===V()?"normal":"reverse","reverse"===v&&(w=!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}