@neoconfetti/svelte
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -34,3 +34,3 @@ // ../core/dist/index.js | ||
const calc_rotation_transform = () => math_round(random() * (POSSIBLE_ROTATION_TRANSFORMS - 1)); | ||
const get_is_circle = (particle_shape, rotation_transform) => particle_shape === "circles" || should_be_circle(rotation_transform); | ||
const get_is_circle = (particle_shape, rotation_transform) => particleShape !== "rectangles" && (particle_shape === "circles" || should_be_circle(rotation_transform)); | ||
function confetti_styles(node, degree) { | ||
@@ -37,0 +37,0 @@ const rotation_transform = calc_rotation_transform(); |
@@ -1,1 +0,1 @@ | ||
var t="mz3PUW_p",e=["#FFC700","#FF0000","#2E3191","#41BBC7"],r=3500,a=.5,o=150,i="mix",n=12,s="",c=!0,l=800,d=1600;function m(m,T={}){let{colors:k=e,duration:A=r,force:H=a,particleCount:N=o,particleShape:F=i,particleSize:O=n,particleClass:j=s,destroyAfterDone:E=c,stageHeight:$=l,stageWidth:q=d}=T;!function(t){if(document.querySelector("style[data-neoconfetti]"))return;const e=P("style");e.dataset.neoconfetti="",e.textContent=t,z(document.head,e)}('@keyframes mz3PUW_ya{to{translate:0 var(--sh)}}@keyframes mz3PUW_xa{to{translate:var(--xlp)0}}@keyframes mz3PUW_r{50%{rotate:var(--hr)180deg}to{rotate:var(--r)360deg}}.mz3PUW_c{z-index:1200;width:0;height:0;position:relative;overflow:visible}.mz3PUW_p{animation:xa var(--dc)forwards cubic-bezier(var(--x1),var(--x2),var(--x3),var(--x4));animation-name:mz3PUW_xa}.mz3PUW_p>div{animation:ya var(--dc)forwards cubic-bezier(var(--y1),var(--y2),var(--y3),var(--y4));width:var(--w);height:var(--h);animation-name:mz3PUW_ya;position:absolute;top:0;left:0}.mz3PUW_p>div:before{content:"";background-color:var(--bgc);animation:r var(--rd)infinite linear;border-radius:var(--br);width:100%;height:100%;animation-name:mz3PUW_r;display:block}'),m.classList.add("mz3PUW_c"),m.style.setProperty("--sh",$+"px");let B=[],D=[];const J=()=>g(x()*(L-1)),I=(t,e)=>"circles"===t||M(e);function G(t,e){const r=J(),a=I(F,r),o=(e,r)=>t.style.setProperty(e,r+"");o("--xlp",_(v(S(e,90)-180),0,180,-q/2,q/2)+"px"),o("--dc",A-g(1e3*x())+"ms");const i=x()<f?U(x()*h,2):0;o("--x1",i),o("--x2",-1*i),o("--x3",i),o("--x4",U(v(_(v(S(e,90)-180),0,180,-1,1)),4)),o("--y1",U(x()*u,4)),o("--y2",U(x()*H*(w()?1:-1),4)),o("--y3",u),o("--y4",U(b(_(v(e-180),0,180,H,-H),0),4)),o("--w",(a?O:g(4*x())+O/2)+"px"),o("--h",(a?O:g(2*x())+O)+"px");const n=r.toString(2).padStart(3,"0").split("");o("--hr",n.map((t=>+t/2+"")).join(" ")),o("--r",n.join(" ")),o("--rd",U(x()*(y-p)+p)+"ms"),o("--br",a?"50%":0)}let K;function Q(){m.innerHTML="",clearTimeout(K),B=W(N,k),D=function(e,r=[],a){const o=[];for(const{color:i}of r){const r=P("div");r.className=`${t} ${a}`,r.style.setProperty("--bgc",i);const n=P("div");z(r,n),z(e,r),o.push(r)}return o}(m,B,j);for(const[t,e]of C(D))G(e,B[+t].degree);K=setTimeout((()=>{E&&(m.innerHTML="")}),A)}return Q(),{update(p){const y=p.particleCount??o,f=p.particleShape??i,h=p.particleSize??n,u=p.particleClass??s,v=p.colors??e,x=p.stageHeight??l,g=p.duration??r,b=p.force??a,P=p.stageWidth??d,z=p.destroyAfterDone??c;B=W(y,v);let U=!1;if(y===N){D=Array.from(m.querySelectorAll(`.${t}`));for(const[t,{color:e}]of C(B)){const r=D[+t];JSON.stringify(k)!==JSON.stringify(v)&&r.style.setProperty("--bgc",e),f!==F&&r.style.setProperty("--br",I(f,J())?"50%":"0"),u!==j&&(j&&r.classList.remove(j),u&&r.classList.add(u))}}else U=!0;E&&!z&&clearTimeout(K),m.style.setProperty("--sh",x+"px"),A=g,k=v,H=b,N=y,F=f,O=h,j=u,E=z,$=x,q=P,U&&Q()},destroy(){m.innerHTML="",clearTimeout(K)}}}var p=200,y=800,f=.1,h=.3,u=.5,v=Math.abs,x=Math.random,g=Math.round,b=Math.max,P=t=>document.createElement(t),z=(t,e)=>t.appendChild(e),W=(t,e)=>Array.from({length:t},((r,a)=>({color:e[a%e.length],degree:360*a/t}))),U=(t,e=2)=>g((t+Number.EPSILON)*10**e)/10**e,_=(t,e,r,a,o)=>(t-e)*(o-a)/(r-e)+a,S=(t,e)=>t+e>360?t+e-360:t+e,w=()=>x()>.5,C=Object.entries,L=6,M=t=>1!==t&&w();export{m as confetti}; | ||
var t="mz3PUW_p",e=["#FFC700","#FF0000","#2E3191","#41BBC7"],r=3500,a=.5,o=150,i="mix",n=12,s="",c=!0,l=800,d=1600;function m(m,T={}){let{colors:k=e,duration:A=r,force:H=a,particleCount:N=o,particleShape:F=i,particleSize:O=n,particleClass:j=s,destroyAfterDone:E=c,stageHeight:$=l,stageWidth:q=d}=T;!function(t){if(document.querySelector("style[data-neoconfetti]"))return;const e=P("style");e.dataset.neoconfetti="",e.textContent=t,z(document.head,e)}('@keyframes mz3PUW_ya{to{translate:0 var(--sh)}}@keyframes mz3PUW_xa{to{translate:var(--xlp)0}}@keyframes mz3PUW_r{50%{rotate:var(--hr)180deg}to{rotate:var(--r)360deg}}.mz3PUW_c{z-index:1200;width:0;height:0;position:relative;overflow:visible}.mz3PUW_p{animation:xa var(--dc)forwards cubic-bezier(var(--x1),var(--x2),var(--x3),var(--x4));animation-name:mz3PUW_xa}.mz3PUW_p>div{animation:ya var(--dc)forwards cubic-bezier(var(--y1),var(--y2),var(--y3),var(--y4));width:var(--w);height:var(--h);animation-name:mz3PUW_ya;position:absolute;top:0;left:0}.mz3PUW_p>div:before{content:"";background-color:var(--bgc);animation:r var(--rd)infinite linear;border-radius:var(--br);width:100%;height:100%;animation-name:mz3PUW_r;display:block}'),m.classList.add("mz3PUW_c"),m.style.setProperty("--sh",$+"px");let B=[],D=[];const J=()=>x(g()*(L-1)),I=(t,e)=>"rectangles"!==F&&("circles"===t||M(e));function G(t,e){const r=J(),a=I(F,r),o=(e,r)=>t.style.setProperty(e,r+"");o("--xlp",_(v(S(e,90)-180),0,180,-q/2,q/2)+"px"),o("--dc",A-x(1e3*g())+"ms");const i=g()<f?U(g()*h,2):0;o("--x1",i),o("--x2",-1*i),o("--x3",i),o("--x4",U(v(_(v(S(e,90)-180),0,180,-1,1)),4)),o("--y1",U(g()*u,4)),o("--y2",U(g()*H*(w()?1:-1),4)),o("--y3",u),o("--y4",U(b(_(v(e-180),0,180,H,-H),0),4)),o("--w",(a?O:x(4*g())+O/2)+"px"),o("--h",(a?O:x(2*g())+O)+"px");const n=r.toString(2).padStart(3,"0").split("");o("--hr",n.map((t=>+t/2+"")).join(" ")),o("--r",n.join(" ")),o("--rd",U(g()*(y-p)+p)+"ms"),o("--br",a?"50%":0)}let K;function Q(){m.innerHTML="",clearTimeout(K),B=W(N,k),D=function(e,r=[],a){const o=[];for(const{color:i}of r){const r=P("div");r.className=`${t} ${a}`,r.style.setProperty("--bgc",i);const n=P("div");z(r,n),z(e,r),o.push(r)}return o}(m,B,j);for(const[t,e]of C(D))G(e,B[+t].degree);K=setTimeout((()=>{E&&(m.innerHTML="")}),A)}return Q(),{update(p){const y=p.particleCount??o,f=p.particleShape??i,h=p.particleSize??n,u=p.particleClass??s,v=p.colors??e,g=p.stageHeight??l,x=p.duration??r,b=p.force??a,P=p.stageWidth??d,z=p.destroyAfterDone??c;B=W(y,v);let U=!1;if(y===N){D=Array.from(m.querySelectorAll(`.${t}`));for(const[t,{color:e}]of C(B)){const r=D[+t];JSON.stringify(k)!==JSON.stringify(v)&&r.style.setProperty("--bgc",e),f!==F&&r.style.setProperty("--br",I(f,J())?"50%":"0"),u!==j&&(j&&r.classList.remove(j),u&&r.classList.add(u))}}else U=!0;E&&!z&&clearTimeout(K),m.style.setProperty("--sh",g+"px"),A=x,k=v,H=b,N=y,F=f,O=h,j=u,E=z,$=g,q=P,U&&Q()},destroy(){m.innerHTML="",clearTimeout(K)}}}var p=200,y=800,f=.1,h=.3,u=.5,v=Math.abs,g=Math.random,x=Math.round,b=Math.max,P=t=>document.createElement(t),z=(t,e)=>t.appendChild(e),W=(t,e)=>Array.from({length:t},((r,a)=>({color:e[a%e.length],degree:360*a/t}))),U=(t,e=2)=>x((t+Number.EPSILON)*10**e)/10**e,_=(t,e,r,a,o)=>(t-e)*(o-a)/(r-e)+a,S=(t,e)=>t+e>360?t+e-360:t+e,w=()=>g()>.5,C=Object.entries,L=6,M=t=>1!==t&&w();export{m as confetti}; |
{ | ||
"name": "@neoconfetti/svelte", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Confetti explosion in Svelte 🎉🎊", | ||
@@ -47,3 +47,3 @@ "author": "Puru Vijay", | ||
"devDependencies": { | ||
"@neoconfetti/core": "2.2.0" | ||
"@neoconfetti/core": "2.2.1" | ||
}, | ||
@@ -50,0 +50,0 @@ "scripts": { |
20344