@tsparticles/slim 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.
|
@@ -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')
|
|
@@ -753,21 +753,41 @@ function initParticleNumericAnimationValue(options, pxRatio) {
|
|
|
753
753
|
maxLoops: getRangeValue(options.animation.count)
|
|
754
754
|
};
|
|
755
755
|
if (animationOptions.enable) {
|
|
756
|
-
res.status = "increasing";
|
|
757
756
|
res.decay = 1 - getRangeValue(animationOptions.decay);
|
|
757
|
+
let autoStatus = false;
|
|
758
|
+
switch (animationOptions.mode) {
|
|
759
|
+
case "increase":
|
|
760
|
+
res.status = "increasing";
|
|
761
|
+
break;
|
|
762
|
+
case "decrease":
|
|
763
|
+
res.status = "decreasing";
|
|
764
|
+
break;
|
|
765
|
+
case "random":
|
|
766
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
767
|
+
break;
|
|
768
|
+
case "auto":
|
|
769
|
+
autoStatus = true;
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
758
772
|
switch (animationOptions.startValue) {
|
|
759
773
|
case "min":
|
|
760
774
|
res.value = res.min;
|
|
761
|
-
|
|
775
|
+
if (autoStatus) {
|
|
776
|
+
res.status = "increasing";
|
|
777
|
+
}
|
|
762
778
|
break;
|
|
763
779
|
case "random":
|
|
764
780
|
res.value = randomInRange(res);
|
|
765
|
-
|
|
781
|
+
if (autoStatus) {
|
|
782
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
783
|
+
}
|
|
766
784
|
break;
|
|
767
785
|
case "max":
|
|
768
786
|
default:
|
|
769
787
|
res.value = res.max;
|
|
770
|
-
|
|
788
|
+
if (autoStatus) {
|
|
789
|
+
res.status = "decreasing";
|
|
790
|
+
}
|
|
771
791
|
break;
|
|
772
792
|
}
|
|
773
793
|
}
|
|
@@ -1670,28 +1690,28 @@ class EventListeners {
|
|
|
1670
1690
|
this.container = container;
|
|
1671
1691
|
this.canPush = true;
|
|
1672
1692
|
this.handlers = {
|
|
1673
|
-
mouseMove: e => this.
|
|
1674
|
-
touchStart: e => this.
|
|
1675
|
-
touchMove: e => this.
|
|
1676
|
-
touchEnd: () => this.
|
|
1677
|
-
mouseLeave: () => this.
|
|
1678
|
-
touchCancel: () => this.
|
|
1679
|
-
touchEndClick: e => this.
|
|
1680
|
-
mouseUp: e => this.
|
|
1681
|
-
mouseDown: () => this.
|
|
1682
|
-
visibilityChange: () => this.
|
|
1683
|
-
themeChange: e => this.
|
|
1684
|
-
oldThemeChange: e => this.
|
|
1685
|
-
resize: () => this.
|
|
1693
|
+
mouseMove: e => this._mouseTouchMove(e),
|
|
1694
|
+
touchStart: e => this._mouseTouchMove(e),
|
|
1695
|
+
touchMove: e => this._mouseTouchMove(e),
|
|
1696
|
+
touchEnd: () => this._mouseTouchFinish(),
|
|
1697
|
+
mouseLeave: () => this._mouseTouchFinish(),
|
|
1698
|
+
touchCancel: () => this._mouseTouchFinish(),
|
|
1699
|
+
touchEndClick: e => this._mouseTouchClick(e),
|
|
1700
|
+
mouseUp: e => this._mouseTouchClick(e),
|
|
1701
|
+
mouseDown: () => this._mouseDown(),
|
|
1702
|
+
visibilityChange: () => this._handleVisibilityChange(),
|
|
1703
|
+
themeChange: e => this._handleThemeChange(e),
|
|
1704
|
+
oldThemeChange: e => this._handleThemeChange(e),
|
|
1705
|
+
resize: () => this._handleWindowResize()
|
|
1686
1706
|
};
|
|
1687
1707
|
}
|
|
1688
1708
|
addListeners() {
|
|
1689
|
-
this.
|
|
1709
|
+
this._manageListeners(true);
|
|
1690
1710
|
}
|
|
1691
1711
|
removeListeners() {
|
|
1692
|
-
this.
|
|
1712
|
+
this._manageListeners(false);
|
|
1693
1713
|
}
|
|
1694
|
-
|
|
1714
|
+
_doMouseTouchClick(e) {
|
|
1695
1715
|
const container = this.container,
|
|
1696
1716
|
options = container.actualOptions;
|
|
1697
1717
|
if (this.canPush) {
|
|
@@ -1703,16 +1723,16 @@ class EventListeners {
|
|
|
1703
1723
|
mouseInteractivity.clickPosition = Object.assign({}, mousePos);
|
|
1704
1724
|
mouseInteractivity.clickTime = new Date().getTime();
|
|
1705
1725
|
const onClick = options.interactivity.events.onClick;
|
|
1706
|
-
executeOnSingleOrMultiple(onClick.mode, mode => this.
|
|
1726
|
+
executeOnSingleOrMultiple(onClick.mode, mode => this._handleClickMode(mode));
|
|
1707
1727
|
}
|
|
1708
1728
|
if (e.type === "touchend") {
|
|
1709
|
-
setTimeout(() => this.
|
|
1729
|
+
setTimeout(() => this._mouseTouchFinish(), 500);
|
|
1710
1730
|
}
|
|
1711
1731
|
}
|
|
1712
|
-
|
|
1732
|
+
_handleClickMode(mode) {
|
|
1713
1733
|
this.container.handleClickMode(mode);
|
|
1714
1734
|
}
|
|
1715
|
-
|
|
1735
|
+
_handleThemeChange(e) {
|
|
1716
1736
|
const mediaEvent = e,
|
|
1717
1737
|
container = this.container,
|
|
1718
1738
|
options = container.options,
|
|
@@ -1723,18 +1743,17 @@ class EventListeners {
|
|
|
1723
1743
|
container.loadTheme(themeName);
|
|
1724
1744
|
}
|
|
1725
1745
|
}
|
|
1726
|
-
|
|
1746
|
+
_handleVisibilityChange() {
|
|
1727
1747
|
const container = this.container,
|
|
1728
1748
|
options = container.actualOptions;
|
|
1729
|
-
this.
|
|
1749
|
+
this._mouseTouchFinish();
|
|
1730
1750
|
if (!options.pauseOnBlur) {
|
|
1731
1751
|
return;
|
|
1732
1752
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1753
|
+
container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
|
|
1754
|
+
if (container.pageHidden) {
|
|
1735
1755
|
container.pause();
|
|
1736
1756
|
} else {
|
|
1737
|
-
container.pageHidden = false;
|
|
1738
1757
|
if (container.getAnimationStatus()) {
|
|
1739
1758
|
container.play(true);
|
|
1740
1759
|
} else {
|
|
@@ -1742,7 +1761,7 @@ class EventListeners {
|
|
|
1742
1761
|
}
|
|
1743
1762
|
}
|
|
1744
1763
|
}
|
|
1745
|
-
|
|
1764
|
+
_handleWindowResize() {
|
|
1746
1765
|
if (this.resizeTimeout) {
|
|
1747
1766
|
clearTimeout(this.resizeTimeout);
|
|
1748
1767
|
delete this.resizeTimeout;
|
|
@@ -1752,7 +1771,7 @@ class EventListeners {
|
|
|
1752
1771
|
return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize();
|
|
1753
1772
|
}, this.container.actualOptions.interactivity.events.resize.delay * 1000);
|
|
1754
1773
|
}
|
|
1755
|
-
|
|
1774
|
+
_manageInteractivityEvents(add) {
|
|
1756
1775
|
var _a;
|
|
1757
1776
|
const handlers = this.handlers,
|
|
1758
1777
|
container = this.container,
|
|
@@ -1768,18 +1787,6 @@ class EventListeners {
|
|
|
1768
1787
|
} else {
|
|
1769
1788
|
container.interactivity.element = container.canvas.element;
|
|
1770
1789
|
}
|
|
1771
|
-
const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
1772
|
-
if (mediaMatch) {
|
|
1773
|
-
if (mediaMatch.addEventListener !== undefined) {
|
|
1774
|
-
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
1775
|
-
} else if (mediaMatch.addListener !== undefined) {
|
|
1776
|
-
if (add) {
|
|
1777
|
-
mediaMatch.addListener(handlers.oldThemeChange);
|
|
1778
|
-
} else {
|
|
1779
|
-
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
1790
|
const interactivityEl = container.interactivity.element;
|
|
1784
1791
|
if (!interactivityEl) {
|
|
1785
1792
|
return;
|
|
@@ -1802,33 +1809,66 @@ class EventListeners {
|
|
|
1802
1809
|
if (container.canvas.element) {
|
|
1803
1810
|
container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
|
|
1804
1811
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1812
|
+
}
|
|
1813
|
+
_manageListeners(add) {
|
|
1814
|
+
this._manageMediaEvents(add);
|
|
1815
|
+
this._manageInteractivityEvents(add);
|
|
1816
|
+
this._manageResizeEvent(add);
|
|
1817
|
+
this._manageVisibilityEvent(add);
|
|
1818
|
+
}
|
|
1819
|
+
_manageMediaEvents(add) {
|
|
1820
|
+
const handlers = this.handlers,
|
|
1821
|
+
mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
1822
|
+
if (!mediaMatch) {
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
1826
|
+
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
if (mediaMatch.addListener !== undefined) {
|
|
1830
|
+
if (add) {
|
|
1831
|
+
mediaMatch.addListener(handlers.oldThemeChange);
|
|
1823
1832
|
} else {
|
|
1824
|
-
|
|
1833
|
+
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
_manageResizeEvent(add) {
|
|
1838
|
+
const handlers = this.handlers,
|
|
1839
|
+
container = this.container,
|
|
1840
|
+
options = container.actualOptions;
|
|
1841
|
+
if (!options.interactivity.events.resize) {
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
if (typeof ResizeObserver === "undefined") {
|
|
1845
|
+
manageListener(window, resizeEvent, handlers.resize, add);
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
if (this.resizeObserver && !add) {
|
|
1849
|
+
if (container.canvas.element) {
|
|
1850
|
+
this.resizeObserver.unobserve(container.canvas.element);
|
|
1825
1851
|
}
|
|
1852
|
+
this.resizeObserver.disconnect();
|
|
1853
|
+
delete this.resizeObserver;
|
|
1854
|
+
} else if (!this.resizeObserver && add && container.canvas.element) {
|
|
1855
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
1856
|
+
const entry = entries.find(e => e.target === container.canvas.element);
|
|
1857
|
+
if (!entry) {
|
|
1858
|
+
return;
|
|
1859
|
+
}
|
|
1860
|
+
this._handleWindowResize();
|
|
1861
|
+
});
|
|
1862
|
+
this.resizeObserver.observe(container.canvas.element);
|
|
1826
1863
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1864
|
+
}
|
|
1865
|
+
_manageVisibilityEvent(add) {
|
|
1866
|
+
if (!document) {
|
|
1867
|
+
return;
|
|
1829
1868
|
}
|
|
1869
|
+
manageListener(document, visibilityChangeEvent, this.handlers.visibilityChange, add);
|
|
1830
1870
|
}
|
|
1831
|
-
|
|
1871
|
+
_mouseDown() {
|
|
1832
1872
|
const interactivity = this.container.interactivity;
|
|
1833
1873
|
if (interactivity) {
|
|
1834
1874
|
const mouse = interactivity.mouse;
|
|
@@ -1836,7 +1876,7 @@ class EventListeners {
|
|
|
1836
1876
|
mouse.downPosition = mouse.position;
|
|
1837
1877
|
}
|
|
1838
1878
|
}
|
|
1839
|
-
|
|
1879
|
+
_mouseTouchClick(e) {
|
|
1840
1880
|
const container = this.container,
|
|
1841
1881
|
options = container.actualOptions,
|
|
1842
1882
|
mouse = container.interactivity.mouse;
|
|
@@ -1856,11 +1896,11 @@ class EventListeners {
|
|
|
1856
1896
|
}
|
|
1857
1897
|
}
|
|
1858
1898
|
if (!handled) {
|
|
1859
|
-
this.
|
|
1899
|
+
this._doMouseTouchClick(e);
|
|
1860
1900
|
}
|
|
1861
1901
|
mouse.clicking = false;
|
|
1862
1902
|
}
|
|
1863
|
-
|
|
1903
|
+
_mouseTouchFinish() {
|
|
1864
1904
|
const interactivity = this.container.interactivity;
|
|
1865
1905
|
if (!interactivity) {
|
|
1866
1906
|
return;
|
|
@@ -1873,7 +1913,7 @@ class EventListeners {
|
|
|
1873
1913
|
mouse.inside = false;
|
|
1874
1914
|
mouse.clicking = false;
|
|
1875
1915
|
}
|
|
1876
|
-
|
|
1916
|
+
_mouseTouchMove(e) {
|
|
1877
1917
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1878
1918
|
const container = this.container,
|
|
1879
1919
|
options = container.actualOptions;
|
|
@@ -2342,14 +2382,15 @@ class Interactivity {
|
|
|
2342
2382
|
|
|
2343
2383
|
class ManualParticle {
|
|
2344
2384
|
load(data) {
|
|
2345
|
-
var _a, _b;
|
|
2385
|
+
var _a, _b, _c;
|
|
2346
2386
|
if (!data) {
|
|
2347
2387
|
return;
|
|
2348
2388
|
}
|
|
2349
2389
|
if (data.position !== undefined) {
|
|
2350
2390
|
this.position = {
|
|
2351
2391
|
x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
|
|
2352
|
-
y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50
|
|
2392
|
+
y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50,
|
|
2393
|
+
mode: (_c = data.position.mode) !== null && _c !== void 0 ? _c : "percent"
|
|
2353
2394
|
};
|
|
2354
2395
|
}
|
|
2355
2396
|
if (data.options !== undefined) {
|
|
@@ -2582,6 +2623,7 @@ class AnimationOptions {
|
|
|
2582
2623
|
class RangedAnimationOptions extends AnimationOptions {
|
|
2583
2624
|
constructor() {
|
|
2584
2625
|
super();
|
|
2626
|
+
this.mode = "auto";
|
|
2585
2627
|
this.startValue = "random";
|
|
2586
2628
|
}
|
|
2587
2629
|
load(data) {
|
|
@@ -2592,6 +2634,9 @@ class RangedAnimationOptions extends AnimationOptions {
|
|
|
2592
2634
|
if (data.minimumValue !== undefined) {
|
|
2593
2635
|
this.minimumValue = data.minimumValue;
|
|
2594
2636
|
}
|
|
2637
|
+
if (data.mode !== undefined) {
|
|
2638
|
+
this.mode = data.mode;
|
|
2639
|
+
}
|
|
2595
2640
|
if (data.startValue !== undefined) {
|
|
2596
2641
|
this.startValue = data.startValue;
|
|
2597
2642
|
}
|
|
@@ -3238,12 +3283,20 @@ class Shape {
|
|
|
3238
3283
|
constructor() {
|
|
3239
3284
|
this.options = {};
|
|
3240
3285
|
this.type = "circle";
|
|
3286
|
+
this.close = true;
|
|
3287
|
+
this.fill = true;
|
|
3241
3288
|
}
|
|
3242
3289
|
load(data) {
|
|
3243
3290
|
var _a;
|
|
3244
3291
|
if (!data) {
|
|
3245
3292
|
return;
|
|
3246
3293
|
}
|
|
3294
|
+
if (data.close !== undefined) {
|
|
3295
|
+
this.close = data.close;
|
|
3296
|
+
}
|
|
3297
|
+
if (data.fill !== undefined) {
|
|
3298
|
+
this.fill = data.fill;
|
|
3299
|
+
}
|
|
3247
3300
|
const options = data.options;
|
|
3248
3301
|
if (options !== undefined) {
|
|
3249
3302
|
for (const shape in options) {
|
|
@@ -4010,7 +4063,10 @@ class Particle {
|
|
|
4010
4063
|
_loadShapeData(shapeOptions, reduceDuplicates) {
|
|
4011
4064
|
const shapeData = shapeOptions.options[this.shape];
|
|
4012
4065
|
if (shapeData) {
|
|
4013
|
-
return deepExtend({
|
|
4066
|
+
return deepExtend({
|
|
4067
|
+
close: shapeOptions.close,
|
|
4068
|
+
fill: shapeOptions.fill
|
|
4069
|
+
}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
|
|
4014
4070
|
}
|
|
4015
4071
|
}
|
|
4016
4072
|
}
|
|
@@ -4193,10 +4249,10 @@ class Particles {
|
|
|
4193
4249
|
const container = this.container,
|
|
4194
4250
|
options = container.actualOptions;
|
|
4195
4251
|
for (const particle of options.manualParticles) {
|
|
4196
|
-
this.addParticle(calcPositionFromSize({
|
|
4252
|
+
this.addParticle(particle.position ? particle.position.mode === "precise" ? particle.position : calcPositionFromSize({
|
|
4197
4253
|
size: container.canvas.size,
|
|
4198
4254
|
position: particle.position
|
|
4199
|
-
}), particle.options);
|
|
4255
|
+
}) : undefined, particle.options);
|
|
4200
4256
|
}
|
|
4201
4257
|
}
|
|
4202
4258
|
addParticle(position, overrideOptions, group, initializer) {
|
|
@@ -4300,22 +4356,9 @@ class Particles {
|
|
|
4300
4356
|
}
|
|
4301
4357
|
let deleted = 0;
|
|
4302
4358
|
for (let i = index; deleted < quantity && i < this.count; i++) {
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
continue;
|
|
4359
|
+
if (this._removeParticle(i--, group, override)) {
|
|
4360
|
+
deleted++;
|
|
4306
4361
|
}
|
|
4307
|
-
particle.destroy(override);
|
|
4308
|
-
this.array.splice(i--, 1);
|
|
4309
|
-
const idx = this.zArray.indexOf(particle);
|
|
4310
|
-
this.zArray.splice(idx, 1);
|
|
4311
|
-
this.pool.push(particle);
|
|
4312
|
-
deleted++;
|
|
4313
|
-
this._engine.dispatchEvent("particleRemoved", {
|
|
4314
|
-
container: this.container,
|
|
4315
|
-
data: {
|
|
4316
|
-
particle
|
|
4317
|
-
}
|
|
4318
|
-
});
|
|
4319
4362
|
}
|
|
4320
4363
|
}
|
|
4321
4364
|
removeQuantity(quantity, group) {
|
|
@@ -4436,6 +4479,24 @@ class Particles {
|
|
|
4436
4479
|
return;
|
|
4437
4480
|
}
|
|
4438
4481
|
}
|
|
4482
|
+
_removeParticle(index, group, override) {
|
|
4483
|
+
const particle = this.array[index];
|
|
4484
|
+
if (!particle || particle.group !== group) {
|
|
4485
|
+
return false;
|
|
4486
|
+
}
|
|
4487
|
+
particle.destroy(override);
|
|
4488
|
+
this.array.splice(index, 1);
|
|
4489
|
+
const zIdx = this.zArray.indexOf(particle);
|
|
4490
|
+
this.zArray.splice(zIdx, 1);
|
|
4491
|
+
this.pool.push(particle);
|
|
4492
|
+
this._engine.dispatchEvent("particleRemoved", {
|
|
4493
|
+
container: this.container,
|
|
4494
|
+
data: {
|
|
4495
|
+
particle
|
|
4496
|
+
}
|
|
4497
|
+
});
|
|
4498
|
+
return true;
|
|
4499
|
+
}
|
|
4439
4500
|
}
|
|
4440
4501
|
;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Retina.js
|
|
4441
4502
|
|
|
@@ -5562,6 +5623,7 @@ const tsParticles = new Engine();
|
|
|
5562
5623
|
|
|
5563
5624
|
|
|
5564
5625
|
|
|
5626
|
+
|
|
5565
5627
|
|
|
5566
5628
|
|
|
5567
5629
|
;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/Options/Classes/RotateAnimation.js
|