tsparticles 2.8.0 → 2.9.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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v2.8.0
7
+ * v2.9.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -1236,9 +1236,7 @@ class Canvas {
1236
1236
  } else {
1237
1237
  this._resetOriginalStyle();
1238
1238
  }
1239
- this.draw(ctx => {
1240
- clear(ctx, this.size);
1241
- });
1239
+ this.stop();
1242
1240
  this._preDrawUpdaters = [];
1243
1241
  this._postDrawUpdaters = [];
1244
1242
  this._resizePlugins = [];
@@ -1427,6 +1425,11 @@ class Canvas {
1427
1425
  };
1428
1426
  }
1429
1427
  }
1428
+ stop() {
1429
+ this.draw(ctx => {
1430
+ clear(ctx, this.size);
1431
+ });
1432
+ }
1430
1433
  async windowResize() {
1431
1434
  if (!this.element) {
1432
1435
  return;
@@ -3114,7 +3117,7 @@ class ParticlesNumber {
3114
3117
  constructor() {
3115
3118
  this.density = new ParticlesDensity();
3116
3119
  this.limit = 0;
3117
- this.value = 100;
3120
+ this.value = 0;
3118
3121
  }
3119
3122
  get max() {
3120
3123
  return this.limit;
@@ -4953,7 +4956,7 @@ class Container {
4953
4956
  this._eventListeners.removeListeners();
4954
4957
  this.pause();
4955
4958
  this.particles.clear();
4956
- this.canvas.clear();
4959
+ this.canvas.stop();
4957
4960
  if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
4958
4961
  this._intersectionObserver.unobserve(this.interactivity.element);
4959
4962
  }
@@ -5271,6 +5274,9 @@ class Engine {
5271
5274
  this._loader = new Loader(this);
5272
5275
  this.plugins = new Plugins(this);
5273
5276
  }
5277
+ get version() {
5278
+ return "2.9.0";
5279
+ }
5274
5280
  addEventListener(type, listener) {
5275
5281
  this._eventDispatcher.addEventListener(type, listener);
5276
5282
  }
@@ -6062,9 +6068,13 @@ class Split {
6062
6068
  this.sizeOffset = true;
6063
6069
  }
6064
6070
  load(data) {
6071
+ var _a;
6065
6072
  if (!data) {
6066
6073
  return;
6067
6074
  }
6075
+ if (data.color !== undefined) {
6076
+ this.color = OptionsColor.create(this.color, data.color);
6077
+ }
6068
6078
  if (data.count !== undefined) {
6069
6079
  this.count = data.count;
6070
6080
  }
@@ -6076,6 +6086,18 @@ class Split {
6076
6086
  if (data.sizeOffset !== undefined) {
6077
6087
  this.sizeOffset = data.sizeOffset;
6078
6088
  }
6089
+ if (data.colorOffset) {
6090
+ this.colorOffset = (_a = this.colorOffset) !== null && _a !== void 0 ? _a : {};
6091
+ if (data.colorOffset.h !== undefined) {
6092
+ this.colorOffset.h = data.colorOffset.h;
6093
+ }
6094
+ if (data.colorOffset.s !== undefined) {
6095
+ this.colorOffset.s = data.colorOffset.s;
6096
+ }
6097
+ if (data.colorOffset.l !== undefined) {
6098
+ this.colorOffset.l = data.colorOffset.l;
6099
+ }
6100
+ }
6079
6101
  }
6080
6102
  }
6081
6103
  ;// CONCATENATED MODULE: ../../updaters/destroy/dist/esm/Options/Classes/Destroy.js
@@ -6167,18 +6189,34 @@ class DestroyUpdater {
6167
6189
  }
6168
6190
  }
6169
6191
  addSplitParticle(parent, splitParticlesOptions) {
6192
+ var _a, _b, _c;
6170
6193
  const destroyOptions = parent.options.destroy;
6171
6194
  if (!destroyOptions) {
6172
6195
  return;
6173
6196
  }
6174
6197
  const splitOptions = destroyOptions.split,
6175
6198
  options = loadParticlesOptions(this.engine, this.container, parent.options),
6176
- factor = getValue(splitOptions.factor);
6177
- options.color.load({
6178
- value: {
6179
- hsl: parent.getFillColor()
6180
- }
6181
- });
6199
+ factor = getValue(splitOptions.factor),
6200
+ parentColor = parent.getFillColor();
6201
+ if (splitOptions.color) {
6202
+ options.color.load(splitOptions.color);
6203
+ } else if (splitOptions.colorOffset && parentColor) {
6204
+ options.color.load({
6205
+ value: {
6206
+ hsl: {
6207
+ h: parentColor.h + getRangeValue((_a = splitOptions.colorOffset.h) !== null && _a !== void 0 ? _a : 0),
6208
+ s: parentColor.s + getRangeValue((_b = splitOptions.colorOffset.s) !== null && _b !== void 0 ? _b : 0),
6209
+ l: parentColor.l + getRangeValue((_c = splitOptions.colorOffset.l) !== null && _c !== void 0 ? _c : 0)
6210
+ }
6211
+ }
6212
+ });
6213
+ } else {
6214
+ options.color.load({
6215
+ value: {
6216
+ hsl: parent.getFillColor()
6217
+ }
6218
+ });
6219
+ }
6182
6220
  options.move.load({
6183
6221
  center: {
6184
6222
  x: parent.position.x,
@@ -6268,7 +6306,7 @@ class EmitterLife {
6268
6306
  this.wait = false;
6269
6307
  }
6270
6308
  load(data) {
6271
- if (data === undefined) {
6309
+ if (!data) {
6272
6310
  return;
6273
6311
  }
6274
6312
  if (data.count !== undefined) {
@@ -6341,14 +6379,14 @@ class Emitter {
6341
6379
  this.startCount = 0;
6342
6380
  }
6343
6381
  load(data) {
6344
- if (data === undefined) {
6382
+ if (!data) {
6345
6383
  return;
6346
6384
  }
6347
6385
  if (data.autoPlay !== undefined) {
6348
6386
  this.autoPlay = data.autoPlay;
6349
6387
  }
6350
6388
  if (data.size !== undefined) {
6351
- if (this.size === undefined) {
6389
+ if (!this.size) {
6352
6390
  this.size = new EmitterSize();
6353
6391
  }
6354
6392
  this.size.load(data.size);