@tsparticles/preset-confetti 3.0.0-alpha.1

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.
@@ -0,0 +1,114 @@
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
+ exports.ConfettiOptions = void 0;
13
+ class ConfettiOptions {
14
+ constructor() {
15
+ this.angle = 90;
16
+ this.count = 50;
17
+ this.spread = 45;
18
+ this.startVelocity = 45;
19
+ this.decay = 0.9;
20
+ this.gravity = 1;
21
+ this.drift = 0;
22
+ this.ticks = 200;
23
+ this.position = {
24
+ x: 50,
25
+ y: 50,
26
+ };
27
+ this.colors = ["#ffffff", "#ff0000"];
28
+ this.shapes = ["square", "circle"];
29
+ this.scalar = 1;
30
+ this.zIndex = 100;
31
+ this.disableForReducedMotion = true;
32
+ }
33
+ get origin() {
34
+ return {
35
+ x: this.position.x / 100,
36
+ y: this.position.y / 100,
37
+ };
38
+ }
39
+ set origin(value) {
40
+ this.position.x = value.x * 100;
41
+ this.position.y = value.y * 100;
42
+ }
43
+ get particleCount() {
44
+ return this.count;
45
+ }
46
+ set particleCount(value) {
47
+ this.count = value;
48
+ }
49
+ load(data) {
50
+ var _a, _b;
51
+ if (!data) {
52
+ return;
53
+ }
54
+ if (data.angle !== undefined) {
55
+ this.angle = data.angle;
56
+ }
57
+ const count = (_a = data.count) !== null && _a !== void 0 ? _a : data.particleCount;
58
+ if (count !== undefined) {
59
+ this.count = count;
60
+ }
61
+ if (data.spread !== undefined) {
62
+ this.spread = data.spread;
63
+ }
64
+ if (data.startVelocity !== undefined) {
65
+ this.startVelocity = data.startVelocity;
66
+ }
67
+ if (data.decay !== undefined) {
68
+ this.decay = data.decay;
69
+ }
70
+ if (data.gravity !== undefined) {
71
+ this.gravity = data.gravity;
72
+ }
73
+ if (data.drift !== undefined) {
74
+ this.drift = data.drift;
75
+ }
76
+ if (data.ticks !== undefined) {
77
+ this.ticks = data.ticks;
78
+ }
79
+ const position = (_b = data.position) !== null && _b !== void 0 ? _b : this.position;
80
+ if ((position === null || position === void 0 ? void 0 : position.x) !== undefined) {
81
+ this.position.x = position.x;
82
+ }
83
+ if ((position === null || position === void 0 ? void 0 : position.y) !== undefined) {
84
+ this.position.y = position.y;
85
+ }
86
+ if (data.colors !== undefined) {
87
+ if (data.colors instanceof Array) {
88
+ this.colors = [...data.colors];
89
+ }
90
+ else {
91
+ this.colors = data.colors;
92
+ }
93
+ }
94
+ if (data.shapes !== undefined) {
95
+ if (data.shapes instanceof Array) {
96
+ this.shapes = [...data.shapes];
97
+ }
98
+ else {
99
+ this.shapes = data.shapes;
100
+ }
101
+ }
102
+ if (data.scalar !== undefined) {
103
+ this.scalar = data.scalar;
104
+ }
105
+ if (data.zIndex !== undefined) {
106
+ this.zIndex = data.zIndex;
107
+ }
108
+ if (data.disableForReducedMotion !== undefined) {
109
+ this.disableForReducedMotion = data.disableForReducedMotion;
110
+ }
111
+ }
112
+ }
113
+ exports.ConfettiOptions = ConfettiOptions;
114
+ });
@@ -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,21 @@
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", "./index", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.tsParticles = exports.loadConfettiPreset = exports.confetti = void 0;
13
+ const index_1 = require("./index");
14
+ Object.defineProperty(exports, "confetti", { enumerable: true, get: function () { return index_1.confetti; } });
15
+ Object.defineProperty(exports, "loadConfettiPreset", { enumerable: true, get: function () { return index_1.loadConfettiPreset; } });
16
+ const engine_1 = require("@tsparticles/engine");
17
+ Object.defineProperty(exports, "tsParticles", { enumerable: true, get: function () { return engine_1.tsParticles; } });
18
+ (async () => {
19
+ await (0, index_1.loadConfettiPreset)(engine_1.tsParticles);
20
+ })();
21
+ });
package/umd/index.js ADDED
@@ -0,0 +1,70 @@
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", "@tsparticles/updater-angle", "@tsparticles/move-base", "@tsparticles/shape-circle", "@tsparticles/updater-color", "@tsparticles/plugin-emitters", "@tsparticles/updater-life", "@tsparticles/plugin-motion", "@tsparticles/updater-opacity", "./options", "@tsparticles/updater-out-modes", "@tsparticles/updater-roll", "@tsparticles/updater-size", "@tsparticles/shape-square", "@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 = exports.loadConfettiPreset = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const updater_angle_1 = require("@tsparticles/updater-angle");
15
+ const move_base_1 = require("@tsparticles/move-base");
16
+ const shape_circle_1 = require("@tsparticles/shape-circle");
17
+ const updater_color_1 = require("@tsparticles/updater-color");
18
+ const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
19
+ const updater_life_1 = require("@tsparticles/updater-life");
20
+ const plugin_motion_1 = require("@tsparticles/plugin-motion");
21
+ const updater_opacity_1 = require("@tsparticles/updater-opacity");
22
+ const options_1 = require("./options");
23
+ const updater_out_modes_1 = require("@tsparticles/updater-out-modes");
24
+ const updater_roll_1 = require("@tsparticles/updater-roll");
25
+ const updater_size_1 = require("@tsparticles/updater-size");
26
+ const shape_square_1 = require("@tsparticles/shape-square");
27
+ const updater_tilt_1 = require("@tsparticles/updater-tilt");
28
+ const updater_wobble_1 = require("@tsparticles/updater-wobble");
29
+ async function loadPreset(engine, confettiOptions, override = false) {
30
+ await (0, move_base_1.loadBaseMover)(engine);
31
+ await (0, shape_circle_1.loadCircleShape)(engine);
32
+ await (0, shape_square_1.loadSquareShape)(engine);
33
+ await (0, updater_color_1.loadColorUpdater)(engine);
34
+ await (0, updater_size_1.loadSizeUpdater)(engine);
35
+ await (0, updater_opacity_1.loadOpacityUpdater)(engine);
36
+ await (0, updater_out_modes_1.loadOutModesUpdater)(engine);
37
+ await (0, plugin_emitters_1.loadEmittersPlugin)(engine);
38
+ await (0, plugin_motion_1.loadMotionPlugin)(engine);
39
+ await (0, updater_wobble_1.loadWobbleUpdater)(engine);
40
+ await (0, updater_roll_1.loadRollUpdater)(engine);
41
+ await (0, updater_angle_1.loadAngleUpdater)(engine);
42
+ await (0, updater_tilt_1.loadTiltUpdater)(engine);
43
+ await (0, updater_life_1.loadLifeUpdater)(engine);
44
+ await engine.addPreset("confetti", (0, options_1.loadOptions)(confettiOptions), override);
45
+ }
46
+ async function loadConfettiPreset(main) {
47
+ await loadPreset(main, {}, true);
48
+ }
49
+ exports.loadConfettiPreset = loadConfettiPreset;
50
+ async function confetti(idOrOptions, confettiOptions) {
51
+ let options;
52
+ let id;
53
+ if (typeof idOrOptions === "string") {
54
+ id = idOrOptions;
55
+ options = confettiOptions !== null && confettiOptions !== void 0 ? confettiOptions : {};
56
+ }
57
+ else {
58
+ id = `tsparticles_${Math.floor((0, engine_1.getRandom)() * 1000)}`;
59
+ options = idOrOptions;
60
+ }
61
+ await loadPreset(engine_1.tsParticles, options, true);
62
+ await engine_1.tsParticles.load({
63
+ id,
64
+ options: {
65
+ preset: "confetti",
66
+ },
67
+ });
68
+ }
69
+ exports.confetti = confetti;
70
+ });
package/umd/options.js ADDED
@@ -0,0 +1,145 @@
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", "./ConfettiOptions"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadOptions = void 0;
13
+ const ConfettiOptions_1 = require("./ConfettiOptions");
14
+ const loadOptions = (confettiOptions) => {
15
+ const actualOptions = new ConfettiOptions_1.ConfettiOptions();
16
+ actualOptions.load(confettiOptions);
17
+ return {
18
+ fullScreen: {
19
+ enable: true,
20
+ zIndex: actualOptions.zIndex,
21
+ },
22
+ fpsLimit: 120,
23
+ particles: {
24
+ number: {
25
+ value: 0,
26
+ },
27
+ color: {
28
+ value: actualOptions.colors,
29
+ },
30
+ shape: {
31
+ type: actualOptions.shapes,
32
+ },
33
+ opacity: {
34
+ value: { min: 0, max: 1 },
35
+ animation: {
36
+ enable: true,
37
+ speed: 0.5,
38
+ startValue: "max",
39
+ destroy: "min",
40
+ },
41
+ },
42
+ size: {
43
+ value: 5 * actualOptions.scalar,
44
+ },
45
+ links: {
46
+ enable: false,
47
+ },
48
+ life: {
49
+ duration: {
50
+ sync: true,
51
+ value: actualOptions.ticks / 60,
52
+ },
53
+ count: 1,
54
+ },
55
+ move: {
56
+ angle: {
57
+ value: actualOptions.spread,
58
+ offset: 0,
59
+ },
60
+ drift: {
61
+ min: -actualOptions.drift,
62
+ max: actualOptions.drift,
63
+ },
64
+ enable: true,
65
+ gravity: {
66
+ enable: true,
67
+ acceleration: actualOptions.gravity * 9.81,
68
+ },
69
+ speed: actualOptions.startVelocity,
70
+ decay: 1 - actualOptions.decay,
71
+ direction: -actualOptions.angle,
72
+ random: true,
73
+ straight: false,
74
+ outModes: {
75
+ default: "none",
76
+ bottom: "destroy",
77
+ },
78
+ },
79
+ rotate: {
80
+ value: {
81
+ min: 0,
82
+ max: 360,
83
+ },
84
+ direction: "random",
85
+ animation: {
86
+ enable: true,
87
+ speed: 60,
88
+ },
89
+ },
90
+ tilt: {
91
+ direction: "random",
92
+ enable: true,
93
+ value: {
94
+ min: 0,
95
+ max: 360,
96
+ },
97
+ animation: {
98
+ enable: true,
99
+ speed: 60,
100
+ },
101
+ },
102
+ roll: {
103
+ darken: {
104
+ enable: true,
105
+ value: 25,
106
+ },
107
+ enable: true,
108
+ speed: {
109
+ min: 15,
110
+ max: 25,
111
+ },
112
+ },
113
+ wobble: {
114
+ distance: 30,
115
+ enable: true,
116
+ speed: {
117
+ min: -15,
118
+ max: 15,
119
+ },
120
+ },
121
+ },
122
+ detectRetina: true,
123
+ motion: {
124
+ disable: actualOptions.disableForReducedMotion,
125
+ },
126
+ emitters: {
127
+ startCount: actualOptions.count,
128
+ position: actualOptions.position,
129
+ size: {
130
+ width: 0,
131
+ height: 0,
132
+ },
133
+ rate: {
134
+ delay: 0,
135
+ quantity: 0,
136
+ },
137
+ life: {
138
+ duration: 0.1,
139
+ count: 1,
140
+ },
141
+ },
142
+ };
143
+ };
144
+ exports.loadOptions = loadOptions;
145
+ });