@graphery/svg
Version:
Graphery SVG library
1 lines • 1.01 kB
JavaScript
(()=>{let i=(n,t)=>typeof n===t,p="function",d="number",f="string",h="element not found";class g{gySVG=null;#n=null;#e=[];#t;#s;constructor(n,t,e,s){this.gySVG=n,this.#n=t,this.#t=typeof e=="function"?e:()=>{},this.#s=typeof s=="function"?s:()=>{}}get prev(){let n=this.#e[this.#e.length-1];let t=n[2];return{end:(e=0)=>(t.delay||0)+(t.duration||200)+e,begin:(e=0)=>(t.delay||0)+e}}step(n){let t=i(n,d)?this.#e[n]:this.#e.find(s=>s[0]===n);if(!t)throw new Error(h);let e=t[2];return{end:(s=0)=>(e.delay||0)+(e.duration||200)+s,begin:(s=0)=>(e.delay||0)+s}}get steps(){return this.#e.slice()}add(...n){return this.#e.push(n),this}play(){let n=this.#s;let t=this.#e.length;this.#t();for(let e of this.#e){let s=i(e[0],f)?this.#n.querySelector(e[0]):e[0],r=e[1],u=e[2],c=e[3]||null,a=e[4]||null;s.animateTo(r,u,c,function(...l){i(a,p)&&a.apply(this,l),--t||n()})}}}function o(n,t){Object.assign(t.prototype,{Seq(e,s){return new g(n,this,e,s)}})}(typeof gobalThis!="undefined"?globalThis:window).gySVG.extend(o);})();