@tsparticles/preset-links 4.5.0 → 4.5.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.
@@ -1,6 +1,6 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
2
  (function (g) {
3
- /* Preset v4.5.0 */
3
+ /* Preset v4.5.1 */
4
4
  g.__tsParticlesInternals = g.__tsParticlesInternals || {};
5
5
  g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6
6
  (function (exports) {
@@ -657,12 +657,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
657
657
  }
658
658
  addEventListener(type, listener) {
659
659
  this.removeEventListener(type, listener);
660
- let arr = this.#listeners.get(type);
661
- if (!arr) {
662
- arr = [];
663
- this.#listeners.set(type, arr);
664
- }
665
- arr.push(listener);
660
+ const arr = this.#listeners.get(type);
661
+ this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
666
662
  }
667
663
  dispatchEvent(type, args) {
668
664
  const listeners = this.#listeners.get(type);
@@ -694,7 +690,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
694
690
  this.#listeners.delete(type);
695
691
  }
696
692
  else {
697
- arr.splice(idx, deleteCount);
693
+ this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
698
694
  }
699
695
  }
700
696
  }
@@ -875,7 +871,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
875
871
  return this.#domArray;
876
872
  }
877
873
  get version() {
878
- return "4.5.0";
874
+ return "4.5.1";
879
875
  }
880
876
  addEventListener(type, listener) {
881
877
  this.#eventDispatcher.addEventListener(type, listener);
@@ -2355,7 +2351,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2355
2351
  }
2356
2352
 
2357
2353
  async function loadBlendPlugin(engine) {
2358
- engine.checkVersion("4.5.0");
2354
+ engine.checkVersion("4.5.1");
2359
2355
  await engine.pluginManager.register(e => {
2360
2356
  e.pluginManager.addPlugin(new BlendPlugin());
2361
2357
  });
@@ -2392,7 +2388,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2392
2388
  }
2393
2389
 
2394
2390
  async function loadCircleShape(engine) {
2395
- engine.checkVersion("4.5.0");
2391
+ engine.checkVersion("4.5.1");
2396
2392
  await engine.pluginManager.register(e => {
2397
2393
  e.pluginManager.addShape(["circle"], () => {
2398
2394
  return Promise.resolve(new CircleDrawer());
@@ -2440,7 +2436,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2440
2436
  }
2441
2437
 
2442
2438
  async function loadHexColorPlugin(engine) {
2443
- engine.checkVersion("4.5.0");
2439
+ engine.checkVersion("4.5.1");
2444
2440
  await engine.pluginManager.register(e => {
2445
2441
  e.pluginManager.addColorManager("hex", new HexColorManager());
2446
2442
  });
@@ -2493,7 +2489,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2493
2489
  }
2494
2490
 
2495
2491
  async function loadHslColorPlugin(engine) {
2496
- engine.checkVersion("4.5.0");
2492
+ engine.checkVersion("4.5.1");
2497
2493
  await engine.pluginManager.register(e => {
2498
2494
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2499
2495
  });
@@ -2525,7 +2521,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2525
2521
  }
2526
2522
 
2527
2523
  async function loadMovePlugin(engine) {
2528
- engine.checkVersion("4.5.0");
2524
+ engine.checkVersion("4.5.1");
2529
2525
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
2530
2526
  addErrorMessages(ErrorMessages$1);
2531
2527
  }
@@ -2735,7 +2731,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2735
2731
  }
2736
2732
 
2737
2733
  async function loadOpacityUpdater(engine) {
2738
- engine.checkVersion("4.5.0");
2734
+ engine.checkVersion("4.5.1");
2739
2735
  await engine.pluginManager.register(e => {
2740
2736
  e.pluginManager.addParticleUpdater("opacity", container => {
2741
2737
  return Promise.resolve(new OpacityUpdater(container));
@@ -3064,7 +3060,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3064
3060
  }
3065
3061
 
3066
3062
  async function loadOutModesUpdater(engine) {
3067
- engine.checkVersion("4.5.0");
3063
+ engine.checkVersion("4.5.1");
3068
3064
  await engine.pluginManager.register(e => {
3069
3065
  e.pluginManager.addParticleUpdater("outModes", container => {
3070
3066
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3143,7 +3139,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3143
3139
  }
3144
3140
 
3145
3141
  async function loadPaintUpdater(engine) {
3146
- engine.checkVersion("4.5.0");
3142
+ engine.checkVersion("4.5.1");
3147
3143
  await engine.pluginManager.register(e => {
3148
3144
  e.pluginManager.addParticleUpdater("paint", container => {
3149
3145
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3198,7 +3194,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3198
3194
  }
3199
3195
 
3200
3196
  async function loadRgbColorPlugin(engine) {
3201
- engine.checkVersion("4.5.0");
3197
+ engine.checkVersion("4.5.1");
3202
3198
  await engine.pluginManager.register(e => {
3203
3199
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3204
3200
  });
@@ -3283,7 +3279,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3283
3279
  }
3284
3280
 
3285
3281
  async function loadSizeUpdater(engine) {
3286
- engine.checkVersion("4.5.0");
3282
+ engine.checkVersion("4.5.1");
3287
3283
  await engine.pluginManager.register(e => {
3288
3284
  e.pluginManager.addParticleUpdater("size", container => {
3289
3285
  return Promise.resolve(new SizeUpdater(container));
@@ -3292,7 +3288,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3292
3288
  }
3293
3289
 
3294
3290
  async function loadBasic(engine) {
3295
- engine.checkVersion("4.5.0");
3291
+ engine.checkVersion("4.5.1");
3296
3292
  await engine.pluginManager.register(async (e) => {
3297
3293
  await Promise.all([
3298
3294
  loadBlendPlugin(e),
@@ -3498,7 +3494,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3498
3494
  const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
3499
3495
 
3500
3496
  async function loadInteractivityPlugin(engine) {
3501
- engine.checkVersion("4.5.0");
3497
+ engine.checkVersion("4.5.1");
3502
3498
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3503
3499
  addErrorMessages(ErrorMessages);
3504
3500
  }
@@ -3578,6 +3574,30 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3578
3574
  }
3579
3575
  return false;
3580
3576
  }
3577
+ query(grid) {
3578
+ const { x, y } = this.position, { width, height } = this.#canvasSize, radius = this.radius, crossesLeft = x - radius <= originPoint.x, crossesRight = x + radius >= width, crossesTop = y - radius <= originPoint.y, crossesBottom = y + radius >= height;
3579
+ if (!crossesLeft && !crossesRight && !crossesTop && !crossesBottom) {
3580
+ return grid.query(this);
3581
+ }
3582
+ const xShifts = [originPoint.x], yShifts = [originPoint.y];
3583
+ if (crossesLeft)
3584
+ xShifts.push(width);
3585
+ if (crossesRight)
3586
+ xShifts.push(-width);
3587
+ if (crossesTop)
3588
+ yShifts.push(height);
3589
+ if (crossesBottom)
3590
+ yShifts.push(-height);
3591
+ const particles = new Set();
3592
+ for (const dx of xShifts) {
3593
+ for (const dy of yShifts) {
3594
+ for (const particle of grid.queryCircle({ x: x + dx, y: y + dy }, radius)) {
3595
+ particles.add(particle);
3596
+ }
3597
+ }
3598
+ }
3599
+ return [...particles];
3600
+ }
3581
3601
  }
3582
3602
 
3583
3603
  class LinksShadow {
@@ -3687,7 +3707,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3687
3707
  if (pos1.x < originPoint.x || pos1.y < originPoint.y || pos1.x > canvasSize.width || pos1.y > canvasSize.height) {
3688
3708
  return;
3689
3709
  }
3690
- const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp, range = warp ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize) : new Circle(pos1.x, pos1.y, optDistance), query = container.particles.grid.query(range);
3710
+ const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp, query = (warp
3711
+ ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize).query(container.particles.grid)
3712
+ : container.particles.grid.queryCircle(pos1, optDistance));
3691
3713
  for (const p2 of query) {
3692
3714
  const linkOpt2 = p2.options.links;
3693
3715
  if (p1 === p2 ||
@@ -3775,7 +3797,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3775
3797
  }
3776
3798
 
3777
3799
  async function loadParticlesLinksInteraction(engine) {
3778
- engine.checkVersion("4.5.0");
3800
+ engine.checkVersion("4.5.1");
3779
3801
  await engine.pluginManager.register((e) => {
3780
3802
  const pluginManager = e.pluginManager;
3781
3803
  ensureInteractivityPluginLoaded(e);
@@ -4755,6 +4777,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4755
4777
  this.#manageListeners(true);
4756
4778
  }
4757
4779
  removeListeners() {
4780
+ if (this.#resizeTimeout !== undefined) {
4781
+ clearTimeout(this.#resizeTimeout);
4782
+ this.#resizeTimeout = undefined;
4783
+ }
4758
4784
  this.#manageListeners(false);
4759
4785
  }
4760
4786
  #handleVisibilityChange() {
@@ -5409,14 +5435,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5409
5435
  return out;
5410
5436
  }
5411
5437
  queryCircle(position, radius, check, out = []) {
5412
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5413
- this.#releaseShapes();
5414
- return result;
5438
+ const circle = this.#acquireCircle(position.x, position.y, radius);
5439
+ try {
5440
+ return this.query(circle, check, out);
5441
+ }
5442
+ finally {
5443
+ this.#circlePoolIdx--;
5444
+ }
5415
5445
  }
5416
5446
  queryRectangle(position, size, check, out = []) {
5417
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5418
- this.#releaseShapes();
5419
- return result;
5447
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
5448
+ try {
5449
+ return this.query(rect, check, out);
5450
+ }
5451
+ finally {
5452
+ this.#rectanglePoolIdx--;
5453
+ }
5420
5454
  }
5421
5455
  #acquireCircle(x, y, r) {
5422
5456
  const idx = this.#circlePoolIdx++;
@@ -5475,10 +5509,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5475
5509
  }
5476
5510
  }
5477
5511
  }
5478
- #releaseShapes() {
5479
- this.#circlePoolIdx = 0;
5480
- this.#rectanglePoolIdx = 0;
5481
- }
5482
5512
  }
5483
5513
 
5484
5514
  class ParticlesManager {
@@ -6026,6 +6056,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6026
6056
  started;
6027
6057
  zLayers;
6028
6058
  #delay;
6059
+ #delayResolve;
6029
6060
  #delayTimeout;
6030
6061
  #delta = { value: 0, factor: 0 };
6031
6062
  #dispatchCallback;
@@ -6264,7 +6295,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6264
6295
  await this.init();
6265
6296
  this.started = true;
6266
6297
  await new Promise(resolve => {
6298
+ this.#delayResolve = resolve;
6267
6299
  const start = async () => {
6300
+ this.#delayTimeout = undefined;
6301
+ this.#delayResolve = undefined;
6268
6302
  this.#eventListeners.addListeners();
6269
6303
  for (const plugin of this.plugins) {
6270
6304
  await plugin.start?.();
@@ -6280,9 +6314,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6280
6314
  if (!guardCheck(this) || !this.started) {
6281
6315
  return;
6282
6316
  }
6283
- if (this.#delayTimeout) {
6317
+ if (this.#delayTimeout !== undefined) {
6284
6318
  clearTimeout(this.#delayTimeout);
6285
6319
  this.#delayTimeout = undefined;
6320
+ this.#delayResolve?.();
6321
+ this.#delayResolve = undefined;
6286
6322
  }
6287
6323
  this.#firstStart = true;
6288
6324
  this.started = false;
@@ -6716,7 +6752,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6716
6752
  manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
6717
6753
  manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
6718
6754
  manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
6719
- manageListener(interactivityEl, touchEndEvent, options.interactivity?.events.onClick.enable ? handlers.touchEndClick : handlers.touchEnd, add);
6755
+ const onClickEnabled = !!options.interactivity?.events.onClick.enable;
6756
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add && onClickEnabled);
6757
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add && !onClickEnabled);
6720
6758
  manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
6721
6759
  manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
6722
6760
  manageListener(interactivityEl, mouseLeaveEvent, handlers.mouseLeave, add);