@tsparticles/preset-confetti 3.0.0-alpha.1 → 3.0.0-beta.2

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