@tsparticles/confetti
Version:
tsParticles confetti bundle — easily create confetti, confetti cannon, confetti explosions, confetti falling, and confetti parade animations with presets. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact,
2 lines (1 loc) • 10.5 kB
JavaScript
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/engine"),require("@tsparticles/basic"),require("@tsparticles/shape-cards/suits"),require("@tsparticles/plugin-emitters/plugin"),require("@tsparticles/shape-emoji"),require("@tsparticles/shape-heart"),require("@tsparticles/shape-image"),require("@tsparticles/updater-life"),require("@tsparticles/plugin-motion"),require("@tsparticles/shape-polygon"),require("@tsparticles/updater-roll"),require("@tsparticles/updater-rotate"),require("@tsparticles/shape-square"),require("@tsparticles/shape-star"),require("@tsparticles/updater-tilt"),require("@tsparticles/updater-wobble")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine","@tsparticles/basic","@tsparticles/shape-cards/suits","@tsparticles/plugin-emitters/plugin","@tsparticles/shape-emoji","@tsparticles/shape-heart","@tsparticles/shape-image","@tsparticles/updater-life","@tsparticles/plugin-motion","@tsparticles/shape-polygon","@tsparticles/updater-roll","@tsparticles/updater-rotate","@tsparticles/shape-square","@tsparticles/shape-star","@tsparticles/updater-tilt","@tsparticles/updater-wobble"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.bundles.confetti=t.__tsParticlesInternals.bundles.confetti||{}),t.__tsParticlesInternals.engine,t.__tsParticlesInternals.bundles.basic,t.__tsParticlesInternals.shapes["cards/suits"],t.__tsParticlesInternals.plugins["emitters/plugin"],t.__tsParticlesInternals.shapes.emoji,t.__tsParticlesInternals.shapes.heart,t.__tsParticlesInternals.shapes.image,t.__tsParticlesInternals.updaters.life,t.__tsParticlesInternals.plugins.motion,t.__tsParticlesInternals.shapes.polygon,t.__tsParticlesInternals.updaters.roll,t.__tsParticlesInternals.updaters.rotate,t.__tsParticlesInternals.shapes.square,t.__tsParticlesInternals.shapes.star,t.__tsParticlesInternals.updaters.tilt,t.__tsParticlesInternals.updaters.wobble)}(this,function(t,e,s,a,i,n,r,l,o,c,p,d,_,u,h,P,f){"use strict";class I{angle;colors;count;decay;disableForReducedMotion;drift;flat;gravity;position;scalar;shapeOptions;shapes;spread;startVelocity;ticks;zIndex;constructor(){this.angle=90,this.count=50,this.spread=45,this.startVelocity=45,this.decay=.9,this.gravity=1,this.drift=0,this.ticks=200,this.position={x:50,y:50},this.colors=["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],this.shapes=["square","circle"],this.scalar=1,this.zIndex=100,this.disableForReducedMotion=!0,this.flat=!1,this.shapeOptions={}}get origin(){return{x:this.position.x/e.percentDenominator,y:this.position.y/e.percentDenominator}}set origin(t){this.position.x=t.x*e.percentDenominator,this.position.y=t.y*e.percentDenominator}get particleCount(){return this.count}set particleCount(t){this.count=t}load(t){if(e.isNull(t))return;e.loadProperty(this,"angle",t.angle);const s=t.count??t.particleCount;void 0!==s&&(this.count=s),e.loadProperty(this,"spread",t.spread),e.loadProperty(this,"startVelocity",t.startVelocity),e.loadProperty(this,"decay",t.decay),e.loadProperty(this,"flat",t.flat),e.loadProperty(this,"gravity",t.gravity),e.loadProperty(this,"drift",t.drift),e.loadProperty(this,"ticks",t.ticks);const a=t.origin;a&&!t.position&&(t.position={x:void 0===a.x?void 0:a.x*e.percentDenominator,y:void 0===a.y?void 0:a.y*e.percentDenominator});const i=t.position;i&&(void 0!==i.x&&(this.position.x=i.x),void 0!==i.y&&(this.position.y=i.y)),void 0!==t.colors&&(e.isArray(t.colors)?this.colors=[...t.colors]:this.colors=t.colors);const n=t.shapeOptions;if(void 0!==n)for(const t in n){const s=n[t];s&&(this.shapeOptions[t]=e.deepExtend(this.shapeOptions[t]??{},s))}void 0!==t.shapes&&(e.isArray(t.shapes)?this.shapes=[...t.shapes]:this.shapes=t.shapes),e.loadProperty(this,"scalar",t.scalar),e.loadProperty(this,"zIndex",t.zIndex),e.loadProperty(this,"disableForReducedMotion",t.disableForReducedMotion)}}const y=new Map;async function m(t,s){const a=new I;a.load(s.options);const i=Number.isFinite(a.ticks)&&a.ticks>0?a.ticks:void 0,n=void 0===i?0:120*e.percentDenominator/(e.defaultFps*i);let r=y.get(s.id);r instanceof Promise&&(await r,r=y.get(s.id));const l=r;if(l&&!l.destroyed){const t=l;if("addEmitter"in t)return await async function(t,e,s){await(t.addEmitter?.({startCount:e.count,position:e.position,size:{width:0,height:0},rate:{delay:0,quantity:0},life:{duration:.1,count:1},particles:{paint:{fill:{color:{value:e.colors},enable:!0}},shape:{type:e.shapes,options:e.shapeOptions},life:{count:1},opacity:{value:{min:0,max:1},animation:{enable:!0,sync:!0,speed:s,startValue:"max",destroy:"min",count:1}},size:{value:5*e.scalar},move:{angle:{value:e.spread,offset:0},drift:{min:-e.drift,max:e.drift},gravity:{acceleration:9.81*e.gravity},speed:3*e.startVelocity,decay:1-e.decay,direction:-e.angle},rotate:{value:e.flat?0:{min:0,max:360},direction:"random",animation:{enable:!e.flat,speed:60}},tilt:{direction:"random",enable:!e.flat,value:e.flat?0:{min:0,max:360},animation:{enable:!0,speed:60}},roll:{darken:{enable:!0,value:25},enable:!e.flat,speed:{min:15,max:25}},wobble:{distance:30,enable:!e.flat,speed:{min:-15,max:15}}}}))}(t,a,n),l}const o=(async()=>{const e=function(t,e,s){return{fullScreen:{enable:!e.canvas,zIndex:t.zIndex},fpsLimit:120,particles:{number:{value:0},paint:{fill:{color:{value:t.colors},enable:!0}},shape:{type:t.shapes,options:t.shapeOptions},opacity:{value:{min:0,max:1},animation:{enable:!0,sync:!0,speed:s,startValue:"max",destroy:"min",count:1}},size:{value:5*t.scalar},links:{enable:!1},life:{count:1},move:{angle:{value:t.spread,offset:0},drift:{min:-t.drift,max:t.drift},enable:!0,gravity:{enable:!0,acceleration:9.81*t.gravity},speed:3*t.startVelocity,decay:1-t.decay,direction:-t.angle,random:!0,straight:!1,outModes:{top:"none",default:"destroy"}},rotate:{value:t.flat?0:{min:0,max:360},direction:"random",animation:{enable:!t.flat,speed:60}},tilt:{direction:"random",enable:!t.flat,value:t.flat?0:{min:0,max:360},animation:{enable:!0,speed:60}},roll:{darken:{enable:!0,value:25},enable:!t.flat,speed:{min:15,max:25}},wobble:{distance:30,enable:!t.flat,speed:{min:-15,max:15}}},motion:{disable:t.disableForReducedMotion},emitters:{name:"confetti",startCount:t.count,position:t.position,size:{width:0,height:0},rate:{delay:0,quantity:0},life:{duration:.1,count:1}}}}(a,s,n),i=await t.load({id:s.id,element:s.canvas,options:e});return y.set(s.id,i),i})();return y.set(s.id,o),o}let g=null;async function b(t){return g||(g=async function(t){t.checkVersion("4.2.1"),await t.pluginManager.register(async t=>{await Promise.all([s.loadBasic(t),c.loadMotionPlugin(t),i.loadEmittersPluginSimple(t),a.loadCardSuitsShape(t),r.loadHeartShape(t),l.loadImageShape(t),p.loadPolygonShape(t),u.loadSquareShape(t),h.loadStarShape(t),n.loadEmojiShape(t),_.loadRotateUpdater(t),o.loadLifeUpdater(t),d.loadRollUpdater(t),P.loadTiltUpdater(t),f.loadWobbleUpdater(t)])})}(t),g)}async function v(t,s){let a,i;return await b(e.tsParticles),e.isString(t)?(i=t,a=s??{}):(i="confetti",a=t),m(e.tsParticles,{id:i,options:a})}v.create=async(t,s={})=>{await b(e.tsParticles);const a=t?.getAttribute("id")??"confetti";return t?.setAttribute("id",a),await m(e.tsParticles,{id:a,canvas:t??void 0,options:s}),async(i,n)=>{let r,l;return e.isString(i)?(l=i,r=n??s):(l=a,r=i),m(e.tsParticles,{id:l,canvas:t??void 0,options:r})}},v.init=async()=>{await b(e.tsParticles)},v.version="4.2.1",globalThis.confetti=v;const x=globalThis;x.__tsParticlesInternals=x.__tsParticlesInternals??{},x.confetti=v,t.confetti=v}),Object.assign(globalThis.window||globalThis,{confetti:(globalThis.__tsParticlesInternals.bundles.confetti||{}).confetti}),delete(globalThis.window||globalThis).tsparticlesInternalExports;