@tsparticles/confetti
Version:
Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.
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 s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(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"],s):s(((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,s,e,a,i,n,r,l,o,c,p,d,_,u,h,f,P){"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/s.percentDenominator,y:this.position.y/s.percentDenominator}}set origin(t){this.position.x=t.x*s.percentDenominator,this.position.y=t.y*s.percentDenominator}get particleCount(){return this.count}set particleCount(t){this.count=t}load(t){if(s.isNull(t))return;void 0!==t.angle&&(this.angle=t.angle);const e=t.count??t.particleCount;void 0!==e&&(this.count=e),void 0!==t.spread&&(this.spread=t.spread),void 0!==t.startVelocity&&(this.startVelocity=t.startVelocity),void 0!==t.decay&&(this.decay=t.decay),void 0!==t.flat&&(this.flat=t.flat),void 0!==t.gravity&&(this.gravity=t.gravity),void 0!==t.drift&&(this.drift=t.drift),void 0!==t.ticks&&(this.ticks=t.ticks);const a=t.origin;a&&!t.position&&(t.position={x:void 0===a.x?void 0:a.x*s.percentDenominator,y:void 0===a.y?void 0:a.y*s.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&&(s.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 e=n[t];e&&(this.shapeOptions[t]=s.deepExtend(this.shapeOptions[t]??{},e))}void 0!==t.shapes&&(s.isArray(t.shapes)?this.shapes=[...t.shapes]:this.shapes=t.shapes),void 0!==t.scalar&&(this.scalar=t.scalar),void 0!==t.zIndex&&(this.zIndex=t.zIndex),void 0!==t.disableForReducedMotion&&(this.disableForReducedMotion=t.disableForReducedMotion)}}const m=new Map;async function g(t,e){const a=new I;a.load(e.options);const i=a.ticks*s.millisecondsToSeconds/(3.6*s.millisecondsToSeconds*120);let n=m.get(e.id);n instanceof Promise&&(await n,n=m.get(e.id));const r=n;if(r&&!r.destroyed){const t=r;if("addEmitter"in t)return await async function(t,s,e){await(t.addEmitter?.({startCount:s.count,position:s.position,size:{width:0,height:0},rate:{delay:0,quantity:0},life:{duration:.1,count:1},particles:{paint:{fill:{color:{value:s.colors},enable:!0}},shape:{type:s.shapes,options:s.shapeOptions},life:{count:1},opacity:{value:{min:0,max:1},animation:{enable:!0,sync:!0,speed:e,startValue:"max",destroy:"min",count:1}},size:{value:5*s.scalar},move:{angle:{value:s.spread,offset:0},drift:{min:-s.drift,max:s.drift},gravity:{acceleration:9.81*s.gravity},speed:3*s.startVelocity,decay:1-s.decay,direction:-s.angle},rotate:{value:s.flat?0:{min:0,max:360},direction:"random",animation:{enable:!s.flat,speed:60}},tilt:{direction:"random",enable:!s.flat,value:s.flat?0:{min:0,max:360},animation:{enable:!0,speed:60}},roll:{darken:{enable:!0,value:25},enable:!s.flat,speed:{min:15,max:25}},wobble:{distance:30,enable:!s.flat,speed:{min:-15,max:15}}}}))}(t,a,i),r}const l=(async()=>{const s=function(t,s,e){return{fullScreen:{enable:!s.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:e,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:{default:"none",bottom:"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,e,i),n=await t.load({id:e.id,element:e.canvas,options:s});return m.set(e.id,n),n})();return m.set(e.id,l),l}let y=null;async function b(t){return y||(y=async function(t){t.checkVersion("4.0.5"),await t.pluginManager.register(async t=>{await Promise.all([e.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),f.loadTiltUpdater(t),P.loadWobbleUpdater(t)])})}(t),y)}async function v(t,e){let a,i;return await b(s.tsParticles),s.isString(t)?(i=t,a=e??{}):(i="confetti",a=t),g(s.tsParticles,{id:i,options:a})}v.create=async(t,e={})=>{await b(s.tsParticles);const a=t?.getAttribute("id")??"confetti";return t?.setAttribute("id",a),await g(s.tsParticles,{id:a,canvas:t??void 0,options:e}),async(i,n)=>{let r,l;return s.isString(i)?(l=i,r=n??e):(l=a,r=i),g(s.tsParticles,{id:l,canvas:t??void 0,options:r})}},v.init=async()=>{await b(s.tsParticles)},v.version="4.0.5",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;