tsparticles 1.41.3 → 1.41.6

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.
Files changed (89) hide show
  1. package/Core/Canvas.js +1 -4
  2. package/Core/Particle.d.ts +1 -0
  3. package/Core/Particle.js +1 -0
  4. package/Core/Particles.js +2 -1
  5. package/Plugins/Emitters/EmitterInstance.js +8 -7
  6. package/Updaters/Size/SizeUpdater.js +0 -1
  7. package/browser/Core/Canvas.js +1 -4
  8. package/browser/Core/Particle.d.ts +1 -0
  9. package/browser/Core/Particle.js +1 -0
  10. package/browser/Core/Particles.js +2 -1
  11. package/browser/Plugins/Emitters/EmitterInstance.js +8 -7
  12. package/browser/Updaters/Size/SizeUpdater.js +0 -1
  13. package/esm/Core/Canvas.js +1 -4
  14. package/esm/Core/Particle.d.ts +1 -0
  15. package/esm/Core/Particle.js +1 -0
  16. package/esm/Core/Particles.js +2 -1
  17. package/esm/Plugins/Emitters/EmitterInstance.js +8 -7
  18. package/esm/Updaters/Size/SizeUpdater.js +0 -1
  19. package/package.json +1 -1
  20. package/report.html +2 -2
  21. package/report.slim.html +2 -2
  22. package/tsparticles.engine.js +4 -5
  23. package/tsparticles.engine.min.js +2 -2
  24. package/tsparticles.interaction.external.attract.js +4 -5
  25. package/tsparticles.interaction.external.attract.min.js +1 -1
  26. package/tsparticles.interaction.external.bounce.js +4 -5
  27. package/tsparticles.interaction.external.bounce.min.js +1 -1
  28. package/tsparticles.interaction.external.bubble.js +4 -5
  29. package/tsparticles.interaction.external.bubble.min.js +1 -1
  30. package/tsparticles.interaction.external.connect.js +4 -5
  31. package/tsparticles.interaction.external.connect.min.js +1 -1
  32. package/tsparticles.interaction.external.grab.js +4 -5
  33. package/tsparticles.interaction.external.grab.min.js +1 -1
  34. package/tsparticles.interaction.external.repulse.js +4 -5
  35. package/tsparticles.interaction.external.repulse.min.js +1 -1
  36. package/tsparticles.interaction.external.trail.js +4 -5
  37. package/tsparticles.interaction.external.trail.min.js +1 -1
  38. package/tsparticles.interaction.particles.attract.js +4 -5
  39. package/tsparticles.interaction.particles.attract.min.js +1 -1
  40. package/tsparticles.interaction.particles.collisions.js +4 -5
  41. package/tsparticles.interaction.particles.collisions.min.js +1 -1
  42. package/tsparticles.interaction.particles.links.js +4 -5
  43. package/tsparticles.interaction.particles.links.min.js +1 -1
  44. package/tsparticles.js +12 -13
  45. package/tsparticles.min.js +2 -2
  46. package/tsparticles.pathseg.min.js +1 -1
  47. package/tsparticles.plugins.absorbers.js +4 -5
  48. package/tsparticles.plugins.absorbers.min.js +1 -1
  49. package/tsparticles.plugins.emitters.js +12 -12
  50. package/tsparticles.plugins.emitters.min.js +2 -2
  51. package/tsparticles.plugins.polygonMask.js +4 -5
  52. package/tsparticles.plugins.polygonMask.min.js +1 -1
  53. package/tsparticles.shape.circle.min.js +1 -1
  54. package/tsparticles.shape.image.js +4 -5
  55. package/tsparticles.shape.image.min.js +1 -1
  56. package/tsparticles.shape.line.min.js +1 -1
  57. package/tsparticles.shape.polygon.min.js +1 -1
  58. package/tsparticles.shape.square.min.js +1 -1
  59. package/tsparticles.shape.star.min.js +1 -1
  60. package/tsparticles.shape.text.js +4 -5
  61. package/tsparticles.shape.text.min.js +1 -1
  62. package/tsparticles.slim.js +4 -6
  63. package/tsparticles.slim.min.js +2 -2
  64. package/tsparticles.updater.angle.js +4 -5
  65. package/tsparticles.updater.angle.min.js +1 -1
  66. package/tsparticles.updater.color.js +4 -5
  67. package/tsparticles.updater.color.min.js +1 -1
  68. package/tsparticles.updater.life.js +4 -5
  69. package/tsparticles.updater.life.min.js +1 -1
  70. package/tsparticles.updater.opacity.js +4 -5
  71. package/tsparticles.updater.opacity.min.js +1 -1
  72. package/tsparticles.updater.outModes.js +4 -5
  73. package/tsparticles.updater.outModes.min.js +1 -1
  74. package/tsparticles.updater.roll.js +4 -5
  75. package/tsparticles.updater.roll.min.js +1 -1
  76. package/tsparticles.updater.size.js +4 -6
  77. package/tsparticles.updater.size.min.js +2 -2
  78. package/tsparticles.updater.strokeColor.js +4 -5
  79. package/tsparticles.updater.strokeColor.min.js +1 -1
  80. package/tsparticles.updater.tilt.js +4 -5
  81. package/tsparticles.updater.tilt.min.js +1 -1
  82. package/tsparticles.updater.wobble.js +4 -5
  83. package/tsparticles.updater.wobble.min.js +1 -1
  84. package/umd/Core/Canvas.js +1 -4
  85. package/umd/Core/Particle.d.ts +1 -0
  86. package/umd/Core/Particle.js +1 -0
  87. package/umd/Core/Particles.js +2 -1
  88. package/umd/Plugins/Emitters/EmitterInstance.js +8 -7
  89. package/umd/Updaters/Size/SizeUpdater.js +0 -1
package/Core/Canvas.js CHANGED
@@ -98,10 +98,7 @@ class Canvas {
98
98
  const container = this.container;
99
99
  const pxRatio = container.retina.pixelRatio;
100
100
  const size = container.canvas.size;
101
- const oldSize = {
102
- width: size.width,
103
- height: size.height,
104
- };
101
+ const oldSize = Object.assign({}, size);
105
102
  size.width = this.element.offsetWidth * pxRatio;
106
103
  size.height = this.element.offsetHeight * pxRatio;
107
104
  this.element.width = size.width;
@@ -13,6 +13,7 @@ export declare class Particle implements IParticle {
13
13
  readonly container: Container;
14
14
  readonly group?: string | undefined;
15
15
  destroyed: boolean;
16
+ ignoresResizeRatio: boolean;
16
17
  lastPathTime: number;
17
18
  misplaced: boolean;
18
19
  spawning: boolean;
package/Core/Particle.js CHANGED
@@ -45,6 +45,7 @@ class Particle {
45
45
  this.retina = {
46
46
  maxDistance: {},
47
47
  };
48
+ this.ignoresResizeRatio = true;
48
49
  const pxRatio = container.retina.pixelRatio;
49
50
  const mainOptions = container.actualOptions;
50
51
  const particlesOptions = new ParticlesOptions_1.ParticlesOptions();
package/Core/Particles.js CHANGED
@@ -111,10 +111,11 @@ class Particles {
111
111
  }
112
112
  for (const particle of this.array) {
113
113
  const resizeFactor = container.canvas.resizeFactor;
114
- if (resizeFactor) {
114
+ if (resizeFactor && !particle.ignoresResizeRatio) {
115
115
  particle.position.x *= resizeFactor.width;
116
116
  particle.position.y *= resizeFactor.height;
117
117
  }
118
+ particle.ignoresResizeRatio = false;
118
119
  particle.bubble.inRange = false;
119
120
  for (const [, plugin] of this.container.plugins) {
120
121
  if (particle.destroyed) {
@@ -18,8 +18,8 @@ const Emitter_1 = require("./Options/Classes/Emitter");
18
18
  const EmitterSize_1 = require("./Options/Classes/EmitterSize");
19
19
  class EmitterInstance {
20
20
  constructor(engine, emitters, container, options, position) {
21
- var _a, _b, _c, _d, _e, _f;
22
- var _g;
21
+ var _a, _b, _c, _d, _e, _f, _g;
22
+ var _h;
23
23
  this.emitters = emitters;
24
24
  this.container = container;
25
25
  _EmitterInstance_firstSpawn.set(this, void 0);
@@ -38,22 +38,23 @@ class EmitterInstance {
38
38
  this.options.load(options);
39
39
  }
40
40
  this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
41
+ this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
41
42
  this.name = this.options.name;
42
- this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
43
+ this.shape = (_c = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _c === void 0 ? void 0 : _c.getShape(this.options.shape);
43
44
  this.fill = this.options.fill;
44
45
  __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
45
46
  __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
46
47
  let particlesOptions = (0, Utils_1.deepExtend)({}, this.options.particles);
47
48
  particlesOptions !== null && particlesOptions !== void 0 ? particlesOptions : (particlesOptions = {});
48
- (_c = particlesOptions.move) !== null && _c !== void 0 ? _c : (particlesOptions.move = {});
49
- (_d = (_g = particlesOptions.move).direction) !== null && _d !== void 0 ? _d : (_g.direction = this.options.direction);
49
+ (_d = particlesOptions.move) !== null && _d !== void 0 ? _d : (particlesOptions.move = {});
50
+ (_e = (_h = particlesOptions.move).direction) !== null && _e !== void 0 ? _e : (_h.direction = this.options.direction);
50
51
  if (this.options.spawnColor) {
51
52
  this.spawnColor = (0, Utils_1.colorToHsl)(this.options.spawnColor);
52
53
  }
53
54
  this.paused = !this.options.autoPlay;
54
55
  this.particlesOptions = particlesOptions;
55
56
  this.size =
56
- (_e = this.options.size) !== null && _e !== void 0 ? _e : (() => {
57
+ (_f = this.options.size) !== null && _f !== void 0 ? _f : (() => {
57
58
  const size = new EmitterSize_1.EmitterSize();
58
59
  size.load({
59
60
  height: 0,
@@ -62,7 +63,7 @@ class EmitterInstance {
62
63
  });
63
64
  return size;
64
65
  })();
65
- this.lifeCount = (_f = this.options.life.count) !== null && _f !== void 0 ? _f : -1;
66
+ this.lifeCount = (_g = this.options.life.count) !== null && _g !== void 0 ? _g : -1;
66
67
  this.immortal = this.lifeCount <= 0;
67
68
  this.play();
68
69
  }
@@ -48,7 +48,6 @@ function updateSize(particle, delta) {
48
48
  particle.size.loops++;
49
49
  }
50
50
  else {
51
- console.log("decreasing");
52
51
  particle.size.value -= sizeVelocity;
53
52
  }
54
53
  }
@@ -117,10 +117,7 @@ export class Canvas {
117
117
  const container = this.container;
118
118
  const pxRatio = container.retina.pixelRatio;
119
119
  const size = container.canvas.size;
120
- const oldSize = {
121
- width: size.width,
122
- height: size.height,
123
- };
120
+ const oldSize = Object.assign({}, size);
124
121
  size.width = this.element.offsetWidth * pxRatio;
125
122
  size.height = this.element.offsetHeight * pxRatio;
126
123
  this.element.width = size.width;
@@ -17,6 +17,7 @@ export declare class Particle implements IParticle {
17
17
  readonly container: Container;
18
18
  readonly group?: string | undefined;
19
19
  destroyed: boolean;
20
+ ignoresResizeRatio: boolean;
20
21
  lastPathTime: number;
21
22
  misplaced: boolean;
22
23
  spawning: boolean;
@@ -46,6 +46,7 @@ export class Particle {
46
46
  this.retina = {
47
47
  maxDistance: {},
48
48
  };
49
+ this.ignoresResizeRatio = true;
49
50
  const pxRatio = container.retina.pixelRatio;
50
51
  const mainOptions = container.actualOptions;
51
52
  const particlesOptions = new ParticlesOptions();
@@ -121,10 +121,11 @@ export class Particles {
121
121
  // p.vy = f * Math.sin(t);
122
122
  // }
123
123
  const resizeFactor = container.canvas.resizeFactor;
124
- if (resizeFactor) {
124
+ if (resizeFactor && !particle.ignoresResizeRatio) {
125
125
  particle.position.x *= resizeFactor.width;
126
126
  particle.position.y *= resizeFactor.height;
127
127
  }
128
+ particle.ignoresResizeRatio = false;
128
129
  particle.bubble.inRange = false;
129
130
  for (const [, plugin] of this.container.plugins) {
130
131
  if (particle.destroyed) {
@@ -18,8 +18,8 @@ import { EmitterSize } from "./Options/Classes/EmitterSize";
18
18
  */
19
19
  export class EmitterInstance {
20
20
  constructor(engine, emitters, container, options, position) {
21
- var _a, _b, _c, _d, _e, _f;
22
- var _g;
21
+ var _a, _b, _c, _d, _e, _f, _g;
22
+ var _h;
23
23
  this.emitters = emitters;
24
24
  this.container = container;
25
25
  _EmitterInstance_firstSpawn.set(this, void 0);
@@ -38,22 +38,23 @@ export class EmitterInstance {
38
38
  this.options.load(options);
39
39
  }
40
40
  this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
41
+ this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
41
42
  this.name = this.options.name;
42
- this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
43
+ this.shape = (_c = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _c === void 0 ? void 0 : _c.getShape(this.options.shape);
43
44
  this.fill = this.options.fill;
44
45
  __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
45
46
  __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
46
47
  let particlesOptions = deepExtend({}, this.options.particles);
47
48
  particlesOptions !== null && particlesOptions !== void 0 ? particlesOptions : (particlesOptions = {});
48
- (_c = particlesOptions.move) !== null && _c !== void 0 ? _c : (particlesOptions.move = {});
49
- (_d = (_g = particlesOptions.move).direction) !== null && _d !== void 0 ? _d : (_g.direction = this.options.direction);
49
+ (_d = particlesOptions.move) !== null && _d !== void 0 ? _d : (particlesOptions.move = {});
50
+ (_e = (_h = particlesOptions.move).direction) !== null && _e !== void 0 ? _e : (_h.direction = this.options.direction);
50
51
  if (this.options.spawnColor) {
51
52
  this.spawnColor = colorToHsl(this.options.spawnColor);
52
53
  }
53
54
  this.paused = !this.options.autoPlay;
54
55
  this.particlesOptions = particlesOptions;
55
56
  this.size =
56
- (_e = this.options.size) !== null && _e !== void 0 ? _e : (() => {
57
+ (_f = this.options.size) !== null && _f !== void 0 ? _f : (() => {
57
58
  const size = new EmitterSize();
58
59
  size.load({
59
60
  height: 0,
@@ -62,7 +63,7 @@ export class EmitterInstance {
62
63
  });
63
64
  return size;
64
65
  })();
65
- this.lifeCount = (_f = this.options.life.count) !== null && _f !== void 0 ? _f : -1;
66
+ this.lifeCount = (_g = this.options.life.count) !== null && _g !== void 0 ? _g : -1;
66
67
  this.immortal = this.lifeCount <= 0;
67
68
  this.play();
68
69
  }
@@ -45,7 +45,6 @@ function updateSize(particle, delta) {
45
45
  particle.size.loops++;
46
46
  }
47
47
  else {
48
- console.log("decreasing");
49
48
  particle.size.value -= sizeVelocity;
50
49
  }
51
50
  }
@@ -95,10 +95,7 @@ export class Canvas {
95
95
  const container = this.container;
96
96
  const pxRatio = container.retina.pixelRatio;
97
97
  const size = container.canvas.size;
98
- const oldSize = {
99
- width: size.width,
100
- height: size.height,
101
- };
98
+ const oldSize = Object.assign({}, size);
102
99
  size.width = this.element.offsetWidth * pxRatio;
103
100
  size.height = this.element.offsetHeight * pxRatio;
104
101
  this.element.width = size.width;
@@ -13,6 +13,7 @@ export declare class Particle implements IParticle {
13
13
  readonly container: Container;
14
14
  readonly group?: string | undefined;
15
15
  destroyed: boolean;
16
+ ignoresResizeRatio: boolean;
16
17
  lastPathTime: number;
17
18
  misplaced: boolean;
18
19
  spawning: boolean;
@@ -42,6 +42,7 @@ export class Particle {
42
42
  this.retina = {
43
43
  maxDistance: {},
44
44
  };
45
+ this.ignoresResizeRatio = true;
45
46
  const pxRatio = container.retina.pixelRatio;
46
47
  const mainOptions = container.actualOptions;
47
48
  const particlesOptions = new ParticlesOptions();
@@ -108,10 +108,11 @@ export class Particles {
108
108
  }
109
109
  for (const particle of this.array) {
110
110
  const resizeFactor = container.canvas.resizeFactor;
111
- if (resizeFactor) {
111
+ if (resizeFactor && !particle.ignoresResizeRatio) {
112
112
  particle.position.x *= resizeFactor.width;
113
113
  particle.position.y *= resizeFactor.height;
114
114
  }
115
+ particle.ignoresResizeRatio = false;
115
116
  particle.bubble.inRange = false;
116
117
  for (const [, plugin] of this.container.plugins) {
117
118
  if (particle.destroyed) {
@@ -15,8 +15,8 @@ import { Emitter } from "./Options/Classes/Emitter";
15
15
  import { EmitterSize } from "./Options/Classes/EmitterSize";
16
16
  export class EmitterInstance {
17
17
  constructor(engine, emitters, container, options, position) {
18
- var _a, _b, _c, _d, _e, _f;
19
- var _g;
18
+ var _a, _b, _c, _d, _e, _f, _g;
19
+ var _h;
20
20
  this.emitters = emitters;
21
21
  this.container = container;
22
22
  _EmitterInstance_firstSpawn.set(this, void 0);
@@ -35,22 +35,23 @@ export class EmitterInstance {
35
35
  this.options.load(options);
36
36
  }
37
37
  this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
38
+ this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
38
39
  this.name = this.options.name;
39
- this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
40
+ this.shape = (_c = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _c === void 0 ? void 0 : _c.getShape(this.options.shape);
40
41
  this.fill = this.options.fill;
41
42
  __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
42
43
  __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
43
44
  let particlesOptions = deepExtend({}, this.options.particles);
44
45
  particlesOptions !== null && particlesOptions !== void 0 ? particlesOptions : (particlesOptions = {});
45
- (_c = particlesOptions.move) !== null && _c !== void 0 ? _c : (particlesOptions.move = {});
46
- (_d = (_g = particlesOptions.move).direction) !== null && _d !== void 0 ? _d : (_g.direction = this.options.direction);
46
+ (_d = particlesOptions.move) !== null && _d !== void 0 ? _d : (particlesOptions.move = {});
47
+ (_e = (_h = particlesOptions.move).direction) !== null && _e !== void 0 ? _e : (_h.direction = this.options.direction);
47
48
  if (this.options.spawnColor) {
48
49
  this.spawnColor = colorToHsl(this.options.spawnColor);
49
50
  }
50
51
  this.paused = !this.options.autoPlay;
51
52
  this.particlesOptions = particlesOptions;
52
53
  this.size =
53
- (_e = this.options.size) !== null && _e !== void 0 ? _e : (() => {
54
+ (_f = this.options.size) !== null && _f !== void 0 ? _f : (() => {
54
55
  const size = new EmitterSize();
55
56
  size.load({
56
57
  height: 0,
@@ -59,7 +60,7 @@ export class EmitterInstance {
59
60
  });
60
61
  return size;
61
62
  })();
62
- this.lifeCount = (_f = this.options.life.count) !== null && _f !== void 0 ? _f : -1;
63
+ this.lifeCount = (_g = this.options.life.count) !== null && _g !== void 0 ? _g : -1;
63
64
  this.immortal = this.lifeCount <= 0;
64
65
  this.play();
65
66
  }
@@ -45,7 +45,6 @@ function updateSize(particle, delta) {
45
45
  particle.size.loops++;
46
46
  }
47
47
  else {
48
- console.log("decreasing");
49
48
  particle.size.value -= sizeVelocity;
50
49
  }
51
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsparticles",
3
- "version": "1.41.3",
3
+ "version": "1.41.6",
4
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.",
5
5
  "homepage": "https://particles.js.org/",
6
6
  "scripts": {