@tsparticles/confetti 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/browser/ConfettiOptions.js +119 -0
- package/browser/IConfettiOptions.js +1 -0
- package/browser/bundle.js +2 -0
- package/browser/confetti.js +300 -0
- package/browser/index.js +1 -0
- package/cjs/ConfettiOptions.js +123 -0
- package/cjs/IConfettiOptions.js +2 -0
- package/cjs/bundle.js +18 -0
- package/cjs/confetti.js +304 -0
- package/cjs/index.js +17 -0
- package/esm/ConfettiOptions.js +119 -0
- package/esm/IConfettiOptions.js +1 -0
- package/esm/bundle.js +2 -0
- package/esm/confetti.js +300 -0
- package/esm/index.js +1 -0
- package/package.json +110 -0
- package/report.html +39 -0
- package/tsparticles.confetti.bundle.js +9605 -0
- package/tsparticles.confetti.bundle.min.js +2 -0
- package/tsparticles.confetti.bundle.min.js.LICENSE.txt +1 -0
- package/tsparticles.confetti.js +874 -0
- package/tsparticles.confetti.min.js +2 -0
- package/tsparticles.confetti.min.js.LICENSE.txt +1 -0
- package/types/ConfettiOptions.d.ts +25 -0
- package/types/IConfettiOptions.d.ts +20 -0
- package/types/bundle.d.ts +2 -0
- package/types/confetti.d.ts +18 -0
- package/types/index.d.ts +4 -0
- package/umd/ConfettiOptions.js +133 -0
- package/umd/IConfettiOptions.js +12 -0
- package/umd/bundle.js +28 -0
- package/umd/confetti.js +314 -0
- package/umd/index.js +27 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.confetti.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/shape-cards"),require("@tsparticles/plugin-emitters"),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/shape-square"),require("@tsparticles/shape-star"),require("@tsparticles/shape-text"),require("@tsparticles/updater-tilt"),require("@tsparticles/updater-wobble"),require("@tsparticles/move-base"),require("@tsparticles/shape-circle"),require("@tsparticles/updater-color"),require("@tsparticles/updater-opacity"),require("@tsparticles/updater-out-modes"),require("@tsparticles/updater-size"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/shape-cards","@tsparticles/plugin-emitters","@tsparticles/shape-heart","@tsparticles/shape-image","@tsparticles/updater-life","@tsparticles/plugin-motion","@tsparticles/shape-polygon","@tsparticles/updater-roll","@tsparticles/shape-square","@tsparticles/shape-star","@tsparticles/shape-text","@tsparticles/updater-tilt","@tsparticles/updater-wobble","@tsparticles/move-base","@tsparticles/shape-circle","@tsparticles/updater-color","@tsparticles/updater-opacity","@tsparticles/updater-out-modes","@tsparticles/updater-size"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/shape-cards"),require("@tsparticles/plugin-emitters"),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/shape-square"),require("@tsparticles/shape-star"),require("@tsparticles/shape-text"),require("@tsparticles/updater-tilt"),require("@tsparticles/updater-wobble"),require("@tsparticles/move-base"),require("@tsparticles/shape-circle"),require("@tsparticles/updater-color"),require("@tsparticles/updater-opacity"),require("@tsparticles/updater-out-modes"),require("@tsparticles/updater-size")):t(e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window);for(var a in i)("object"==typeof exports?exports:e)[a]=i[a]}}(this,((e,t,i,a,s,r,o,n,l,c,p,d,u,h,y,v,f,w,m,g)=>(()=>{"use strict";var x={533:t=>{t.exports=e},619:e=>{e.exports=y},68:e=>{e.exports=i},82:e=>{e.exports=o},686:e=>{e.exports=t},163:e=>{e.exports=v},12:e=>{e.exports=a},885:e=>{e.exports=s},907:e=>{e.exports=n},55:e=>{e.exports=c},960:e=>{e.exports=p},727:e=>{e.exports=d},501:e=>{e.exports=f},84:e=>{e.exports=r},446:e=>{e.exports=w},290:e=>{e.exports=m},734:e=>{e.exports=l},2:e=>{e.exports=g},448:e=>{e.exports=u},83:e=>{e.exports=h}},b={};function q(e){var t=b[e];if(void 0!==t)return t.exports;var i=b[e]={exports:{}};return x[e](i,i.exports,q),i.exports}q.d=(e,t)=>{for(var i in t)q.o(t,i)&&!q.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},q.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),q.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var S={};return(()=>{q.r(S),q.d(S,{confetti:()=>I});var e=q(533);class t{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.shapeOptions={}}get origin(){return{x:this.position.x/100,y:this.position.y/100}}set origin(e){this.position.x=100*e.x,this.position.y=100*e.y}get particleCount(){return this.count}set particleCount(e){this.count=e}load(t){if(!t)return;void 0!==t.angle&&(this.angle=t.angle);const i=t.count??t.particleCount;void 0!==i&&(this.count=i),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.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?100*a.x:void 0,y:void 0!==a.y?100*a.y:void 0});const s=t.position;s&&(void 0!==s.x&&(this.position.x=s.x),void 0!==s.y&&(this.position.y=s.y)),void 0!==t.colors&&((0,e.isArray)(t.colors)?this.colors=[...t.colors]:this.colors=t.colors);const r=t.shapeOptions;if(void 0!==r)for(const t in r){const i=r[t];i&&(this.shapeOptions[t]=(0,e.deepExtend)(this.shapeOptions[t]??{},i))}void 0!==t.shapes&&((0,e.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)}}var i=q(619),a=q(163),s=q(501),r=q(446),o=q(290),n=q(2);var l=q(686),c=q(68),p=q(12),d=q(885),u=q(84),h=q(82),y=q(907),v=q(734);class f{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,e.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class w extends e.ValueWithRandom{constructor(){super(),this.animation=new f,this.direction="clockwise",this.path=!1,this.value=0}load(e){e&&(super.load(e),void 0!==e.direction&&(this.direction=e.direction),this.animation.load(e.animation),void 0!==e.path&&(this.path=e.path))}}class m{constructor(e){this.container=e}init(t){const i=t.options.rotate;if(!i)return;t.rotate={enable:i.animation.enable,value:(0,e.getRangeValue)(i.value)*Math.PI/180},t.pathRotation=i.path;let a=i.direction;if("random"===a){a=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(a){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const s=i.animation;s.enable&&(t.rotate.decay=1-(0,e.getRangeValue)(s.decay),t.rotate.velocity=(0,e.getRangeValue)(s.speed)/360*this.container.retina.reduceFactor,s.sync||(t.rotate.velocity*=(0,e.getRandom)())),t.rotation=t.rotate.value}isEnabled(e){const t=e.options.rotate;return!!t&&(!e.destroyed&&!e.spawning&&t.animation.enable&&!t.path)}loadOptions(e,...t){e.rotate||(e.rotate=new w);for(const i of t)e.rotate.load(i?.rotate)}update(e,t){this.isEnabled(e)&&(!function(e,t){const i=e.rotate,a=e.options.rotate;if(!i||!a)return;const s=a.animation,r=(i.velocity??0)*t.factor,o=2*Math.PI,n=i.decay??1;s.enable&&("increasing"===i.status?(i.value+=r,i.value>o&&(i.value-=o)):(i.value-=r,i.value<0&&(i.value+=o)),i.velocity&&1!==n&&(i.velocity*=n))}(e,t),e.rotation=e.rotate?.value??0)}}var g=q(55),x=q(960),b=q(727),R=q(448),M=q(83);let P=!1,k=!1;const z=new Map;async function O(e){if(!P){if(k)return new Promise((e=>{const t=setInterval((()=>{P&&(clearInterval(t),e())}),100)}));k=!0,await(0,c.loadEmittersPlugin)(e,!1),await(0,h.loadMotionPlugin)(e,!1),await(0,l.loadCardsShape)(e,!1),await(0,p.loadHeartShape)(e,!1),await(0,d.loadImageShape)(e,!1),await(0,y.loadPolygonShape)(e,!1),await(0,g.loadSquareShape)(e,!1),await(0,x.loadStarShape)(e,!1),await(0,b.loadTextShape)(e,!1),await async function(e,t=!0){await e.addParticleUpdater("rotate",(e=>new m(e)),t)}(e,!1),await(0,u.loadLifeUpdater)(e,!1),await(0,v.loadRollUpdater)(e,!1),await(0,R.loadTiltUpdater)(e,!1),await(0,M.loadWobbleUpdater)(e,!1),await async function(e,t=!0){await(0,i.loadBaseMover)(e,!1),await(0,a.loadCircleShape)(e,!1),await(0,s.loadColorUpdater)(e,!1),await(0,r.loadOpacityUpdater)(e,!1),await(0,o.loadOutModesUpdater)(e,!1),await(0,n.loadSizeUpdater)(e,!1),await e.refresh(t)}(e),k=!1,P=!0}}async function V(i){const a=new t;let s;a.load(i.options);const r=1e3*a.ticks/432e3;if(z.has(i.id)&&(s=z.get(i.id),s&&!s.destroyed)){const e=s;if(e.addEmitter)return void e.addEmitter({startCount:a.count,position:a.position,size:{width:0,height:0},rate:{delay:0,quantity:0},life:{duration:.1,count:1},particles:{color:{value:a.colors},shape:{type:a.shapes,options:a.shapeOptions},life:{count:1},opacity:{value:{min:0,max:1},animation:{enable:!0,sync:!0,speed:r,startValue:"max",destroy:"min"}},size:{value:5*a.scalar},move:{angle:{value:a.spread,offset:0},drift:{min:-a.drift,max:a.drift},gravity:{acceleration:9.81*a.gravity},speed:3*a.startVelocity,decay:1-a.decay,direction:-a.angle}}})}const o={fullScreen:{enable:!i.canvas,zIndex:a.zIndex},fpsLimit:120,particles:{number:{value:0},color:{value:a.colors},shape:{type:a.shapes,options:a.shapeOptions},opacity:{value:{min:0,max:1},animation:{enable:!0,sync:!0,speed:r,startValue:"max",destroy:"min"}},size:{value:5*a.scalar},links:{enable:!1},life:{count:1},move:{angle:{value:a.spread,offset:0},drift:{min:-a.drift,max:a.drift},enable:!0,gravity:{enable:!0,acceleration:9.81*a.gravity},speed:3*a.startVelocity,decay:1-a.decay,direction:-a.angle,random:!0,straight:!1,outModes:{default:"none",bottom:"destroy"}},rotate:{value:{min:0,max:360},direction:"random",animation:{enable:!0,speed:60}},tilt:{direction:"random",enable:!0,value:{min:0,max:360},animation:{enable:!0,speed:60}},roll:{darken:{enable:!0,value:25},enable:!0,speed:{min:15,max:25}},wobble:{distance:30,enable:!0,speed:{min:-15,max:15}}},detectRetina:!0,motion:{disable:a.disableForReducedMotion},emitters:{name:"confetti",startCount:a.count,position:a.position,size:{width:0,height:0},rate:{delay:0,quantity:0},life:{duration:.1,count:1}}};return s=await e.tsParticles.load({id:i.id,element:i.canvas,options:o}),z.set(i.id,s),s}async function I(t,i){let a,s;return await O(e.tsParticles),(0,e.isString)(t)?(s=t,a=i??{}):(s="confetti",a=t),V({id:s,options:a})}I.create=async(t,i)=>{if(!t)return I;await O(e.tsParticles);const a=t.getAttribute("id")||"confetti";return t.setAttribute("id",a),async(s,r)=>{let o,n;return(0,e.isString)(s)?(n=s,o=r??i):(n=a,o=s),V({id:n,canvas:t,options:o})}},I.version=e.tsParticles.version,(0,e.isSsr)()||(window.confetti=I)})(),S})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Confetti v3.0.0-beta.0 by Matteo Bruni */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ICoordinates, type IOptionLoader, type RecursivePartial, type ShapeData, type SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
import type { IConfettiOptions } from "./IConfettiOptions";
|
|
3
|
+
export declare class ConfettiOptions implements IConfettiOptions, IOptionLoader<IConfettiOptions> {
|
|
4
|
+
angle: number;
|
|
5
|
+
colors: SingleOrMultiple<string>;
|
|
6
|
+
count: number;
|
|
7
|
+
decay: number;
|
|
8
|
+
disableForReducedMotion: boolean;
|
|
9
|
+
drift: number;
|
|
10
|
+
gravity: number;
|
|
11
|
+
position: ICoordinates;
|
|
12
|
+
scalar: number;
|
|
13
|
+
shapeOptions: ShapeData;
|
|
14
|
+
shapes: SingleOrMultiple<string>;
|
|
15
|
+
spread: number;
|
|
16
|
+
startVelocity: number;
|
|
17
|
+
ticks: number;
|
|
18
|
+
zIndex: number;
|
|
19
|
+
constructor();
|
|
20
|
+
get origin(): ICoordinates;
|
|
21
|
+
set origin(value: ICoordinates);
|
|
22
|
+
get particleCount(): number;
|
|
23
|
+
set particleCount(value: number);
|
|
24
|
+
load(data?: RecursivePartial<IConfettiOptions>): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ICoordinates, SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
export interface IConfettiOptions {
|
|
3
|
+
angle: number;
|
|
4
|
+
colors: SingleOrMultiple<string>;
|
|
5
|
+
count: number;
|
|
6
|
+
decay: number;
|
|
7
|
+
disableForReducedMotion: boolean;
|
|
8
|
+
drift: number;
|
|
9
|
+
gravity: number;
|
|
10
|
+
origin: ICoordinates;
|
|
11
|
+
particleCount: number;
|
|
12
|
+
position: ICoordinates;
|
|
13
|
+
scalar: number;
|
|
14
|
+
shapeOptions: Record<string, SingleOrMultiple<unknown>>;
|
|
15
|
+
shapes: SingleOrMultiple<string>;
|
|
16
|
+
spread: number;
|
|
17
|
+
startVelocity: number;
|
|
18
|
+
ticks: number;
|
|
19
|
+
zIndex: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Container, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IConfettiOptions } from "./IConfettiOptions";
|
|
3
|
+
export type ConfettiFirstParam = string | RecursivePartial<IConfettiOptions>;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
confetti: ConfettiFunc & {
|
|
7
|
+
create: (canvas: HTMLCanvasElement, options: RecursivePartial<IConfettiOptions>) => Promise<ConfettiFunc>;
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
type ConfettiFunc = (idOrOptions: ConfettiFirstParam, confettiOptions?: RecursivePartial<IConfettiOptions>) => Promise<Container | undefined>;
|
|
13
|
+
export declare function confetti(idOrOptions: ConfettiFirstParam, confettiOptions?: RecursivePartial<IConfettiOptions>): Promise<Container | undefined>;
|
|
14
|
+
export declare namespace confetti {
|
|
15
|
+
var create: (canvas: HTMLCanvasElement, options: RecursivePartial<IConfettiOptions>) => Promise<ConfettiFunc>;
|
|
16
|
+
var version: string;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConfettiOptions = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class ConfettiOptions {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.angle = 90;
|
|
17
|
+
this.count = 50;
|
|
18
|
+
this.spread = 45;
|
|
19
|
+
this.startVelocity = 45;
|
|
20
|
+
this.decay = 0.9;
|
|
21
|
+
this.gravity = 1;
|
|
22
|
+
this.drift = 0;
|
|
23
|
+
this.ticks = 200;
|
|
24
|
+
this.position = {
|
|
25
|
+
x: 50,
|
|
26
|
+
y: 50,
|
|
27
|
+
};
|
|
28
|
+
this.colors = ["#26ccff", "#a25afd", "#ff5e7e", "#88ff5a", "#fcff42", "#ffa62d", "#ff36ff"];
|
|
29
|
+
this.shapes = ["square", "circle"];
|
|
30
|
+
this.scalar = 1;
|
|
31
|
+
this.zIndex = 100;
|
|
32
|
+
this.disableForReducedMotion = true;
|
|
33
|
+
this.shapeOptions = {};
|
|
34
|
+
}
|
|
35
|
+
get origin() {
|
|
36
|
+
return {
|
|
37
|
+
x: this.position.x / 100,
|
|
38
|
+
y: this.position.y / 100,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
set origin(value) {
|
|
42
|
+
this.position.x = value.x * 100;
|
|
43
|
+
this.position.y = value.y * 100;
|
|
44
|
+
}
|
|
45
|
+
get particleCount() {
|
|
46
|
+
return this.count;
|
|
47
|
+
}
|
|
48
|
+
set particleCount(value) {
|
|
49
|
+
this.count = value;
|
|
50
|
+
}
|
|
51
|
+
load(data) {
|
|
52
|
+
if (!data) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (data.angle !== undefined) {
|
|
56
|
+
this.angle = data.angle;
|
|
57
|
+
}
|
|
58
|
+
const count = data.count ?? data.particleCount;
|
|
59
|
+
if (count !== undefined) {
|
|
60
|
+
this.count = count;
|
|
61
|
+
}
|
|
62
|
+
if (data.spread !== undefined) {
|
|
63
|
+
this.spread = data.spread;
|
|
64
|
+
}
|
|
65
|
+
if (data.startVelocity !== undefined) {
|
|
66
|
+
this.startVelocity = data.startVelocity;
|
|
67
|
+
}
|
|
68
|
+
if (data.decay !== undefined) {
|
|
69
|
+
this.decay = data.decay;
|
|
70
|
+
}
|
|
71
|
+
if (data.gravity !== undefined) {
|
|
72
|
+
this.gravity = data.gravity;
|
|
73
|
+
}
|
|
74
|
+
if (data.drift !== undefined) {
|
|
75
|
+
this.drift = data.drift;
|
|
76
|
+
}
|
|
77
|
+
if (data.ticks !== undefined) {
|
|
78
|
+
this.ticks = data.ticks;
|
|
79
|
+
}
|
|
80
|
+
const origin = data.origin;
|
|
81
|
+
if (origin && !data.position) {
|
|
82
|
+
data.position = {
|
|
83
|
+
x: origin.x !== undefined ? origin.x * 100 : undefined,
|
|
84
|
+
y: origin.y !== undefined ? origin.y * 100 : undefined,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const position = data.position;
|
|
88
|
+
if (position) {
|
|
89
|
+
if (position.x !== undefined) {
|
|
90
|
+
this.position.x = position.x;
|
|
91
|
+
}
|
|
92
|
+
if (position.y !== undefined) {
|
|
93
|
+
this.position.y = position.y;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (data.colors !== undefined) {
|
|
97
|
+
if ((0, engine_1.isArray)(data.colors)) {
|
|
98
|
+
this.colors = [...data.colors];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.colors = data.colors;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const options = data.shapeOptions;
|
|
105
|
+
if (options !== undefined) {
|
|
106
|
+
for (const shape in options) {
|
|
107
|
+
const item = options[shape];
|
|
108
|
+
if (item) {
|
|
109
|
+
this.shapeOptions[shape] = (0, engine_1.deepExtend)(this.shapeOptions[shape] ?? {}, item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (data.shapes !== undefined) {
|
|
114
|
+
if ((0, engine_1.isArray)(data.shapes)) {
|
|
115
|
+
this.shapes = [...data.shapes];
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.shapes = data.shapes;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (data.scalar !== undefined) {
|
|
122
|
+
this.scalar = data.scalar;
|
|
123
|
+
}
|
|
124
|
+
if (data.zIndex !== undefined) {
|
|
125
|
+
this.zIndex = data.zIndex;
|
|
126
|
+
}
|
|
127
|
+
if (data.disableForReducedMotion !== undefined) {
|
|
128
|
+
this.disableForReducedMotion = data.disableForReducedMotion;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.ConfettiOptions = ConfettiOptions;
|
|
133
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
package/umd/bundle.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", ".", "@tsparticles/engine"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("."), exports);
|
|
27
|
+
__exportStar(require("@tsparticles/engine"), exports);
|
|
28
|
+
});
|
package/umd/confetti.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./ConfettiOptions", "@tsparticles/basic", "@tsparticles/shape-cards", "@tsparticles/plugin-emitters", "@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/shape-text", "@tsparticles/updater-tilt", "@tsparticles/updater-wobble"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.confetti = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const ConfettiOptions_1 = require("./ConfettiOptions");
|
|
15
|
+
const basic_1 = require("@tsparticles/basic");
|
|
16
|
+
const shape_cards_1 = require("@tsparticles/shape-cards");
|
|
17
|
+
const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
|
|
18
|
+
const shape_heart_1 = require("@tsparticles/shape-heart");
|
|
19
|
+
const shape_image_1 = require("@tsparticles/shape-image");
|
|
20
|
+
const updater_life_1 = require("@tsparticles/updater-life");
|
|
21
|
+
const plugin_motion_1 = require("@tsparticles/plugin-motion");
|
|
22
|
+
const shape_polygon_1 = require("@tsparticles/shape-polygon");
|
|
23
|
+
const updater_roll_1 = require("@tsparticles/updater-roll");
|
|
24
|
+
const updater_rotate_1 = require("@tsparticles/updater-rotate");
|
|
25
|
+
const shape_square_1 = require("@tsparticles/shape-square");
|
|
26
|
+
const shape_star_1 = require("@tsparticles/shape-star");
|
|
27
|
+
const shape_text_1 = require("@tsparticles/shape-text");
|
|
28
|
+
const updater_tilt_1 = require("@tsparticles/updater-tilt");
|
|
29
|
+
const updater_wobble_1 = require("@tsparticles/updater-wobble");
|
|
30
|
+
let initialized = false;
|
|
31
|
+
let initializing = false;
|
|
32
|
+
const ids = new Map();
|
|
33
|
+
async function initPlugins(engine) {
|
|
34
|
+
if (initialized) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (initializing) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
const interval = setInterval(() => {
|
|
40
|
+
if (!initialized) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
clearInterval(interval);
|
|
44
|
+
resolve();
|
|
45
|
+
}, 100);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
initializing = true;
|
|
49
|
+
await (0, plugin_emitters_1.loadEmittersPlugin)(engine, false);
|
|
50
|
+
await (0, plugin_motion_1.loadMotionPlugin)(engine, false);
|
|
51
|
+
await (0, shape_cards_1.loadCardsShape)(engine, false);
|
|
52
|
+
await (0, shape_heart_1.loadHeartShape)(engine, false);
|
|
53
|
+
await (0, shape_image_1.loadImageShape)(engine, false);
|
|
54
|
+
await (0, shape_polygon_1.loadPolygonShape)(engine, false);
|
|
55
|
+
await (0, shape_square_1.loadSquareShape)(engine, false);
|
|
56
|
+
await (0, shape_star_1.loadStarShape)(engine, false);
|
|
57
|
+
await (0, shape_text_1.loadTextShape)(engine, false);
|
|
58
|
+
await (0, updater_rotate_1.loadRotateUpdater)(engine, false);
|
|
59
|
+
await (0, updater_life_1.loadLifeUpdater)(engine, false);
|
|
60
|
+
await (0, updater_roll_1.loadRollUpdater)(engine, false);
|
|
61
|
+
await (0, updater_tilt_1.loadTiltUpdater)(engine, false);
|
|
62
|
+
await (0, updater_wobble_1.loadWobbleUpdater)(engine, false);
|
|
63
|
+
await (0, basic_1.loadBasic)(engine);
|
|
64
|
+
initializing = false;
|
|
65
|
+
initialized = true;
|
|
66
|
+
}
|
|
67
|
+
async function setConfetti(params) {
|
|
68
|
+
const actualOptions = new ConfettiOptions_1.ConfettiOptions();
|
|
69
|
+
actualOptions.load(params.options);
|
|
70
|
+
let container;
|
|
71
|
+
const fpsLimit = 120, opacitySpeed = (actualOptions.ticks * 1000) / (3600 * fpsLimit);
|
|
72
|
+
if (ids.has(params.id)) {
|
|
73
|
+
container = ids.get(params.id);
|
|
74
|
+
if (container && !container.destroyed) {
|
|
75
|
+
const alias = container;
|
|
76
|
+
if (alias.addEmitter) {
|
|
77
|
+
alias.addEmitter({
|
|
78
|
+
startCount: actualOptions.count,
|
|
79
|
+
position: actualOptions.position,
|
|
80
|
+
size: {
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
},
|
|
84
|
+
rate: {
|
|
85
|
+
delay: 0,
|
|
86
|
+
quantity: 0,
|
|
87
|
+
},
|
|
88
|
+
life: {
|
|
89
|
+
duration: 0.1,
|
|
90
|
+
count: 1,
|
|
91
|
+
},
|
|
92
|
+
particles: {
|
|
93
|
+
color: {
|
|
94
|
+
value: actualOptions.colors,
|
|
95
|
+
},
|
|
96
|
+
shape: {
|
|
97
|
+
type: actualOptions.shapes,
|
|
98
|
+
options: actualOptions.shapeOptions,
|
|
99
|
+
},
|
|
100
|
+
life: {
|
|
101
|
+
count: 1,
|
|
102
|
+
},
|
|
103
|
+
opacity: {
|
|
104
|
+
value: { min: 0, max: 1 },
|
|
105
|
+
animation: {
|
|
106
|
+
enable: true,
|
|
107
|
+
sync: true,
|
|
108
|
+
speed: opacitySpeed,
|
|
109
|
+
startValue: "max",
|
|
110
|
+
destroy: "min",
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
size: {
|
|
114
|
+
value: 5 * actualOptions.scalar,
|
|
115
|
+
},
|
|
116
|
+
move: {
|
|
117
|
+
angle: {
|
|
118
|
+
value: actualOptions.spread,
|
|
119
|
+
offset: 0,
|
|
120
|
+
},
|
|
121
|
+
drift: {
|
|
122
|
+
min: -actualOptions.drift,
|
|
123
|
+
max: actualOptions.drift,
|
|
124
|
+
},
|
|
125
|
+
gravity: {
|
|
126
|
+
acceleration: actualOptions.gravity * 9.81,
|
|
127
|
+
},
|
|
128
|
+
speed: actualOptions.startVelocity * 3,
|
|
129
|
+
decay: 1 - actualOptions.decay,
|
|
130
|
+
direction: -actualOptions.angle,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const particlesOptions = {
|
|
139
|
+
fullScreen: {
|
|
140
|
+
enable: !params.canvas,
|
|
141
|
+
zIndex: actualOptions.zIndex,
|
|
142
|
+
},
|
|
143
|
+
fpsLimit: 120,
|
|
144
|
+
particles: {
|
|
145
|
+
number: {
|
|
146
|
+
value: 0,
|
|
147
|
+
},
|
|
148
|
+
color: {
|
|
149
|
+
value: actualOptions.colors,
|
|
150
|
+
},
|
|
151
|
+
shape: {
|
|
152
|
+
type: actualOptions.shapes,
|
|
153
|
+
options: actualOptions.shapeOptions,
|
|
154
|
+
},
|
|
155
|
+
opacity: {
|
|
156
|
+
value: { min: 0, max: 1 },
|
|
157
|
+
animation: {
|
|
158
|
+
enable: true,
|
|
159
|
+
sync: true,
|
|
160
|
+
speed: opacitySpeed,
|
|
161
|
+
startValue: "max",
|
|
162
|
+
destroy: "min",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
size: {
|
|
166
|
+
value: 5 * actualOptions.scalar,
|
|
167
|
+
},
|
|
168
|
+
links: {
|
|
169
|
+
enable: false,
|
|
170
|
+
},
|
|
171
|
+
life: {
|
|
172
|
+
count: 1,
|
|
173
|
+
},
|
|
174
|
+
move: {
|
|
175
|
+
angle: {
|
|
176
|
+
value: actualOptions.spread,
|
|
177
|
+
offset: 0,
|
|
178
|
+
},
|
|
179
|
+
drift: {
|
|
180
|
+
min: -actualOptions.drift,
|
|
181
|
+
max: actualOptions.drift,
|
|
182
|
+
},
|
|
183
|
+
enable: true,
|
|
184
|
+
gravity: {
|
|
185
|
+
enable: true,
|
|
186
|
+
acceleration: actualOptions.gravity * 9.81,
|
|
187
|
+
},
|
|
188
|
+
speed: actualOptions.startVelocity * 3,
|
|
189
|
+
decay: 1 - actualOptions.decay,
|
|
190
|
+
direction: -actualOptions.angle,
|
|
191
|
+
random: true,
|
|
192
|
+
straight: false,
|
|
193
|
+
outModes: {
|
|
194
|
+
default: "none",
|
|
195
|
+
bottom: "destroy",
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
rotate: {
|
|
199
|
+
value: {
|
|
200
|
+
min: 0,
|
|
201
|
+
max: 360,
|
|
202
|
+
},
|
|
203
|
+
direction: "random",
|
|
204
|
+
animation: {
|
|
205
|
+
enable: true,
|
|
206
|
+
speed: 60,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
tilt: {
|
|
210
|
+
direction: "random",
|
|
211
|
+
enable: true,
|
|
212
|
+
value: {
|
|
213
|
+
min: 0,
|
|
214
|
+
max: 360,
|
|
215
|
+
},
|
|
216
|
+
animation: {
|
|
217
|
+
enable: true,
|
|
218
|
+
speed: 60,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
roll: {
|
|
222
|
+
darken: {
|
|
223
|
+
enable: true,
|
|
224
|
+
value: 25,
|
|
225
|
+
},
|
|
226
|
+
enable: true,
|
|
227
|
+
speed: {
|
|
228
|
+
min: 15,
|
|
229
|
+
max: 25,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
wobble: {
|
|
233
|
+
distance: 30,
|
|
234
|
+
enable: true,
|
|
235
|
+
speed: {
|
|
236
|
+
min: -15,
|
|
237
|
+
max: 15,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
detectRetina: true,
|
|
242
|
+
motion: {
|
|
243
|
+
disable: actualOptions.disableForReducedMotion,
|
|
244
|
+
},
|
|
245
|
+
emitters: {
|
|
246
|
+
name: "confetti",
|
|
247
|
+
startCount: actualOptions.count,
|
|
248
|
+
position: actualOptions.position,
|
|
249
|
+
size: {
|
|
250
|
+
width: 0,
|
|
251
|
+
height: 0,
|
|
252
|
+
},
|
|
253
|
+
rate: {
|
|
254
|
+
delay: 0,
|
|
255
|
+
quantity: 0,
|
|
256
|
+
},
|
|
257
|
+
life: {
|
|
258
|
+
duration: 0.1,
|
|
259
|
+
count: 1,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
container = await engine_1.tsParticles.load({ id: params.id, element: params.canvas, options: particlesOptions });
|
|
264
|
+
ids.set(params.id, container);
|
|
265
|
+
return container;
|
|
266
|
+
}
|
|
267
|
+
async function confetti(idOrOptions, confettiOptions) {
|
|
268
|
+
await initPlugins(engine_1.tsParticles);
|
|
269
|
+
let options;
|
|
270
|
+
let id;
|
|
271
|
+
if ((0, engine_1.isString)(idOrOptions)) {
|
|
272
|
+
id = idOrOptions;
|
|
273
|
+
options = confettiOptions ?? {};
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
id = "confetti";
|
|
277
|
+
options = idOrOptions;
|
|
278
|
+
}
|
|
279
|
+
return setConfetti({
|
|
280
|
+
id,
|
|
281
|
+
options,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
exports.confetti = confetti;
|
|
285
|
+
confetti.create = async (canvas, options) => {
|
|
286
|
+
if (!canvas) {
|
|
287
|
+
return confetti;
|
|
288
|
+
}
|
|
289
|
+
await initPlugins(engine_1.tsParticles);
|
|
290
|
+
const id = canvas.getAttribute("id") || "confetti";
|
|
291
|
+
canvas.setAttribute("id", id);
|
|
292
|
+
return async (idOrOptions, confettiOptions) => {
|
|
293
|
+
let subOptions;
|
|
294
|
+
let subId;
|
|
295
|
+
if ((0, engine_1.isString)(idOrOptions)) {
|
|
296
|
+
subId = idOrOptions;
|
|
297
|
+
subOptions = confettiOptions ?? options;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
subId = id;
|
|
301
|
+
subOptions = idOrOptions;
|
|
302
|
+
}
|
|
303
|
+
return setConfetti({
|
|
304
|
+
id: subId,
|
|
305
|
+
canvas,
|
|
306
|
+
options: subOptions,
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
confetti.version = engine_1.tsParticles.version;
|
|
311
|
+
if (!(0, engine_1.isSsr)()) {
|
|
312
|
+
window.confetti = confetti;
|
|
313
|
+
}
|
|
314
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./confetti"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./confetti"), exports);
|
|
27
|
+
});
|