@tsparticles/confetti 4.1.2 → 4.2.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.
@@ -1,4 +1,4 @@
1
- import { deepExtend, isArray, isNull, percentDenominator, } from "@tsparticles/engine";
1
+ import { deepExtend, isArray, isNull, loadProperty, percentDenominator, } from "@tsparticles/engine";
2
2
  export class ConfettiOptions {
3
3
  angle;
4
4
  colors;
@@ -57,34 +57,18 @@ export class ConfettiOptions {
57
57
  if (isNull(data)) {
58
58
  return;
59
59
  }
60
- if (data.angle !== undefined) {
61
- this.angle = data.angle;
62
- }
60
+ loadProperty(this, "angle", data.angle);
63
61
  const count = data.count ?? data.particleCount;
64
62
  if (count !== undefined) {
65
63
  this.count = count;
66
64
  }
67
- if (data.spread !== undefined) {
68
- this.spread = data.spread;
69
- }
70
- if (data.startVelocity !== undefined) {
71
- this.startVelocity = data.startVelocity;
72
- }
73
- if (data.decay !== undefined) {
74
- this.decay = data.decay;
75
- }
76
- if (data.flat !== undefined) {
77
- this.flat = data.flat;
78
- }
79
- if (data.gravity !== undefined) {
80
- this.gravity = data.gravity;
81
- }
82
- if (data.drift !== undefined) {
83
- this.drift = data.drift;
84
- }
85
- if (data.ticks !== undefined) {
86
- this.ticks = data.ticks;
87
- }
65
+ loadProperty(this, "spread", data.spread);
66
+ loadProperty(this, "startVelocity", data.startVelocity);
67
+ loadProperty(this, "decay", data.decay);
68
+ loadProperty(this, "flat", data.flat);
69
+ loadProperty(this, "gravity", data.gravity);
70
+ loadProperty(this, "drift", data.drift);
71
+ loadProperty(this, "ticks", data.ticks);
88
72
  const origin = data.origin;
89
73
  if (origin && !data.position) {
90
74
  data.position = {
@@ -126,14 +110,8 @@ export class ConfettiOptions {
126
110
  this.shapes = data.shapes;
127
111
  }
128
112
  }
129
- if (data.scalar !== undefined) {
130
- this.scalar = data.scalar;
131
- }
132
- if (data.zIndex !== undefined) {
133
- this.zIndex = data.zIndex;
134
- }
135
- if (data.disableForReducedMotion !== undefined) {
136
- this.disableForReducedMotion = data.disableForReducedMotion;
137
- }
113
+ loadProperty(this, "scalar", data.scalar);
114
+ loadProperty(this, "zIndex", data.zIndex);
115
+ loadProperty(this, "disableForReducedMotion", data.disableForReducedMotion);
138
116
  }
139
117
  }
@@ -17,7 +17,7 @@ import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
17
17
  import { setConfetti } from "./utils.js";
18
18
  let initPromise = null;
19
19
  async function doInitPlugins(engine) {
20
- engine.checkVersion("4.1.2");
20
+ engine.checkVersion("4.2.0");
21
21
  await engine.pluginManager.register(async (e) => {
22
22
  await Promise.all([
23
23
  loadBasic(e),
@@ -90,5 +90,5 @@ confetti.create = async (canvas, options = {}) => {
90
90
  confetti.init = async () => {
91
91
  await initPlugins(tsParticles);
92
92
  };
93
- confetti.version = "4.1.2";
93
+ confetti.version = "4.2.0";
94
94
  globalThis.confetti = confetti;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { setConfetti } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadEmojiShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -92,5 +92,5 @@ confetti.create = async (canvas, options = {}) => {
92
92
  confetti.init = async () => {
93
93
  await initPlugins(tsParticles);
94
94
  };
95
- confetti.version = "4.1.2";
95
+ confetti.version = "4.2.0";
96
96
  globalThis.confetti = confetti;
package/browser/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { millisecondsToSeconds } from "@tsparticles/engine";
1
+ import { defaultFps, percentDenominator } from "@tsparticles/engine";
2
2
  import { ConfettiOptions } from "./ConfettiOptions.js";
3
- const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, ids = new Map();
3
+ const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, noOpacityChange = 0, ids = new Map(), minTicks = 0;
4
4
  export async function addEmitter(container, actualOptions, opacitySpeed) {
5
5
  await container.addEmitter?.({
6
6
  startCount: actualOptions.count,
@@ -251,7 +251,7 @@ export function convertOptions(actualOptions, params, opacitySpeed) {
251
251
  export async function setConfetti(engine, params) {
252
252
  const actualOptions = new ConfettiOptions();
253
253
  actualOptions.load(params.options);
254
- const fpsLimit = 120, fpsLimitFactor = 3.6, opacitySpeed = (fpsLimitFactor * fpsLimit * millisecondsToSeconds) / (actualOptions.ticks * millisecondsToSeconds);
254
+ const fpsLimit = 120, safeTicks = Number.isFinite(actualOptions.ticks) && actualOptions.ticks > minTicks ? actualOptions.ticks : undefined, opacitySpeed = safeTicks === undefined ? noOpacityChange : (fpsLimit * percentDenominator) / (defaultFps * safeTicks);
255
255
  let containerOrPromise = ids.get(params.id);
256
256
  if (containerOrPromise instanceof Promise) {
257
257
  await containerOrPromise;
@@ -1,4 +1,4 @@
1
- import { deepExtend, isArray, isNull, percentDenominator, } from "@tsparticles/engine";
1
+ import { deepExtend, isArray, isNull, loadProperty, percentDenominator, } from "@tsparticles/engine";
2
2
  export class ConfettiOptions {
3
3
  angle;
4
4
  colors;
@@ -57,34 +57,18 @@ export class ConfettiOptions {
57
57
  if (isNull(data)) {
58
58
  return;
59
59
  }
60
- if (data.angle !== undefined) {
61
- this.angle = data.angle;
62
- }
60
+ loadProperty(this, "angle", data.angle);
63
61
  const count = data.count ?? data.particleCount;
64
62
  if (count !== undefined) {
65
63
  this.count = count;
66
64
  }
67
- if (data.spread !== undefined) {
68
- this.spread = data.spread;
69
- }
70
- if (data.startVelocity !== undefined) {
71
- this.startVelocity = data.startVelocity;
72
- }
73
- if (data.decay !== undefined) {
74
- this.decay = data.decay;
75
- }
76
- if (data.flat !== undefined) {
77
- this.flat = data.flat;
78
- }
79
- if (data.gravity !== undefined) {
80
- this.gravity = data.gravity;
81
- }
82
- if (data.drift !== undefined) {
83
- this.drift = data.drift;
84
- }
85
- if (data.ticks !== undefined) {
86
- this.ticks = data.ticks;
87
- }
65
+ loadProperty(this, "spread", data.spread);
66
+ loadProperty(this, "startVelocity", data.startVelocity);
67
+ loadProperty(this, "decay", data.decay);
68
+ loadProperty(this, "flat", data.flat);
69
+ loadProperty(this, "gravity", data.gravity);
70
+ loadProperty(this, "drift", data.drift);
71
+ loadProperty(this, "ticks", data.ticks);
88
72
  const origin = data.origin;
89
73
  if (origin && !data.position) {
90
74
  data.position = {
@@ -126,14 +110,8 @@ export class ConfettiOptions {
126
110
  this.shapes = data.shapes;
127
111
  }
128
112
  }
129
- if (data.scalar !== undefined) {
130
- this.scalar = data.scalar;
131
- }
132
- if (data.zIndex !== undefined) {
133
- this.zIndex = data.zIndex;
134
- }
135
- if (data.disableForReducedMotion !== undefined) {
136
- this.disableForReducedMotion = data.disableForReducedMotion;
137
- }
113
+ loadProperty(this, "scalar", data.scalar);
114
+ loadProperty(this, "zIndex", data.zIndex);
115
+ loadProperty(this, "disableForReducedMotion", data.disableForReducedMotion);
138
116
  }
139
117
  }
package/cjs/confetti.js CHANGED
@@ -17,7 +17,7 @@ import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
17
17
  import { setConfetti } from "./utils.js";
18
18
  let initPromise = null;
19
19
  async function doInitPlugins(engine) {
20
- engine.checkVersion("4.1.2");
20
+ engine.checkVersion("4.2.0");
21
21
  await engine.pluginManager.register(async (e) => {
22
22
  await Promise.all([
23
23
  loadBasic(e),
@@ -90,5 +90,5 @@ confetti.create = async (canvas, options = {}) => {
90
90
  confetti.init = async () => {
91
91
  await initPlugins(tsParticles);
92
92
  };
93
- confetti.version = "4.1.2";
93
+ confetti.version = "4.2.0";
94
94
  globalThis.confetti = confetti;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { setConfetti } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadEmojiShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -92,5 +92,5 @@ confetti.create = async (canvas, options = {}) => {
92
92
  confetti.init = async () => {
93
93
  await initPlugins(tsParticles);
94
94
  };
95
- confetti.version = "4.1.2";
95
+ confetti.version = "4.2.0";
96
96
  globalThis.confetti = confetti;
package/cjs/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { millisecondsToSeconds } from "@tsparticles/engine";
1
+ import { defaultFps, percentDenominator } from "@tsparticles/engine";
2
2
  import { ConfettiOptions } from "./ConfettiOptions.js";
3
- const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, ids = new Map();
3
+ const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, noOpacityChange = 0, ids = new Map(), minTicks = 0;
4
4
  export async function addEmitter(container, actualOptions, opacitySpeed) {
5
5
  await container.addEmitter?.({
6
6
  startCount: actualOptions.count,
@@ -251,7 +251,7 @@ export function convertOptions(actualOptions, params, opacitySpeed) {
251
251
  export async function setConfetti(engine, params) {
252
252
  const actualOptions = new ConfettiOptions();
253
253
  actualOptions.load(params.options);
254
- const fpsLimit = 120, fpsLimitFactor = 3.6, opacitySpeed = (fpsLimitFactor * fpsLimit * millisecondsToSeconds) / (actualOptions.ticks * millisecondsToSeconds);
254
+ const fpsLimit = 120, safeTicks = Number.isFinite(actualOptions.ticks) && actualOptions.ticks > minTicks ? actualOptions.ticks : undefined, opacitySpeed = safeTicks === undefined ? noOpacityChange : (fpsLimit * percentDenominator) / (defaultFps * safeTicks);
255
255
  let containerOrPromise = ids.get(params.id);
256
256
  if (containerOrPromise instanceof Promise) {
257
257
  await containerOrPromise;
@@ -1,4 +1,4 @@
1
- import { deepExtend, isArray, isNull, percentDenominator, } from "@tsparticles/engine";
1
+ import { deepExtend, isArray, isNull, loadProperty, percentDenominator, } from "@tsparticles/engine";
2
2
  export class ConfettiOptions {
3
3
  angle;
4
4
  colors;
@@ -57,34 +57,18 @@ export class ConfettiOptions {
57
57
  if (isNull(data)) {
58
58
  return;
59
59
  }
60
- if (data.angle !== undefined) {
61
- this.angle = data.angle;
62
- }
60
+ loadProperty(this, "angle", data.angle);
63
61
  const count = data.count ?? data.particleCount;
64
62
  if (count !== undefined) {
65
63
  this.count = count;
66
64
  }
67
- if (data.spread !== undefined) {
68
- this.spread = data.spread;
69
- }
70
- if (data.startVelocity !== undefined) {
71
- this.startVelocity = data.startVelocity;
72
- }
73
- if (data.decay !== undefined) {
74
- this.decay = data.decay;
75
- }
76
- if (data.flat !== undefined) {
77
- this.flat = data.flat;
78
- }
79
- if (data.gravity !== undefined) {
80
- this.gravity = data.gravity;
81
- }
82
- if (data.drift !== undefined) {
83
- this.drift = data.drift;
84
- }
85
- if (data.ticks !== undefined) {
86
- this.ticks = data.ticks;
87
- }
65
+ loadProperty(this, "spread", data.spread);
66
+ loadProperty(this, "startVelocity", data.startVelocity);
67
+ loadProperty(this, "decay", data.decay);
68
+ loadProperty(this, "flat", data.flat);
69
+ loadProperty(this, "gravity", data.gravity);
70
+ loadProperty(this, "drift", data.drift);
71
+ loadProperty(this, "ticks", data.ticks);
88
72
  const origin = data.origin;
89
73
  if (origin && !data.position) {
90
74
  data.position = {
@@ -126,14 +110,8 @@ export class ConfettiOptions {
126
110
  this.shapes = data.shapes;
127
111
  }
128
112
  }
129
- if (data.scalar !== undefined) {
130
- this.scalar = data.scalar;
131
- }
132
- if (data.zIndex !== undefined) {
133
- this.zIndex = data.zIndex;
134
- }
135
- if (data.disableForReducedMotion !== undefined) {
136
- this.disableForReducedMotion = data.disableForReducedMotion;
137
- }
113
+ loadProperty(this, "scalar", data.scalar);
114
+ loadProperty(this, "zIndex", data.zIndex);
115
+ loadProperty(this, "disableForReducedMotion", data.disableForReducedMotion);
138
116
  }
139
117
  }
package/esm/confetti.js CHANGED
@@ -17,7 +17,7 @@ import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
17
17
  import { setConfetti } from "./utils.js";
18
18
  let initPromise = null;
19
19
  async function doInitPlugins(engine) {
20
- engine.checkVersion("4.1.2");
20
+ engine.checkVersion("4.2.0");
21
21
  await engine.pluginManager.register(async (e) => {
22
22
  await Promise.all([
23
23
  loadBasic(e),
@@ -90,5 +90,5 @@ confetti.create = async (canvas, options = {}) => {
90
90
  confetti.init = async () => {
91
91
  await initPlugins(tsParticles);
92
92
  };
93
- confetti.version = "4.1.2";
93
+ confetti.version = "4.2.0";
94
94
  globalThis.confetti = confetti;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { setConfetti } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadEmojiShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -92,5 +92,5 @@ confetti.create = async (canvas, options = {}) => {
92
92
  confetti.init = async () => {
93
93
  await initPlugins(tsParticles);
94
94
  };
95
- confetti.version = "4.1.2";
95
+ confetti.version = "4.2.0";
96
96
  globalThis.confetti = confetti;
package/esm/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { millisecondsToSeconds } from "@tsparticles/engine";
1
+ import { defaultFps, percentDenominator } from "@tsparticles/engine";
2
2
  import { ConfettiOptions } from "./ConfettiOptions.js";
3
- const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, ids = new Map();
3
+ const defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0, noOpacityChange = 0, ids = new Map(), minTicks = 0;
4
4
  export async function addEmitter(container, actualOptions, opacitySpeed) {
5
5
  await container.addEmitter?.({
6
6
  startCount: actualOptions.count,
@@ -251,7 +251,7 @@ export function convertOptions(actualOptions, params, opacitySpeed) {
251
251
  export async function setConfetti(engine, params) {
252
252
  const actualOptions = new ConfettiOptions();
253
253
  actualOptions.load(params.options);
254
- const fpsLimit = 120, fpsLimitFactor = 3.6, opacitySpeed = (fpsLimitFactor * fpsLimit * millisecondsToSeconds) / (actualOptions.ticks * millisecondsToSeconds);
254
+ const fpsLimit = 120, safeTicks = Number.isFinite(actualOptions.ticks) && actualOptions.ticks > minTicks ? actualOptions.ticks : undefined, opacitySpeed = safeTicks === undefined ? noOpacityChange : (fpsLimit * percentDenominator) / (defaultFps * safeTicks);
255
255
  let containerOrPromise = ids.get(params.id);
256
256
  if (containerOrPromise instanceof Promise) {
257
257
  await containerOrPromise;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tsparticles/confetti",
3
- "version": "4.1.2",
4
- "description": "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.",
3
+ "version": "4.2.0",
4
+ "description": "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, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
7
7
  "type": "git",
@@ -105,22 +105,22 @@
105
105
  "./package.json": "./package.json"
106
106
  },
107
107
  "dependencies": {
108
- "@tsparticles/basic": "4.1.2",
109
- "@tsparticles/engine": "4.1.2",
110
- "@tsparticles/plugin-emitters": "4.1.2",
111
- "@tsparticles/plugin-motion": "4.1.2",
112
- "@tsparticles/shape-cards": "4.1.2",
113
- "@tsparticles/shape-emoji": "4.1.2",
114
- "@tsparticles/shape-heart": "4.1.2",
115
- "@tsparticles/shape-image": "4.1.2",
116
- "@tsparticles/shape-polygon": "4.1.2",
117
- "@tsparticles/shape-square": "4.1.2",
118
- "@tsparticles/shape-star": "4.1.2",
119
- "@tsparticles/updater-life": "4.1.2",
120
- "@tsparticles/updater-roll": "4.1.2",
121
- "@tsparticles/updater-rotate": "4.1.2",
122
- "@tsparticles/updater-tilt": "4.1.2",
123
- "@tsparticles/updater-wobble": "4.1.2"
108
+ "@tsparticles/basic": "4.2.0",
109
+ "@tsparticles/engine": "4.2.0",
110
+ "@tsparticles/plugin-emitters": "4.2.0",
111
+ "@tsparticles/plugin-motion": "4.2.0",
112
+ "@tsparticles/shape-cards": "4.2.0",
113
+ "@tsparticles/shape-emoji": "4.2.0",
114
+ "@tsparticles/shape-heart": "4.2.0",
115
+ "@tsparticles/shape-image": "4.2.0",
116
+ "@tsparticles/shape-polygon": "4.2.0",
117
+ "@tsparticles/shape-square": "4.2.0",
118
+ "@tsparticles/shape-star": "4.2.0",
119
+ "@tsparticles/updater-life": "4.2.0",
120
+ "@tsparticles/updater-roll": "4.2.0",
121
+ "@tsparticles/updater-rotate": "4.2.0",
122
+ "@tsparticles/updater-tilt": "4.2.0",
123
+ "@tsparticles/updater-wobble": "4.2.0"
124
124
  },
125
125
  "publishConfig": {
126
126
  "access": "public"