tsparticles 3.0.0-beta.2 → 3.0.0-beta.3
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.
- package/package.json +11 -11
- package/report.html +2 -2
- package/tsparticles.bundle.js +130 -83
- package/tsparticles.bundle.min.js +1 -1
- package/tsparticles.bundle.min.js.LICENSE.txt +1 -1
- package/tsparticles.js +1 -1
- package/tsparticles.min.js.LICENSE.txt +1 -1
package/tsparticles.bundle.js
CHANGED
|
@@ -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.
|
|
7
|
+
* v3.0.0-beta.3
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -207,6 +207,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
207
207
|
rectBounce: () => (/* reexport */ rectBounce),
|
|
208
208
|
resizeEvent: () => (/* reexport */ resizeEvent),
|
|
209
209
|
rgbToHsl: () => (/* reexport */ rgbToHsl),
|
|
210
|
+
safeIntersectionObserver: () => (/* reexport */ safeIntersectionObserver),
|
|
210
211
|
safeMatchMedia: () => (/* reexport */ safeMatchMedia),
|
|
211
212
|
safeMutationObserver: () => (/* reexport */ safeMutationObserver),
|
|
212
213
|
setLogger: () => (/* reexport */ setLogger),
|
|
@@ -573,6 +574,12 @@ function safeMatchMedia(query) {
|
|
|
573
574
|
}
|
|
574
575
|
return matchMedia(query);
|
|
575
576
|
}
|
|
577
|
+
function safeIntersectionObserver(callback) {
|
|
578
|
+
if (isSsr() || typeof IntersectionObserver === "undefined") {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
return new IntersectionObserver(callback);
|
|
582
|
+
}
|
|
576
583
|
function safeMutationObserver(callback) {
|
|
577
584
|
if (isSsr() || typeof MutationObserver === "undefined") {
|
|
578
585
|
return;
|
|
@@ -1232,7 +1239,15 @@ function drawParticle(data) {
|
|
|
1232
1239
|
if (colorStyles.stroke) {
|
|
1233
1240
|
context.strokeStyle = colorStyles.stroke;
|
|
1234
1241
|
}
|
|
1235
|
-
|
|
1242
|
+
const drawData = {
|
|
1243
|
+
container,
|
|
1244
|
+
context,
|
|
1245
|
+
particle,
|
|
1246
|
+
radius,
|
|
1247
|
+
opacity,
|
|
1248
|
+
delta
|
|
1249
|
+
};
|
|
1250
|
+
drawShape(drawData);
|
|
1236
1251
|
if (strokeWidth > 0) {
|
|
1237
1252
|
context.stroke();
|
|
1238
1253
|
}
|
|
@@ -1242,11 +1257,19 @@ function drawParticle(data) {
|
|
|
1242
1257
|
if (particle.fill) {
|
|
1243
1258
|
context.fill();
|
|
1244
1259
|
}
|
|
1245
|
-
drawShapeAfterEffect(
|
|
1260
|
+
drawShapeAfterEffect(drawData);
|
|
1246
1261
|
context.globalCompositeOperation = "source-over";
|
|
1247
1262
|
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
1248
1263
|
}
|
|
1249
|
-
function drawShape(
|
|
1264
|
+
function drawShape(data) {
|
|
1265
|
+
const {
|
|
1266
|
+
container,
|
|
1267
|
+
context,
|
|
1268
|
+
particle,
|
|
1269
|
+
radius,
|
|
1270
|
+
opacity,
|
|
1271
|
+
delta
|
|
1272
|
+
} = data;
|
|
1250
1273
|
if (!particle.shape) {
|
|
1251
1274
|
return;
|
|
1252
1275
|
}
|
|
@@ -1254,9 +1277,24 @@ function drawShape(container, context, particle, radius, opacity, delta) {
|
|
|
1254
1277
|
if (!drawer) {
|
|
1255
1278
|
return;
|
|
1256
1279
|
}
|
|
1257
|
-
drawer.draw(
|
|
1280
|
+
drawer.draw({
|
|
1281
|
+
context,
|
|
1282
|
+
particle,
|
|
1283
|
+
radius,
|
|
1284
|
+
opacity,
|
|
1285
|
+
delta,
|
|
1286
|
+
pixelRatio: container.retina.pixelRatio
|
|
1287
|
+
});
|
|
1258
1288
|
}
|
|
1259
|
-
function drawShapeAfterEffect(
|
|
1289
|
+
function drawShapeAfterEffect(data) {
|
|
1290
|
+
const {
|
|
1291
|
+
container,
|
|
1292
|
+
context,
|
|
1293
|
+
particle,
|
|
1294
|
+
radius,
|
|
1295
|
+
opacity,
|
|
1296
|
+
delta
|
|
1297
|
+
} = data;
|
|
1260
1298
|
if (!particle.shape) {
|
|
1261
1299
|
return;
|
|
1262
1300
|
}
|
|
@@ -1264,7 +1302,14 @@ function drawShapeAfterEffect(container, context, particle, radius, opacity, del
|
|
|
1264
1302
|
if (!drawer || !drawer.afterEffect) {
|
|
1265
1303
|
return;
|
|
1266
1304
|
}
|
|
1267
|
-
drawer.afterEffect(
|
|
1305
|
+
drawer.afterEffect({
|
|
1306
|
+
context,
|
|
1307
|
+
particle,
|
|
1308
|
+
radius,
|
|
1309
|
+
opacity,
|
|
1310
|
+
delta,
|
|
1311
|
+
pixelRatio: container.retina.pixelRatio
|
|
1312
|
+
});
|
|
1268
1313
|
}
|
|
1269
1314
|
function drawPlugin(context, plugin, delta) {
|
|
1270
1315
|
if (!plugin.draw) {
|
|
@@ -3648,7 +3693,17 @@ class InteractionManager {
|
|
|
3648
3693
|
|
|
3649
3694
|
|
|
3650
3695
|
|
|
3651
|
-
|
|
3696
|
+
function loadShapeData(shape, shapeOptions, id, reduceDuplicates) {
|
|
3697
|
+
const shapeData = shapeOptions.options[shape];
|
|
3698
|
+
if (!shapeData) {
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3701
|
+
return deepExtend({
|
|
3702
|
+
close: shapeOptions.close,
|
|
3703
|
+
fill: shapeOptions.fill
|
|
3704
|
+
}, itemFromSingleOrMultiple(shapeData, id, reduceDuplicates));
|
|
3705
|
+
}
|
|
3706
|
+
function fixOutMode(data) {
|
|
3652
3707
|
if (!isInArray(data.outMode, data.checkModes)) {
|
|
3653
3708
|
return;
|
|
3654
3709
|
}
|
|
@@ -3658,7 +3713,7 @@ const fixOutMode = data => {
|
|
|
3658
3713
|
} else if (data.coord < diameter) {
|
|
3659
3714
|
data.setCb(data.radius);
|
|
3660
3715
|
}
|
|
3661
|
-
}
|
|
3716
|
+
}
|
|
3662
3717
|
class Particle {
|
|
3663
3718
|
constructor(engine, id, container, position, overrideOptions, group) {
|
|
3664
3719
|
this.container = container;
|
|
@@ -3783,16 +3838,6 @@ class Particle {
|
|
|
3783
3838
|
}
|
|
3784
3839
|
this.offset = Vector.origin;
|
|
3785
3840
|
};
|
|
3786
|
-
this._loadShapeData = (shapeOptions, reduceDuplicates) => {
|
|
3787
|
-
const shapeData = shapeOptions.options[this.shape];
|
|
3788
|
-
if (!shapeData) {
|
|
3789
|
-
return;
|
|
3790
|
-
}
|
|
3791
|
-
return deepExtend({
|
|
3792
|
-
close: shapeOptions.close,
|
|
3793
|
-
fill: shapeOptions.fill
|
|
3794
|
-
}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
|
|
3795
|
-
};
|
|
3796
3841
|
this._engine = engine;
|
|
3797
3842
|
this.init(id, position, overrideOptions, group);
|
|
3798
3843
|
}
|
|
@@ -3881,7 +3926,7 @@ class Particle {
|
|
|
3881
3926
|
shapeOptions.load(overrideOptions.shape);
|
|
3882
3927
|
}
|
|
3883
3928
|
}
|
|
3884
|
-
this.shapeData = this.
|
|
3929
|
+
this.shapeData = loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates);
|
|
3885
3930
|
particlesOptions.load(overrideOptions);
|
|
3886
3931
|
const shapeData = this.shapeData;
|
|
3887
3932
|
if (shapeData) {
|
|
@@ -4477,7 +4522,6 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
|
4477
4522
|
}
|
|
4478
4523
|
class Container {
|
|
4479
4524
|
constructor(engine, id, sourceOptions) {
|
|
4480
|
-
this.id = id;
|
|
4481
4525
|
this._intersectionManager = entries => {
|
|
4482
4526
|
if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
|
|
4483
4527
|
return;
|
|
@@ -4516,6 +4560,7 @@ class Container {
|
|
|
4516
4560
|
}
|
|
4517
4561
|
};
|
|
4518
4562
|
this._engine = engine;
|
|
4563
|
+
this.id = Symbol(id);
|
|
4519
4564
|
this.fpsLimit = 120;
|
|
4520
4565
|
this.smooth = false;
|
|
4521
4566
|
this._delay = 0;
|
|
@@ -4545,9 +4590,7 @@ class Container {
|
|
|
4545
4590
|
this._options = loadContainerOptions(this._engine, this);
|
|
4546
4591
|
this.actualOptions = loadContainerOptions(this._engine, this);
|
|
4547
4592
|
this._eventListeners = new EventListeners(this);
|
|
4548
|
-
|
|
4549
|
-
this._intersectionObserver = new IntersectionObserver(entries => this._intersectionManager(entries));
|
|
4550
|
-
}
|
|
4593
|
+
this._intersectionObserver = safeIntersectionObserver(entries => this._intersectionManager(entries));
|
|
4551
4594
|
this._engine.dispatchEvent("containerBuilt", {
|
|
4552
4595
|
container: this
|
|
4553
4596
|
});
|
|
@@ -4990,17 +5033,17 @@ class Engine {
|
|
|
4990
5033
|
return res;
|
|
4991
5034
|
}
|
|
4992
5035
|
get version() {
|
|
4993
|
-
return "3.0.0-beta.
|
|
5036
|
+
return "3.0.0-beta.3";
|
|
4994
5037
|
}
|
|
4995
|
-
addConfig(
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5038
|
+
addConfig(config) {
|
|
5039
|
+
const name = config.name ?? "default";
|
|
5040
|
+
this._configs.set(name, config);
|
|
5041
|
+
this._eventDispatcher.dispatchEvent("configAdded", {
|
|
5042
|
+
data: {
|
|
5043
|
+
name,
|
|
5044
|
+
config
|
|
5000
5045
|
}
|
|
5001
|
-
}
|
|
5002
|
-
this._configs.set(nameOrConfig.name ?? "default", nameOrConfig);
|
|
5003
|
-
}
|
|
5046
|
+
});
|
|
5004
5047
|
}
|
|
5005
5048
|
addEventListener(type, listener) {
|
|
5006
5049
|
this._eventDispatcher.addEventListener(type, listener);
|
|
@@ -5029,44 +5072,11 @@ class Engine {
|
|
|
5029
5072
|
(override || !this.getPreset(preset)) && this.presets.set(preset, options);
|
|
5030
5073
|
await this.refresh(refresh);
|
|
5031
5074
|
}
|
|
5032
|
-
async addShape(shape, drawer,
|
|
5033
|
-
let customDrawer;
|
|
5034
|
-
let realRefresh = refresh,
|
|
5035
|
-
realInit,
|
|
5036
|
-
realAfterEffect,
|
|
5037
|
-
realDestroy;
|
|
5038
|
-
if (isBoolean(initOrRefresh)) {
|
|
5039
|
-
realRefresh = initOrRefresh;
|
|
5040
|
-
realInit = undefined;
|
|
5041
|
-
} else {
|
|
5042
|
-
realInit = initOrRefresh;
|
|
5043
|
-
}
|
|
5044
|
-
if (isBoolean(afterEffectOrRefresh)) {
|
|
5045
|
-
realRefresh = afterEffectOrRefresh;
|
|
5046
|
-
realAfterEffect = undefined;
|
|
5047
|
-
} else {
|
|
5048
|
-
realAfterEffect = afterEffectOrRefresh;
|
|
5049
|
-
}
|
|
5050
|
-
if (isBoolean(destroyOrRefresh)) {
|
|
5051
|
-
realRefresh = destroyOrRefresh;
|
|
5052
|
-
realDestroy = undefined;
|
|
5053
|
-
} else {
|
|
5054
|
-
realDestroy = destroyOrRefresh;
|
|
5055
|
-
}
|
|
5056
|
-
if (isFunction(drawer)) {
|
|
5057
|
-
customDrawer = {
|
|
5058
|
-
afterEffect: realAfterEffect,
|
|
5059
|
-
destroy: realDestroy,
|
|
5060
|
-
draw: drawer,
|
|
5061
|
-
init: realInit
|
|
5062
|
-
};
|
|
5063
|
-
} else {
|
|
5064
|
-
customDrawer = drawer;
|
|
5065
|
-
}
|
|
5075
|
+
async addShape(shape, drawer, refresh = true) {
|
|
5066
5076
|
executeOnSingleOrMultiple(shape, type => {
|
|
5067
|
-
!this.getShapeDrawer(type) && this.drawers.set(type,
|
|
5077
|
+
!this.getShapeDrawer(type) && this.drawers.set(type, drawer);
|
|
5068
5078
|
});
|
|
5069
|
-
await this.refresh(
|
|
5079
|
+
await this.refresh(refresh);
|
|
5070
5080
|
}
|
|
5071
5081
|
clearPlugins(container) {
|
|
5072
5082
|
this.updaters.delete(container);
|
|
@@ -5144,7 +5154,7 @@ class Engine {
|
|
|
5144
5154
|
}
|
|
5145
5155
|
const currentOptions = itemFromSingleOrMultiple(options, index),
|
|
5146
5156
|
dom = this.dom(),
|
|
5147
|
-
oldIndex = dom.findIndex(v => v.id === id);
|
|
5157
|
+
oldIndex = dom.findIndex(v => v.id.description === id);
|
|
5148
5158
|
if (oldIndex >= 0) {
|
|
5149
5159
|
const old = this.domItem(oldIndex);
|
|
5150
5160
|
if (old && !old.destroyed) {
|
|
@@ -7285,7 +7295,12 @@ async function loadBaseMover(engine, refresh = true) {
|
|
|
7285
7295
|
;// CONCATENATED MODULE: ../../shapes/circle/dist/browser/CircleDrawer.js
|
|
7286
7296
|
|
|
7287
7297
|
class CircleDrawer {
|
|
7288
|
-
draw(
|
|
7298
|
+
draw(data) {
|
|
7299
|
+
const {
|
|
7300
|
+
context,
|
|
7301
|
+
particle,
|
|
7302
|
+
radius
|
|
7303
|
+
} = data;
|
|
7289
7304
|
if (!particle.circleRange) {
|
|
7290
7305
|
particle.circleRange = {
|
|
7291
7306
|
min: 0,
|
|
@@ -10089,8 +10104,15 @@ class ImageDrawer {
|
|
|
10089
10104
|
}
|
|
10090
10105
|
this._engine.images.push(image);
|
|
10091
10106
|
}
|
|
10092
|
-
draw(
|
|
10093
|
-
const
|
|
10107
|
+
draw(data) {
|
|
10108
|
+
const {
|
|
10109
|
+
context,
|
|
10110
|
+
radius,
|
|
10111
|
+
particle,
|
|
10112
|
+
opacity,
|
|
10113
|
+
delta
|
|
10114
|
+
} = data,
|
|
10115
|
+
image = particle.image,
|
|
10094
10116
|
element = image?.element;
|
|
10095
10117
|
if (!image) {
|
|
10096
10118
|
return;
|
|
@@ -10526,8 +10548,13 @@ async function loadLifeUpdater(engine, refresh = true) {
|
|
|
10526
10548
|
}
|
|
10527
10549
|
;// CONCATENATED MODULE: ../../shapes/line/dist/browser/LineDrawer.js
|
|
10528
10550
|
class LineDrawer {
|
|
10529
|
-
draw(
|
|
10530
|
-
const
|
|
10551
|
+
draw(data) {
|
|
10552
|
+
const {
|
|
10553
|
+
context,
|
|
10554
|
+
particle,
|
|
10555
|
+
radius
|
|
10556
|
+
} = data,
|
|
10557
|
+
shapeData = particle.shapeData;
|
|
10531
10558
|
context.moveTo(-radius / 2, 0);
|
|
10532
10559
|
context.lineTo(radius / 2, 0);
|
|
10533
10560
|
context.lineCap = shapeData?.cap ?? "butt";
|
|
@@ -11343,8 +11370,13 @@ async function loadParticlesLinksInteraction(engine, refresh = true) {
|
|
|
11343
11370
|
;// CONCATENATED MODULE: ../../shapes/polygon/dist/browser/PolygonDrawerBase.js
|
|
11344
11371
|
|
|
11345
11372
|
class PolygonDrawerBase {
|
|
11346
|
-
draw(
|
|
11347
|
-
const
|
|
11373
|
+
draw(data) {
|
|
11374
|
+
const {
|
|
11375
|
+
context,
|
|
11376
|
+
particle,
|
|
11377
|
+
radius
|
|
11378
|
+
} = data,
|
|
11379
|
+
start = this.getCenter(particle, radius),
|
|
11348
11380
|
side = this.getSidesData(particle, radius),
|
|
11349
11381
|
sideCount = side.count.numerator * side.count.denominator,
|
|
11350
11382
|
decimalSides = side.count.numerator / side.count.denominator,
|
|
@@ -11578,8 +11610,12 @@ async function loadRotateUpdater(engine, refresh = true) {
|
|
|
11578
11610
|
;// CONCATENATED MODULE: ../../shapes/square/dist/browser/SquareDrawer.js
|
|
11579
11611
|
const fixFactor = Math.sqrt(2);
|
|
11580
11612
|
class SquareDrawer {
|
|
11581
|
-
draw(
|
|
11582
|
-
const
|
|
11613
|
+
draw(data) {
|
|
11614
|
+
const {
|
|
11615
|
+
context,
|
|
11616
|
+
radius
|
|
11617
|
+
} = data,
|
|
11618
|
+
fixedRadius = radius / fixFactor,
|
|
11583
11619
|
fixedDiameter = fixedRadius * 2;
|
|
11584
11620
|
context.rect(-fixedRadius, -fixedRadius, fixedDiameter, fixedDiameter);
|
|
11585
11621
|
}
|
|
@@ -11595,8 +11631,13 @@ async function loadSquareShape(engine, refresh = true) {
|
|
|
11595
11631
|
;// CONCATENATED MODULE: ../../shapes/star/dist/browser/StarDrawer.js
|
|
11596
11632
|
|
|
11597
11633
|
class StarDrawer {
|
|
11598
|
-
draw(
|
|
11599
|
-
const
|
|
11634
|
+
draw(data) {
|
|
11635
|
+
const {
|
|
11636
|
+
context,
|
|
11637
|
+
particle,
|
|
11638
|
+
radius
|
|
11639
|
+
} = data,
|
|
11640
|
+
sides = particle.sides,
|
|
11600
11641
|
inset = particle.starInset ?? 2;
|
|
11601
11642
|
context.moveTo(0, 0 - radius);
|
|
11602
11643
|
for (let i = 0; i < sides; i++) {
|
|
@@ -11734,8 +11775,14 @@ async function loadStrokeColorUpdater(engine, refresh = true) {
|
|
|
11734
11775
|
|
|
11735
11776
|
const validTypes = ["text", "character", "char"];
|
|
11736
11777
|
class TextDrawer {
|
|
11737
|
-
draw(
|
|
11738
|
-
const
|
|
11778
|
+
draw(data) {
|
|
11779
|
+
const {
|
|
11780
|
+
context,
|
|
11781
|
+
particle,
|
|
11782
|
+
radius,
|
|
11783
|
+
opacity
|
|
11784
|
+
} = data,
|
|
11785
|
+
character = particle.shapeData;
|
|
11739
11786
|
if (character === undefined) {
|
|
11740
11787
|
return;
|
|
11741
11788
|
}
|