@tsparticles/pjs 3.0.0-beta.4 → 3.0.0-beta.5

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
- * v3.0.0-beta.4
7
+ * v3.0.0-beta.5
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -2403,11 +2403,7 @@ class Events {
2403
2403
  });
2404
2404
  }
2405
2405
  this.onHover.load(data.onHover);
2406
- if (isBoolean(data.resize)) {
2407
- this.resize.enable = data.resize;
2408
- } else {
2409
- this.resize.load(data.resize);
2410
- }
2406
+ this.resize.load(data.resize);
2411
2407
  }
2412
2408
  }
2413
2409
  ;// CONCATENATED MODULE: ../../engine/dist/browser/Options/Classes/Interactivity/Modes/Modes.js
@@ -3432,23 +3428,26 @@ class ParticlesOptions {
3432
3428
  if (!data) {
3433
3429
  return;
3434
3430
  }
3435
- this.bounce.load(data.bounce);
3436
- this.color.load(AnimatableColor.create(this.color, data.color));
3437
- this.effect.load(data.effect);
3438
3431
  if (data.groups !== undefined) {
3439
- for (const group in data.groups) {
3432
+ for (const group of Object.keys(data.groups)) {
3433
+ if (!Object.hasOwn(data.groups, group)) {
3434
+ continue;
3435
+ }
3440
3436
  const item = data.groups[group];
3441
3437
  if (item !== undefined) {
3442
3438
  this.groups[group] = deepExtend(this.groups[group] ?? {}, item);
3443
3439
  }
3444
3440
  }
3445
3441
  }
3446
- this.move.load(data.move);
3447
- this.number.load(data.number);
3448
- this.opacity.load(data.opacity);
3449
3442
  if (data.reduceDuplicates !== undefined) {
3450
3443
  this.reduceDuplicates = data.reduceDuplicates;
3451
3444
  }
3445
+ this.bounce.load(data.bounce);
3446
+ this.color.load(AnimatableColor.create(this.color, data.color));
3447
+ this.effect.load(data.effect);
3448
+ this.move.load(data.move);
3449
+ this.number.load(data.number);
3450
+ this.opacity.load(data.opacity);
3452
3451
  this.shape.load(data.shape);
3453
3452
  this.size.load(data.size);
3454
3453
  this.shadow.load(data.shadow);
@@ -3873,7 +3872,9 @@ class Particle {
3873
3872
  this.bubble.inRange = false;
3874
3873
  this.slow.inRange = false;
3875
3874
  const container = this.container,
3876
- pathGenerator = this.pathGenerator;
3875
+ pathGenerator = this.pathGenerator,
3876
+ shapeDrawer = container.shapeDrawers.get(this.shape);
3877
+ shapeDrawer && shapeDrawer.particleDestroy && shapeDrawer.particleDestroy(this);
3877
3878
  for (const [, plugin] of container.plugins) {
3878
3879
  plugin.particleDestroyed && plugin.particleDestroyed(this, override);
3879
3880
  }
@@ -5127,7 +5128,7 @@ class Engine {
5127
5128
  return res;
5128
5129
  }
5129
5130
  get version() {
5130
- return "3.0.0-beta.4";
5131
+ return "3.0.0-beta.5";
5131
5132
  }
5132
5133
  addConfig(config) {
5133
5134
  const name = config.name ?? "default";
@@ -5625,11 +5626,248 @@ class Particles_Particles {
5625
5626
  }
5626
5627
  }
5627
5628
  ;// CONCATENATED MODULE: ./dist/browser/VincentGarreau/particles.js
5629
+
5630
+ const defaultPjsOptions = {
5631
+ particles: {
5632
+ number: {
5633
+ value: 400,
5634
+ density: {
5635
+ enable: true,
5636
+ value_area: 800
5637
+ }
5638
+ },
5639
+ color: {
5640
+ value: "#fff"
5641
+ },
5642
+ shape: {
5643
+ type: "circle",
5644
+ stroke: {
5645
+ width: 0,
5646
+ color: "#ff0000"
5647
+ },
5648
+ polygon: {
5649
+ nb_sides: 5
5650
+ },
5651
+ image: {
5652
+ src: "",
5653
+ width: 100,
5654
+ height: 100
5655
+ }
5656
+ },
5657
+ opacity: {
5658
+ value: 1,
5659
+ random: false,
5660
+ anim: {
5661
+ enable: false,
5662
+ speed: 2,
5663
+ opacity_min: 0,
5664
+ sync: false
5665
+ }
5666
+ },
5667
+ size: {
5668
+ value: 20,
5669
+ random: false,
5670
+ anim: {
5671
+ enable: false,
5672
+ speed: 20,
5673
+ size_min: 0,
5674
+ sync: false
5675
+ }
5676
+ },
5677
+ line_linked: {
5678
+ enable: true,
5679
+ distance: 100,
5680
+ color: "#fff",
5681
+ opacity: 1,
5682
+ width: 1
5683
+ },
5684
+ move: {
5685
+ enable: true,
5686
+ speed: 2,
5687
+ direction: "none",
5688
+ random: false,
5689
+ straight: false,
5690
+ out_mode: "out",
5691
+ bounce: false,
5692
+ attract: {
5693
+ enable: false,
5694
+ rotateX: 3000,
5695
+ rotateY: 3000
5696
+ }
5697
+ }
5698
+ },
5699
+ interactivity: {
5700
+ detect_on: "canvas",
5701
+ events: {
5702
+ onhover: {
5703
+ enable: true,
5704
+ mode: "grab"
5705
+ },
5706
+ onclick: {
5707
+ enable: true,
5708
+ mode: "push"
5709
+ },
5710
+ resize: true
5711
+ },
5712
+ modes: {
5713
+ grab: {
5714
+ distance: 100,
5715
+ line_linked: {
5716
+ opacity: 1
5717
+ }
5718
+ },
5719
+ bubble: {
5720
+ distance: 200,
5721
+ size: 80,
5722
+ duration: 0.4,
5723
+ opacity: 1,
5724
+ speed: 3
5725
+ },
5726
+ repulse: {
5727
+ distance: 200,
5728
+ duration: 0.4
5729
+ },
5730
+ push: {
5731
+ particles_nb: 4
5732
+ },
5733
+ remove: {
5734
+ particles_nb: 2
5735
+ }
5736
+ }
5737
+ },
5738
+ retina_detect: false
5739
+ };
5628
5740
  const initParticlesJS = engine => {
5629
5741
  const particlesJS = (tagId, options) => {
5742
+ const fixedOptions = deepExtend(defaultPjsOptions, options);
5630
5743
  return engine.load({
5631
5744
  id: tagId,
5632
- options
5745
+ options: {
5746
+ fullScreen: {
5747
+ enable: false
5748
+ },
5749
+ detectRetina: fixedOptions.retina_detect,
5750
+ smooth: true,
5751
+ interactivity: {
5752
+ detectsOn: fixedOptions.interactivity.detect_on,
5753
+ events: {
5754
+ onHover: {
5755
+ enable: fixedOptions.interactivity.events.onhover.enable,
5756
+ mode: fixedOptions.interactivity.events.onhover.mode
5757
+ },
5758
+ onClick: {
5759
+ enable: fixedOptions.interactivity.events.onclick.enable,
5760
+ mode: fixedOptions.interactivity.events.onclick.mode
5761
+ },
5762
+ resize: {
5763
+ enable: fixedOptions.interactivity.events.resize
5764
+ }
5765
+ },
5766
+ modes: {
5767
+ grab: {
5768
+ distance: fixedOptions.interactivity.modes.grab.distance,
5769
+ links: {
5770
+ opacity: fixedOptions.interactivity.modes.grab.line_linked.opacity
5771
+ }
5772
+ },
5773
+ bubble: {
5774
+ distance: fixedOptions.interactivity.modes.bubble.distance,
5775
+ size: fixedOptions.interactivity.modes.bubble.size,
5776
+ duration: fixedOptions.interactivity.modes.bubble.duration,
5777
+ opacity: fixedOptions.interactivity.modes.bubble.opacity,
5778
+ speed: fixedOptions.interactivity.modes.bubble.speed
5779
+ },
5780
+ repulse: {
5781
+ distance: fixedOptions.interactivity.modes.repulse.distance,
5782
+ duration: fixedOptions.interactivity.modes.repulse.duration
5783
+ },
5784
+ push: {
5785
+ quantity: fixedOptions.interactivity.modes.push.particles_nb
5786
+ },
5787
+ remove: {
5788
+ quantity: fixedOptions.interactivity.modes.remove.particles_nb
5789
+ }
5790
+ }
5791
+ },
5792
+ particles: {
5793
+ collisions: {
5794
+ enable: fixedOptions.particles.move.bounce
5795
+ },
5796
+ number: {
5797
+ value: fixedOptions.particles.number.value,
5798
+ density: {
5799
+ enable: fixedOptions.particles.number.density.enable,
5800
+ width: fixedOptions.particles.number.density.value_area
5801
+ }
5802
+ },
5803
+ color: {
5804
+ value: fixedOptions.particles.color.value
5805
+ },
5806
+ stroke: {
5807
+ width: fixedOptions.particles.shape.stroke.width,
5808
+ color: {
5809
+ value: fixedOptions.particles.shape.stroke.color
5810
+ }
5811
+ },
5812
+ shape: {
5813
+ type: fixedOptions.particles.shape.type,
5814
+ options: {
5815
+ polygon: {
5816
+ sides: fixedOptions.particles.shape.polygon.nb_sides
5817
+ },
5818
+ image: {
5819
+ src: fixedOptions.particles.shape.image.src,
5820
+ width: fixedOptions.particles.shape.image.width,
5821
+ height: fixedOptions.particles.shape.image.height
5822
+ }
5823
+ }
5824
+ },
5825
+ opacity: {
5826
+ value: fixedOptions.particles.opacity.random ? {
5827
+ min: fixedOptions.particles.opacity.anim.enable ? fixedOptions.particles.opacity.anim.opacity_min : 0,
5828
+ max: fixedOptions.particles.opacity.value
5829
+ } : fixedOptions.particles.opacity.value,
5830
+ animation: {
5831
+ enable: fixedOptions.particles.opacity.anim.enable,
5832
+ speed: fixedOptions.particles.opacity.anim.speed,
5833
+ sync: fixedOptions.particles.opacity.anim.sync
5834
+ }
5835
+ },
5836
+ size: {
5837
+ value: fixedOptions.particles.size.random ? {
5838
+ min: fixedOptions.particles.size.anim.enable ? fixedOptions.particles.size.anim.size_min : 0,
5839
+ max: fixedOptions.particles.size.value
5840
+ } : fixedOptions.particles.size.value,
5841
+ animation: {
5842
+ enable: fixedOptions.particles.size.anim.enable,
5843
+ speed: fixedOptions.particles.size.anim.speed,
5844
+ sync: fixedOptions.particles.size.anim.sync
5845
+ }
5846
+ },
5847
+ links: {
5848
+ enable: fixedOptions.particles.line_linked.enable,
5849
+ distance: fixedOptions.particles.line_linked.distance,
5850
+ color: fixedOptions.particles.line_linked.color,
5851
+ opacity: fixedOptions.particles.line_linked.opacity,
5852
+ width: fixedOptions.particles.line_linked.width
5853
+ },
5854
+ move: {
5855
+ enable: fixedOptions.particles.move.enable,
5856
+ speed: fixedOptions.particles.move.speed / 3,
5857
+ direction: fixedOptions.particles.move.direction,
5858
+ random: fixedOptions.particles.move.random,
5859
+ straight: fixedOptions.particles.move.straight,
5860
+ outModes: fixedOptions.particles.move.out_mode,
5861
+ attract: {
5862
+ enable: fixedOptions.particles.move.attract.enable,
5863
+ rotate: {
5864
+ x: fixedOptions.particles.move.attract.rotateX,
5865
+ y: fixedOptions.particles.move.attract.rotateY
5866
+ }
5867
+ }
5868
+ }
5869
+ }
5870
+ }
5633
5871
  });
5634
5872
  };
5635
5873
  particlesJS.load = (tagId, pathConfigJson, callback) => {