tsparticles 3.0.0-alpha.0 → 3.0.0-alpha.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.
- package/package.json +11 -11
- package/report.html +2 -2
- package/tsparticles.bundle.js +152 -90
- 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-alpha.
|
|
7
|
+
* v3.0.0-alpha.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -724,21 +724,41 @@ function initParticleNumericAnimationValue(options, pxRatio) {
|
|
|
724
724
|
maxLoops: getRangeValue(options.animation.count)
|
|
725
725
|
};
|
|
726
726
|
if (animationOptions.enable) {
|
|
727
|
-
res.status = "increasing";
|
|
728
727
|
res.decay = 1 - getRangeValue(animationOptions.decay);
|
|
728
|
+
let autoStatus = false;
|
|
729
|
+
switch (animationOptions.mode) {
|
|
730
|
+
case "increase":
|
|
731
|
+
res.status = "increasing";
|
|
732
|
+
break;
|
|
733
|
+
case "decrease":
|
|
734
|
+
res.status = "decreasing";
|
|
735
|
+
break;
|
|
736
|
+
case "random":
|
|
737
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
738
|
+
break;
|
|
739
|
+
case "auto":
|
|
740
|
+
autoStatus = true;
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
729
743
|
switch (animationOptions.startValue) {
|
|
730
744
|
case "min":
|
|
731
745
|
res.value = res.min;
|
|
732
|
-
|
|
746
|
+
if (autoStatus) {
|
|
747
|
+
res.status = "increasing";
|
|
748
|
+
}
|
|
733
749
|
break;
|
|
734
750
|
case "random":
|
|
735
751
|
res.value = randomInRange(res);
|
|
736
|
-
|
|
752
|
+
if (autoStatus) {
|
|
753
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
754
|
+
}
|
|
737
755
|
break;
|
|
738
756
|
case "max":
|
|
739
757
|
default:
|
|
740
758
|
res.value = res.max;
|
|
741
|
-
|
|
759
|
+
if (autoStatus) {
|
|
760
|
+
res.status = "decreasing";
|
|
761
|
+
}
|
|
742
762
|
break;
|
|
743
763
|
}
|
|
744
764
|
}
|
|
@@ -1641,28 +1661,28 @@ class EventListeners {
|
|
|
1641
1661
|
this.container = container;
|
|
1642
1662
|
this.canPush = true;
|
|
1643
1663
|
this.handlers = {
|
|
1644
|
-
mouseMove: e => this.
|
|
1645
|
-
touchStart: e => this.
|
|
1646
|
-
touchMove: e => this.
|
|
1647
|
-
touchEnd: () => this.
|
|
1648
|
-
mouseLeave: () => this.
|
|
1649
|
-
touchCancel: () => this.
|
|
1650
|
-
touchEndClick: e => this.
|
|
1651
|
-
mouseUp: e => this.
|
|
1652
|
-
mouseDown: () => this.
|
|
1653
|
-
visibilityChange: () => this.
|
|
1654
|
-
themeChange: e => this.
|
|
1655
|
-
oldThemeChange: e => this.
|
|
1656
|
-
resize: () => this.
|
|
1664
|
+
mouseMove: e => this._mouseTouchMove(e),
|
|
1665
|
+
touchStart: e => this._mouseTouchMove(e),
|
|
1666
|
+
touchMove: e => this._mouseTouchMove(e),
|
|
1667
|
+
touchEnd: () => this._mouseTouchFinish(),
|
|
1668
|
+
mouseLeave: () => this._mouseTouchFinish(),
|
|
1669
|
+
touchCancel: () => this._mouseTouchFinish(),
|
|
1670
|
+
touchEndClick: e => this._mouseTouchClick(e),
|
|
1671
|
+
mouseUp: e => this._mouseTouchClick(e),
|
|
1672
|
+
mouseDown: () => this._mouseDown(),
|
|
1673
|
+
visibilityChange: () => this._handleVisibilityChange(),
|
|
1674
|
+
themeChange: e => this._handleThemeChange(e),
|
|
1675
|
+
oldThemeChange: e => this._handleThemeChange(e),
|
|
1676
|
+
resize: () => this._handleWindowResize()
|
|
1657
1677
|
};
|
|
1658
1678
|
}
|
|
1659
1679
|
addListeners() {
|
|
1660
|
-
this.
|
|
1680
|
+
this._manageListeners(true);
|
|
1661
1681
|
}
|
|
1662
1682
|
removeListeners() {
|
|
1663
|
-
this.
|
|
1683
|
+
this._manageListeners(false);
|
|
1664
1684
|
}
|
|
1665
|
-
|
|
1685
|
+
_doMouseTouchClick(e) {
|
|
1666
1686
|
const container = this.container,
|
|
1667
1687
|
options = container.actualOptions;
|
|
1668
1688
|
if (this.canPush) {
|
|
@@ -1674,16 +1694,16 @@ class EventListeners {
|
|
|
1674
1694
|
mouseInteractivity.clickPosition = Object.assign({}, mousePos);
|
|
1675
1695
|
mouseInteractivity.clickTime = new Date().getTime();
|
|
1676
1696
|
const onClick = options.interactivity.events.onClick;
|
|
1677
|
-
executeOnSingleOrMultiple(onClick.mode, mode => this.
|
|
1697
|
+
executeOnSingleOrMultiple(onClick.mode, mode => this._handleClickMode(mode));
|
|
1678
1698
|
}
|
|
1679
1699
|
if (e.type === "touchend") {
|
|
1680
|
-
setTimeout(() => this.
|
|
1700
|
+
setTimeout(() => this._mouseTouchFinish(), 500);
|
|
1681
1701
|
}
|
|
1682
1702
|
}
|
|
1683
|
-
|
|
1703
|
+
_handleClickMode(mode) {
|
|
1684
1704
|
this.container.handleClickMode(mode);
|
|
1685
1705
|
}
|
|
1686
|
-
|
|
1706
|
+
_handleThemeChange(e) {
|
|
1687
1707
|
const mediaEvent = e,
|
|
1688
1708
|
container = this.container,
|
|
1689
1709
|
options = container.options,
|
|
@@ -1694,18 +1714,17 @@ class EventListeners {
|
|
|
1694
1714
|
container.loadTheme(themeName);
|
|
1695
1715
|
}
|
|
1696
1716
|
}
|
|
1697
|
-
|
|
1717
|
+
_handleVisibilityChange() {
|
|
1698
1718
|
const container = this.container,
|
|
1699
1719
|
options = container.actualOptions;
|
|
1700
|
-
this.
|
|
1720
|
+
this._mouseTouchFinish();
|
|
1701
1721
|
if (!options.pauseOnBlur) {
|
|
1702
1722
|
return;
|
|
1703
1723
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1724
|
+
container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
|
|
1725
|
+
if (container.pageHidden) {
|
|
1706
1726
|
container.pause();
|
|
1707
1727
|
} else {
|
|
1708
|
-
container.pageHidden = false;
|
|
1709
1728
|
if (container.getAnimationStatus()) {
|
|
1710
1729
|
container.play(true);
|
|
1711
1730
|
} else {
|
|
@@ -1713,7 +1732,7 @@ class EventListeners {
|
|
|
1713
1732
|
}
|
|
1714
1733
|
}
|
|
1715
1734
|
}
|
|
1716
|
-
|
|
1735
|
+
_handleWindowResize() {
|
|
1717
1736
|
if (this.resizeTimeout) {
|
|
1718
1737
|
clearTimeout(this.resizeTimeout);
|
|
1719
1738
|
delete this.resizeTimeout;
|
|
@@ -1723,7 +1742,7 @@ class EventListeners {
|
|
|
1723
1742
|
return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
|
|
1724
1743
|
}, this.container.actualOptions.interactivity.events.resize.delay * 1000);
|
|
1725
1744
|
}
|
|
1726
|
-
|
|
1745
|
+
_manageInteractivityEvents(add) {
|
|
1727
1746
|
var _a;
|
|
1728
1747
|
const handlers = this.handlers,
|
|
1729
1748
|
container = this.container,
|
|
@@ -1739,18 +1758,6 @@ class EventListeners {
|
|
|
1739
1758
|
} else {
|
|
1740
1759
|
container.interactivity.element = container.canvas.element;
|
|
1741
1760
|
}
|
|
1742
|
-
const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
1743
|
-
if (mediaMatch) {
|
|
1744
|
-
if (mediaMatch.addEventListener !== undefined) {
|
|
1745
|
-
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
1746
|
-
} else if (mediaMatch.addListener !== undefined) {
|
|
1747
|
-
if (add) {
|
|
1748
|
-
mediaMatch.addListener(handlers.oldThemeChange);
|
|
1749
|
-
} else {
|
|
1750
|
-
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
1761
|
const interactivityEl = container.interactivity.element;
|
|
1755
1762
|
if (!interactivityEl) {
|
|
1756
1763
|
return;
|
|
@@ -1773,33 +1780,66 @@ class EventListeners {
|
|
|
1773
1780
|
if (container.canvas.element) {
|
|
1774
1781
|
container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
|
|
1775
1782
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1783
|
+
}
|
|
1784
|
+
_manageListeners(add) {
|
|
1785
|
+
this._manageMediaEvents(add);
|
|
1786
|
+
this._manageInteractivityEvents(add);
|
|
1787
|
+
this._manageResizeEvent(add);
|
|
1788
|
+
this._manageVisibilityEvent(add);
|
|
1789
|
+
}
|
|
1790
|
+
_manageMediaEvents(add) {
|
|
1791
|
+
const handlers = this.handlers,
|
|
1792
|
+
mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
1793
|
+
if (!mediaMatch) {
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
1797
|
+
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
if (mediaMatch.addListener !== undefined) {
|
|
1801
|
+
if (add) {
|
|
1802
|
+
mediaMatch.addListener(handlers.oldThemeChange);
|
|
1794
1803
|
} else {
|
|
1795
|
-
|
|
1804
|
+
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
_manageResizeEvent(add) {
|
|
1809
|
+
const handlers = this.handlers,
|
|
1810
|
+
container = this.container,
|
|
1811
|
+
options = container.actualOptions;
|
|
1812
|
+
if (!options.interactivity.events.resize) {
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
if (typeof ResizeObserver === "undefined") {
|
|
1816
|
+
manageListener(window, resizeEvent, handlers.resize, add);
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
if (this.resizeObserver && !add) {
|
|
1820
|
+
if (container.canvas.element) {
|
|
1821
|
+
this.resizeObserver.unobserve(container.canvas.element);
|
|
1796
1822
|
}
|
|
1823
|
+
this.resizeObserver.disconnect();
|
|
1824
|
+
delete this.resizeObserver;
|
|
1825
|
+
} else if (!this.resizeObserver && add && container.canvas.element) {
|
|
1826
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
1827
|
+
const entry = entries.find(e => e.target === container.canvas.element);
|
|
1828
|
+
if (!entry) {
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
this._handleWindowResize();
|
|
1832
|
+
});
|
|
1833
|
+
this.resizeObserver.observe(container.canvas.element);
|
|
1797
1834
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1835
|
+
}
|
|
1836
|
+
_manageVisibilityEvent(add) {
|
|
1837
|
+
if (!document) {
|
|
1838
|
+
return;
|
|
1800
1839
|
}
|
|
1840
|
+
manageListener(document, visibilityChangeEvent, this.handlers.visibilityChange, add);
|
|
1801
1841
|
}
|
|
1802
|
-
|
|
1842
|
+
_mouseDown() {
|
|
1803
1843
|
const interactivity = this.container.interactivity;
|
|
1804
1844
|
if (interactivity) {
|
|
1805
1845
|
const mouse = interactivity.mouse;
|
|
@@ -1807,7 +1847,7 @@ class EventListeners {
|
|
|
1807
1847
|
mouse.downPosition = mouse.position;
|
|
1808
1848
|
}
|
|
1809
1849
|
}
|
|
1810
|
-
|
|
1850
|
+
_mouseTouchClick(e) {
|
|
1811
1851
|
const container = this.container,
|
|
1812
1852
|
options = container.actualOptions,
|
|
1813
1853
|
mouse = container.interactivity.mouse;
|
|
@@ -1827,11 +1867,11 @@ class EventListeners {
|
|
|
1827
1867
|
}
|
|
1828
1868
|
}
|
|
1829
1869
|
if (!handled) {
|
|
1830
|
-
this.
|
|
1870
|
+
this._doMouseTouchClick(e);
|
|
1831
1871
|
}
|
|
1832
1872
|
mouse.clicking = false;
|
|
1833
1873
|
}
|
|
1834
|
-
|
|
1874
|
+
_mouseTouchFinish() {
|
|
1835
1875
|
const interactivity = this.container.interactivity;
|
|
1836
1876
|
if (!interactivity) {
|
|
1837
1877
|
return;
|
|
@@ -1844,7 +1884,7 @@ class EventListeners {
|
|
|
1844
1884
|
mouse.inside = false;
|
|
1845
1885
|
mouse.clicking = false;
|
|
1846
1886
|
}
|
|
1847
|
-
|
|
1887
|
+
_mouseTouchMove(e) {
|
|
1848
1888
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1849
1889
|
const container = this.container,
|
|
1850
1890
|
options = container.actualOptions;
|
|
@@ -2313,14 +2353,15 @@ class Interactivity {
|
|
|
2313
2353
|
|
|
2314
2354
|
class ManualParticle {
|
|
2315
2355
|
load(data) {
|
|
2316
|
-
var _a, _b;
|
|
2356
|
+
var _a, _b, _c;
|
|
2317
2357
|
if (!data) {
|
|
2318
2358
|
return;
|
|
2319
2359
|
}
|
|
2320
2360
|
if (data.position !== undefined) {
|
|
2321
2361
|
this.position = {
|
|
2322
2362
|
x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
|
|
2323
|
-
y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
|
|
2363
|
+
y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50,
|
|
2364
|
+
mode: (_c = data.position.mode) !== null && _c !== void 0 ? _c : "percent"
|
|
2324
2365
|
};
|
|
2325
2366
|
}
|
|
2326
2367
|
if (data.options !== undefined) {
|
|
@@ -2553,6 +2594,7 @@ class AnimationOptions {
|
|
|
2553
2594
|
class RangedAnimationOptions extends AnimationOptions {
|
|
2554
2595
|
constructor() {
|
|
2555
2596
|
super();
|
|
2597
|
+
this.mode = "auto";
|
|
2556
2598
|
this.startValue = "random";
|
|
2557
2599
|
}
|
|
2558
2600
|
load(data) {
|
|
@@ -2563,6 +2605,9 @@ class RangedAnimationOptions extends AnimationOptions {
|
|
|
2563
2605
|
if (data.minimumValue !== undefined) {
|
|
2564
2606
|
this.minimumValue = data.minimumValue;
|
|
2565
2607
|
}
|
|
2608
|
+
if (data.mode !== undefined) {
|
|
2609
|
+
this.mode = data.mode;
|
|
2610
|
+
}
|
|
2566
2611
|
if (data.startValue !== undefined) {
|
|
2567
2612
|
this.startValue = data.startValue;
|
|
2568
2613
|
}
|
|
@@ -3209,12 +3254,20 @@ class Shape {
|
|
|
3209
3254
|
constructor() {
|
|
3210
3255
|
this.options = {};
|
|
3211
3256
|
this.type = "circle";
|
|
3257
|
+
this.close = true;
|
|
3258
|
+
this.fill = true;
|
|
3212
3259
|
}
|
|
3213
3260
|
load(data) {
|
|
3214
3261
|
var _a;
|
|
3215
3262
|
if (!data) {
|
|
3216
3263
|
return;
|
|
3217
3264
|
}
|
|
3265
|
+
if (data.close !== undefined) {
|
|
3266
|
+
this.close = data.close;
|
|
3267
|
+
}
|
|
3268
|
+
if (data.fill !== undefined) {
|
|
3269
|
+
this.fill = data.fill;
|
|
3270
|
+
}
|
|
3218
3271
|
const options = data.options;
|
|
3219
3272
|
if (options !== undefined) {
|
|
3220
3273
|
for (const shape in options) {
|
|
@@ -3981,7 +4034,10 @@ class Particle {
|
|
|
3981
4034
|
_loadShapeData(shapeOptions, reduceDuplicates) {
|
|
3982
4035
|
const shapeData = shapeOptions.options[this.shape];
|
|
3983
4036
|
if (shapeData) {
|
|
3984
|
-
return deepExtend({
|
|
4037
|
+
return deepExtend({
|
|
4038
|
+
close: shapeOptions.close,
|
|
4039
|
+
fill: shapeOptions.fill
|
|
4040
|
+
}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
|
|
3985
4041
|
}
|
|
3986
4042
|
}
|
|
3987
4043
|
}
|
|
@@ -4164,10 +4220,10 @@ class Particles {
|
|
|
4164
4220
|
const container = this.container,
|
|
4165
4221
|
options = container.actualOptions;
|
|
4166
4222
|
for (const particle of options.manualParticles) {
|
|
4167
|
-
this.addParticle(calcPositionFromSize({
|
|
4223
|
+
this.addParticle(particle.position ? particle.position.mode === "precise" ? particle.position : calcPositionFromSize({
|
|
4168
4224
|
size: container.canvas.size,
|
|
4169
4225
|
position: particle.position
|
|
4170
|
-
}), particle.options);
|
|
4226
|
+
}) : undefined, particle.options);
|
|
4171
4227
|
}
|
|
4172
4228
|
}
|
|
4173
4229
|
addParticle(position, overrideOptions, group, initializer) {
|
|
@@ -4271,22 +4327,9 @@ class Particles {
|
|
|
4271
4327
|
}
|
|
4272
4328
|
let deleted = 0;
|
|
4273
4329
|
for (let i = index; deleted < quantity && i < this.count; i++) {
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
continue;
|
|
4330
|
+
if (this._removeParticle(i--, group, override)) {
|
|
4331
|
+
deleted++;
|
|
4277
4332
|
}
|
|
4278
|
-
particle.destroy(override);
|
|
4279
|
-
this.array.splice(i--, 1);
|
|
4280
|
-
const idx = this.zArray.indexOf(particle);
|
|
4281
|
-
this.zArray.splice(idx, 1);
|
|
4282
|
-
this.pool.push(particle);
|
|
4283
|
-
deleted++;
|
|
4284
|
-
this._engine.dispatchEvent("particleRemoved", {
|
|
4285
|
-
container: this.container,
|
|
4286
|
-
data: {
|
|
4287
|
-
particle
|
|
4288
|
-
}
|
|
4289
|
-
});
|
|
4290
4333
|
}
|
|
4291
4334
|
}
|
|
4292
4335
|
removeQuantity(quantity, group) {
|
|
@@ -4407,6 +4450,24 @@ class Particles {
|
|
|
4407
4450
|
return;
|
|
4408
4451
|
}
|
|
4409
4452
|
}
|
|
4453
|
+
_removeParticle(index, group, override) {
|
|
4454
|
+
const particle = this.array[index];
|
|
4455
|
+
if (!particle || particle.group !== group) {
|
|
4456
|
+
return false;
|
|
4457
|
+
}
|
|
4458
|
+
particle.destroy(override);
|
|
4459
|
+
this.array.splice(index, 1);
|
|
4460
|
+
const zIdx = this.zArray.indexOf(particle);
|
|
4461
|
+
this.zArray.splice(zIdx, 1);
|
|
4462
|
+
this.pool.push(particle);
|
|
4463
|
+
this._engine.dispatchEvent("particleRemoved", {
|
|
4464
|
+
container: this.container,
|
|
4465
|
+
data: {
|
|
4466
|
+
particle
|
|
4467
|
+
}
|
|
4468
|
+
});
|
|
4469
|
+
return true;
|
|
4470
|
+
}
|
|
4410
4471
|
}
|
|
4411
4472
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Retina.js
|
|
4412
4473
|
|
|
@@ -5533,6 +5594,7 @@ const tsParticles = new Engine();
|
|
|
5533
5594
|
|
|
5534
5595
|
|
|
5535
5596
|
|
|
5597
|
+
|
|
5536
5598
|
|
|
5537
5599
|
|
|
5538
5600
|
;// CONCATENATED MODULE: ../../plugins/absorbers/dist/esm/Options/Classes/AbsorberSizeLimit.js
|