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