@tsparticles/engine 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/README.md +62 -83
- package/browser/Core/Particle.js +4 -1
- package/browser/Core/Particles.js +28 -19
- package/browser/Core/Utils/EventListeners.js +83 -68
- package/browser/Enums/Modes/AnimationMode.js +1 -0
- package/browser/Options/Classes/AnimationOptions.js +4 -0
- package/browser/Options/Classes/ManualParticle.js +2 -1
- package/browser/Options/Classes/Particles/Shape/Shape.js +8 -0
- package/browser/Utils/Utils.js +24 -4
- package/browser/bundle.js +1 -0
- package/browser/index.js +1 -0
- package/cjs/Core/Particle.js +4 -1
- package/cjs/Core/Particles.js +28 -19
- package/cjs/Core/Utils/EventListeners.js +83 -68
- package/cjs/Enums/Modes/AnimationMode.js +2 -0
- package/cjs/Options/Classes/AnimationOptions.js +4 -0
- package/cjs/Options/Classes/ManualParticle.js +2 -1
- package/cjs/Options/Classes/Particles/Shape/Shape.js +8 -0
- package/cjs/Utils/Utils.js +24 -4
- package/cjs/bundle.js +1 -0
- package/cjs/index.js +1 -0
- package/esm/Core/Particle.js +4 -1
- package/esm/Core/Particles.js +28 -19
- package/esm/Core/Utils/EventListeners.js +83 -68
- package/esm/Enums/Modes/AnimationMode.js +1 -0
- package/esm/Options/Classes/AnimationOptions.js +4 -0
- package/esm/Options/Classes/ManualParticle.js +2 -1
- package/esm/Options/Classes/Particles/Shape/Shape.js +8 -0
- package/esm/Utils/Utils.js +24 -4
- package/esm/bundle.js +1 -0
- package/esm/index.js +1 -0
- package/package.json +1 -1
- package/report.html +2 -2
- package/tsparticles.engine.js +152 -90
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Interfaces/ICoordinates.d.ts +3 -1
- package/types/Core/Interfaces/IDimension.d.ts +4 -0
- package/types/Core/Particles.d.ts +1 -0
- package/types/Core/Utils/EventListeners.d.ts +14 -10
- package/types/Enums/Modes/AnimationMode.d.ts +6 -0
- package/types/Options/Classes/AnimationOptions.d.ts +2 -0
- package/types/Options/Classes/ManualParticle.d.ts +2 -2
- package/types/Options/Classes/Particles/Move/Spin.d.ts +2 -2
- package/types/Options/Classes/Particles/Shape/Shape.d.ts +2 -0
- package/types/Options/Interfaces/IAnimation.d.ts +2 -0
- package/types/Options/Interfaces/IManualParticle.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -0
- package/types/bundle.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/umd/Core/Particle.js +4 -1
- package/umd/Core/Particles.js +28 -19
- package/umd/Core/Utils/EventListeners.js +83 -68
- package/umd/Enums/Modes/AnimationMode.js +12 -0
- package/umd/Options/Classes/AnimationOptions.js +4 -0
- package/umd/Options/Classes/ManualParticle.js +2 -1
- package/umd/Options/Classes/Particles/Shape/Shape.js +8 -0
- package/umd/Utils/Utils.js +24 -4
- package/umd/bundle.js +2 -1
- package/umd/index.js +2 -1
package/README.md
CHANGED
|
@@ -30,48 +30,67 @@ React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.j
|
|
|
30
30
|
|
|
31
31
|
## Table of Contents
|
|
32
32
|
|
|
33
|
-
- [
|
|
34
|
-
|
|
35
|
-
- [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
- [
|
|
71
|
-
- [
|
|
72
|
-
- [
|
|
73
|
-
- [
|
|
74
|
-
- [
|
|
33
|
+
- [tsParticles - TypeScript Particles](#tsparticles---typescript-particles)
|
|
34
|
+
- [Table of Contents](#table-of-contents)
|
|
35
|
+
- [Do you want to use it on your website?](#do-you-want-to-use-it-on-your-website)
|
|
36
|
+
- [**_Library installation_**](#library-installation)
|
|
37
|
+
- [**_Hosting / CDN_**](#hosting--cdn)
|
|
38
|
+
- [jsDelivr](#jsdelivr)
|
|
39
|
+
- [cdnjs](#cdnjs)
|
|
40
|
+
- [unpkg](#unpkg)
|
|
41
|
+
- [**_npm_**](#npm)
|
|
42
|
+
- [**_yarn_**](#yarn)
|
|
43
|
+
- [**_pnpm_**](#pnpm)
|
|
44
|
+
- [Import and require](#import-and-require)
|
|
45
|
+
- [**_NuGet_**](#nuget)
|
|
46
|
+
- [**_Usage_**](#usage)
|
|
47
|
+
- [Official components for some of the most used frameworks](#official-components-for-some-of-the-most-used-frameworks)
|
|
48
|
+
- [Angular](#angular)
|
|
49
|
+
- [Ember](#ember)
|
|
50
|
+
- [Inferno](#inferno)
|
|
51
|
+
- [jQuery](#jquery)
|
|
52
|
+
- [Preact](#preact)
|
|
53
|
+
- [ReactJS](#reactjs)
|
|
54
|
+
- [RiotJS](#riotjs)
|
|
55
|
+
- [`@tsparticles/riot`](#tsparticlesriot)
|
|
56
|
+
- [SolidJS](#solidjs)
|
|
57
|
+
- [`@tsparticles/solid`](#tsparticlessolid)
|
|
58
|
+
- [Svelte](#svelte)
|
|
59
|
+
- [VueJS 2.x](#vuejs-2x)
|
|
60
|
+
- [VueJS 3.x](#vuejs-3x)
|
|
61
|
+
- [Web Components](#web-components)
|
|
62
|
+
- [`@tsparticles/webcomponents`](#tsparticleswebcomponents)
|
|
63
|
+
- [WordPress](#wordpress)
|
|
64
|
+
- [`@tsparticles/wordpress`](#tsparticleswordpress)
|
|
65
|
+
- [Elementor](#elementor)
|
|
66
|
+
- [Presets](#presets)
|
|
67
|
+
- [Big Circles](#big-circles)
|
|
68
|
+
- [Bubbles](#bubbles)
|
|
69
|
+
- [Confetti](#confetti)
|
|
70
|
+
- [Fire](#fire)
|
|
71
|
+
- [Firefly](#firefly)
|
|
72
|
+
- [Fireworks](#fireworks)
|
|
73
|
+
- [Fountain](#fountain)
|
|
74
|
+
- [Links](#links)
|
|
75
|
+
- [Sea Anemone](#sea-anemone)
|
|
76
|
+
- [Snow](#snow)
|
|
77
|
+
- [Stars](#stars)
|
|
78
|
+
- [Triangles](#triangles)
|
|
79
|
+
- [Templates and Resources](#templates-and-resources)
|
|
80
|
+
- [**_Demo / Generator_**](#demo--generator)
|
|
81
|
+
- [**_Video Tutorials_**](#video-tutorials)
|
|
82
|
+
- [Characters as particles](#characters-as-particles)
|
|
83
|
+
- [Polygon mask](#polygon-mask)
|
|
84
|
+
- [Animated stars](#animated-stars)
|
|
85
|
+
- [Nyan cat flying on scrolling stars](#nyan-cat-flying-on-scrolling-stars)
|
|
86
|
+
- [Snow particles](#snow-particles)
|
|
87
|
+
- [Background Mask particles](#background-mask-particles)
|
|
88
|
+
- [**_Options_**](#options)
|
|
89
|
+
- [Want to see it in action and try it?](#want-to-see-it-in-action-and-try-it)
|
|
90
|
+
- [Migrating from Particles.js](#migrating-from-particlesjs)
|
|
91
|
+
- [Plugins/Customizations](#pluginscustomizations)
|
|
92
|
+
- [Dependency Graphs](#dependency-graphs)
|
|
93
|
+
- [Huge thanks to JetBrains for the 2020-2022 Open Source Licenses!](#huge-thanks-to-jetbrains-for-the-2020-2022-open-source-licenses)
|
|
75
94
|
|
|
76
95
|
---
|
|
77
96
|
|
|
@@ -636,28 +655,7 @@ _Read more [here](https://particles.js.org/docs/modules/Core_Interfaces_IPlugin.
|
|
|
636
655
|
|
|
637
656
|
---
|
|
638
657
|
|
|
639
|
-
## Dependency
|
|
640
|
-
|
|
641
|
-
```mermaid
|
|
642
|
-
flowchart TD
|
|
643
|
-
|
|
644
|
-
subgraph c [Components]
|
|
645
|
-
ca[Angular]
|
|
646
|
-
ci[Inferno.js]
|
|
647
|
-
cj[JQuery]
|
|
648
|
-
cp[Preact]
|
|
649
|
-
cre[React.js]
|
|
650
|
-
cri[Riot.js]
|
|
651
|
-
cso[Solid.js]
|
|
652
|
-
csv[Svelte]
|
|
653
|
-
cv2[Vue.js 2.x]
|
|
654
|
-
cv3[Vue.js 3.x]
|
|
655
|
-
cwc[Web Components]
|
|
656
|
-
cwp[WordPress]
|
|
657
|
-
end
|
|
658
|
-
|
|
659
|
-
e[tsParticles Engine] --> c
|
|
660
|
-
```
|
|
658
|
+
## Dependency Graph
|
|
661
659
|
|
|
662
660
|
```mermaid
|
|
663
661
|
flowchart LR
|
|
@@ -787,23 +785,6 @@ uw[Wobble]
|
|
|
787
785
|
end
|
|
788
786
|
|
|
789
787
|
e --> u
|
|
790
|
-
|
|
791
|
-
subgraph pr [Presets]
|
|
792
|
-
prbi[Big Circles]
|
|
793
|
-
prbu[Bubbles]
|
|
794
|
-
prc[Confetti]
|
|
795
|
-
prf[Fire]
|
|
796
|
-
prff[Firefly]
|
|
797
|
-
prfw[Fireworks]
|
|
798
|
-
prfo[Fountain]
|
|
799
|
-
prl[Links]
|
|
800
|
-
prsa[Sea Anemone]
|
|
801
|
-
prsn[Snow]
|
|
802
|
-
prst[Stars]
|
|
803
|
-
prt[Triangles]
|
|
804
|
-
end
|
|
805
|
-
|
|
806
|
-
e --> pr
|
|
807
788
|
```
|
|
808
789
|
|
|
809
790
|
---
|
|
@@ -820,5 +801,3 @@ e --> pr
|
|
|
820
801
|
### Huge thanks to [JetBrains](https://www.jetbrains.com/?from=tsParticles) for the 2020-2022 Open Source Licenses!
|
|
821
802
|
|
|
822
803
|
[JetBrains WebStorm](https://www.jetbrains.com/webstorm/?from=tsParticles) is used to maintain this project.
|
|
823
|
-
|
|
824
|
-
---
|
package/browser/Core/Particle.js
CHANGED
|
@@ -301,7 +301,10 @@ export class Particle {
|
|
|
301
301
|
_loadShapeData(shapeOptions, reduceDuplicates) {
|
|
302
302
|
const shapeData = shapeOptions.options[this.shape];
|
|
303
303
|
if (shapeData) {
|
|
304
|
-
return deepExtend({
|
|
304
|
+
return deepExtend({
|
|
305
|
+
close: shapeOptions.close,
|
|
306
|
+
fill: shapeOptions.fill,
|
|
307
|
+
}, itemFromSingleOrMultiple(shapeData, this.id, reduceDuplicates));
|
|
305
308
|
}
|
|
306
309
|
}
|
|
307
310
|
}
|
|
@@ -27,10 +27,14 @@ export class Particles {
|
|
|
27
27
|
addManualParticles() {
|
|
28
28
|
const container = this.container, options = container.actualOptions;
|
|
29
29
|
for (const particle of options.manualParticles) {
|
|
30
|
-
this.addParticle(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
this.addParticle(particle.position
|
|
31
|
+
? particle.position.mode === "precise"
|
|
32
|
+
? particle.position
|
|
33
|
+
: calcPositionFromSize({
|
|
34
|
+
size: container.canvas.size,
|
|
35
|
+
position: particle.position,
|
|
36
|
+
})
|
|
37
|
+
: undefined, particle.options);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
addParticle(position, overrideOptions, group, initializer) {
|
|
@@ -127,22 +131,9 @@ export class Particles {
|
|
|
127
131
|
}
|
|
128
132
|
let deleted = 0;
|
|
129
133
|
for (let i = index; deleted < quantity && i < this.count; i++) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
continue;
|
|
134
|
+
if (this._removeParticle(i--, group, override)) {
|
|
135
|
+
deleted++;
|
|
133
136
|
}
|
|
134
|
-
particle.destroy(override);
|
|
135
|
-
this.array.splice(i--, 1);
|
|
136
|
-
const idx = this.zArray.indexOf(particle);
|
|
137
|
-
this.zArray.splice(idx, 1);
|
|
138
|
-
this.pool.push(particle);
|
|
139
|
-
deleted++;
|
|
140
|
-
this._engine.dispatchEvent("particleRemoved", {
|
|
141
|
-
container: this.container,
|
|
142
|
-
data: {
|
|
143
|
-
particle,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
137
|
}
|
|
147
138
|
}
|
|
148
139
|
removeQuantity(quantity, group) {
|
|
@@ -259,4 +250,22 @@ export class Particles {
|
|
|
259
250
|
return;
|
|
260
251
|
}
|
|
261
252
|
}
|
|
253
|
+
_removeParticle(index, group, override) {
|
|
254
|
+
const particle = this.array[index];
|
|
255
|
+
if (!particle || particle.group !== group) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
particle.destroy(override);
|
|
259
|
+
this.array.splice(index, 1);
|
|
260
|
+
const zIdx = this.zArray.indexOf(particle);
|
|
261
|
+
this.zArray.splice(zIdx, 1);
|
|
262
|
+
this.pool.push(particle);
|
|
263
|
+
this._engine.dispatchEvent("particleRemoved", {
|
|
264
|
+
container: this.container,
|
|
265
|
+
data: {
|
|
266
|
+
particle,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
262
271
|
}
|
|
@@ -21,28 +21,28 @@ export class EventListeners {
|
|
|
21
21
|
this.container = container;
|
|
22
22
|
this.canPush = true;
|
|
23
23
|
this.handlers = {
|
|
24
|
-
mouseMove: (e) => this.
|
|
25
|
-
touchStart: (e) => this.
|
|
26
|
-
touchMove: (e) => this.
|
|
27
|
-
touchEnd: () => this.
|
|
28
|
-
mouseLeave: () => this.
|
|
29
|
-
touchCancel: () => this.
|
|
30
|
-
touchEndClick: (e) => this.
|
|
31
|
-
mouseUp: (e) => this.
|
|
32
|
-
mouseDown: () => this.
|
|
33
|
-
visibilityChange: () => this.
|
|
34
|
-
themeChange: (e) => this.
|
|
35
|
-
oldThemeChange: (e) => this.
|
|
36
|
-
resize: () => this.
|
|
24
|
+
mouseMove: (e) => this._mouseTouchMove(e),
|
|
25
|
+
touchStart: (e) => this._mouseTouchMove(e),
|
|
26
|
+
touchMove: (e) => this._mouseTouchMove(e),
|
|
27
|
+
touchEnd: () => this._mouseTouchFinish(),
|
|
28
|
+
mouseLeave: () => this._mouseTouchFinish(),
|
|
29
|
+
touchCancel: () => this._mouseTouchFinish(),
|
|
30
|
+
touchEndClick: (e) => this._mouseTouchClick(e),
|
|
31
|
+
mouseUp: (e) => this._mouseTouchClick(e),
|
|
32
|
+
mouseDown: () => this._mouseDown(),
|
|
33
|
+
visibilityChange: () => this._handleVisibilityChange(),
|
|
34
|
+
themeChange: (e) => this._handleThemeChange(e),
|
|
35
|
+
oldThemeChange: (e) => this._handleThemeChange(e),
|
|
36
|
+
resize: () => this._handleWindowResize(),
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
addListeners() {
|
|
40
|
-
this.
|
|
40
|
+
this._manageListeners(true);
|
|
41
41
|
}
|
|
42
42
|
removeListeners() {
|
|
43
|
-
this.
|
|
43
|
+
this._manageListeners(false);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
_doMouseTouchClick(e) {
|
|
46
46
|
const container = this.container, options = container.actualOptions;
|
|
47
47
|
if (this.canPush) {
|
|
48
48
|
const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
|
|
@@ -52,33 +52,32 @@ export class EventListeners {
|
|
|
52
52
|
mouseInteractivity.clickPosition = Object.assign({}, mousePos);
|
|
53
53
|
mouseInteractivity.clickTime = new Date().getTime();
|
|
54
54
|
const onClick = options.interactivity.events.onClick;
|
|
55
|
-
executeOnSingleOrMultiple(onClick.mode, (mode) => this.
|
|
55
|
+
executeOnSingleOrMultiple(onClick.mode, (mode) => this._handleClickMode(mode));
|
|
56
56
|
}
|
|
57
57
|
if (e.type === "touchend") {
|
|
58
|
-
setTimeout(() => this.
|
|
58
|
+
setTimeout(() => this._mouseTouchFinish(), 500);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
_handleClickMode(mode) {
|
|
62
62
|
this.container.handleClickMode(mode);
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
_handleThemeChange(e) {
|
|
65
65
|
const mediaEvent = e, container = this.container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes.find((theme) => theme.name === themeName);
|
|
66
66
|
if (theme && theme.default.auto) {
|
|
67
67
|
container.loadTheme(themeName);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
_handleVisibilityChange() {
|
|
71
71
|
const container = this.container, options = container.actualOptions;
|
|
72
|
-
this.
|
|
72
|
+
this._mouseTouchFinish();
|
|
73
73
|
if (!options.pauseOnBlur) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
|
|
77
|
+
if (container.pageHidden) {
|
|
78
78
|
container.pause();
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
container.pageHidden = false;
|
|
82
81
|
if (container.getAnimationStatus()) {
|
|
83
82
|
container.play(true);
|
|
84
83
|
}
|
|
@@ -87,14 +86,14 @@ export class EventListeners {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
_handleWindowResize() {
|
|
91
90
|
if (this.resizeTimeout) {
|
|
92
91
|
clearTimeout(this.resizeTimeout);
|
|
93
92
|
delete this.resizeTimeout;
|
|
94
93
|
}
|
|
95
94
|
this.resizeTimeout = setTimeout(async () => { var _a; return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
|
|
96
95
|
}
|
|
97
|
-
|
|
96
|
+
_manageInteractivityEvents(add) {
|
|
98
97
|
var _a;
|
|
99
98
|
const handlers = this.handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn;
|
|
100
99
|
let mouseLeaveTmpEvent = mouseLeaveEvent;
|
|
@@ -109,20 +108,6 @@ export class EventListeners {
|
|
|
109
108
|
else {
|
|
110
109
|
container.interactivity.element = container.canvas.element;
|
|
111
110
|
}
|
|
112
|
-
const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
113
|
-
if (mediaMatch) {
|
|
114
|
-
if (mediaMatch.addEventListener !== undefined) {
|
|
115
|
-
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
116
|
-
}
|
|
117
|
-
else if (mediaMatch.addListener !== undefined) {
|
|
118
|
-
if (add) {
|
|
119
|
-
mediaMatch.addListener(handlers.oldThemeChange);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
111
|
const interactivityEl = container.interactivity.element;
|
|
127
112
|
if (!interactivityEl) {
|
|
128
113
|
return;
|
|
@@ -146,35 +131,65 @@ export class EventListeners {
|
|
|
146
131
|
if (container.canvas.element) {
|
|
147
132
|
container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
|
|
148
133
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
134
|
+
}
|
|
135
|
+
_manageListeners(add) {
|
|
136
|
+
this._manageMediaEvents(add);
|
|
137
|
+
this._manageInteractivityEvents(add);
|
|
138
|
+
this._manageResizeEvent(add);
|
|
139
|
+
this._manageVisibilityEvent(add);
|
|
140
|
+
}
|
|
141
|
+
_manageMediaEvents(add) {
|
|
142
|
+
const handlers = this.handlers, mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
143
|
+
if (!mediaMatch) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
147
|
+
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (mediaMatch.addListener !== undefined) {
|
|
151
|
+
if (add) {
|
|
152
|
+
mediaMatch.addListener(handlers.oldThemeChange);
|
|
168
153
|
}
|
|
169
154
|
else {
|
|
170
|
-
|
|
155
|
+
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
_manageResizeEvent(add) {
|
|
160
|
+
const handlers = this.handlers, container = this.container, options = container.actualOptions;
|
|
161
|
+
if (!options.interactivity.events.resize) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (typeof ResizeObserver === "undefined") {
|
|
165
|
+
manageListener(window, resizeEvent, handlers.resize, add);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (this.resizeObserver && !add) {
|
|
169
|
+
if (container.canvas.element) {
|
|
170
|
+
this.resizeObserver.unobserve(container.canvas.element);
|
|
171
171
|
}
|
|
172
|
+
this.resizeObserver.disconnect();
|
|
173
|
+
delete this.resizeObserver;
|
|
174
|
+
}
|
|
175
|
+
else if (!this.resizeObserver && add && container.canvas.element) {
|
|
176
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
177
|
+
const entry = entries.find((e) => e.target === container.canvas.element);
|
|
178
|
+
if (!entry) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this._handleWindowResize();
|
|
182
|
+
});
|
|
183
|
+
this.resizeObserver.observe(container.canvas.element);
|
|
172
184
|
}
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
}
|
|
186
|
+
_manageVisibilityEvent(add) {
|
|
187
|
+
if (!document) {
|
|
188
|
+
return;
|
|
175
189
|
}
|
|
190
|
+
manageListener(document, visibilityChangeEvent, this.handlers.visibilityChange, add);
|
|
176
191
|
}
|
|
177
|
-
|
|
192
|
+
_mouseDown() {
|
|
178
193
|
const interactivity = this.container.interactivity;
|
|
179
194
|
if (interactivity) {
|
|
180
195
|
const mouse = interactivity.mouse;
|
|
@@ -182,7 +197,7 @@ export class EventListeners {
|
|
|
182
197
|
mouse.downPosition = mouse.position;
|
|
183
198
|
}
|
|
184
199
|
}
|
|
185
|
-
|
|
200
|
+
_mouseTouchClick(e) {
|
|
186
201
|
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse;
|
|
187
202
|
mouse.inside = true;
|
|
188
203
|
let handled = false;
|
|
@@ -200,11 +215,11 @@ export class EventListeners {
|
|
|
200
215
|
}
|
|
201
216
|
}
|
|
202
217
|
if (!handled) {
|
|
203
|
-
this.
|
|
218
|
+
this._doMouseTouchClick(e);
|
|
204
219
|
}
|
|
205
220
|
mouse.clicking = false;
|
|
206
221
|
}
|
|
207
|
-
|
|
222
|
+
_mouseTouchFinish() {
|
|
208
223
|
const interactivity = this.container.interactivity;
|
|
209
224
|
if (!interactivity) {
|
|
210
225
|
return;
|
|
@@ -217,7 +232,7 @@ export class EventListeners {
|
|
|
217
232
|
mouse.inside = false;
|
|
218
233
|
mouse.clicking = false;
|
|
219
234
|
}
|
|
220
|
-
|
|
235
|
+
_mouseTouchMove(e) {
|
|
221
236
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
222
237
|
const container = this.container, options = container.actualOptions;
|
|
223
238
|
if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -31,6 +31,7 @@ export class AnimationOptions {
|
|
|
31
31
|
export class RangedAnimationOptions extends AnimationOptions {
|
|
32
32
|
constructor() {
|
|
33
33
|
super();
|
|
34
|
+
this.mode = "auto";
|
|
34
35
|
this.startValue = "random";
|
|
35
36
|
}
|
|
36
37
|
load(data) {
|
|
@@ -41,6 +42,9 @@ export class RangedAnimationOptions extends AnimationOptions {
|
|
|
41
42
|
if (data.minimumValue !== undefined) {
|
|
42
43
|
this.minimumValue = data.minimumValue;
|
|
43
44
|
}
|
|
45
|
+
if (data.mode !== undefined) {
|
|
46
|
+
this.mode = data.mode;
|
|
47
|
+
}
|
|
44
48
|
if (data.startValue !== undefined) {
|
|
45
49
|
this.startValue = data.startValue;
|
|
46
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepExtend } from "../../Utils/Utils";
|
|
2
2
|
export class ManualParticle {
|
|
3
3
|
load(data) {
|
|
4
|
-
var _a, _b;
|
|
4
|
+
var _a, _b, _c;
|
|
5
5
|
if (!data) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
@@ -9,6 +9,7 @@ export class ManualParticle {
|
|
|
9
9
|
this.position = {
|
|
10
10
|
x: (_a = data.position.x) !== null && _a !== void 0 ? _a : 50,
|
|
11
11
|
y: (_b = data.position.y) !== null && _b !== void 0 ? _b : 50,
|
|
12
|
+
mode: (_c = data.position.mode) !== null && _c !== void 0 ? _c : "percent",
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
if (data.options !== undefined) {
|
|
@@ -3,12 +3,20 @@ export class Shape {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this.options = {};
|
|
5
5
|
this.type = "circle";
|
|
6
|
+
this.close = true;
|
|
7
|
+
this.fill = true;
|
|
6
8
|
}
|
|
7
9
|
load(data) {
|
|
8
10
|
var _a;
|
|
9
11
|
if (!data) {
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
14
|
+
if (data.close !== undefined) {
|
|
15
|
+
this.close = data.close;
|
|
16
|
+
}
|
|
17
|
+
if (data.fill !== undefined) {
|
|
18
|
+
this.fill = data.fill;
|
|
19
|
+
}
|
|
12
20
|
const options = data.options;
|
|
13
21
|
if (options !== undefined) {
|
|
14
22
|
for (const shape in options) {
|
package/browser/Utils/Utils.js
CHANGED
|
@@ -224,21 +224,41 @@ export function initParticleNumericAnimationValue(options, pxRatio) {
|
|
|
224
224
|
maxLoops: getRangeValue(options.animation.count),
|
|
225
225
|
};
|
|
226
226
|
if (animationOptions.enable) {
|
|
227
|
-
res.status = "increasing";
|
|
228
227
|
res.decay = 1 - getRangeValue(animationOptions.decay);
|
|
228
|
+
let autoStatus = false;
|
|
229
|
+
switch (animationOptions.mode) {
|
|
230
|
+
case "increase":
|
|
231
|
+
res.status = "increasing";
|
|
232
|
+
break;
|
|
233
|
+
case "decrease":
|
|
234
|
+
res.status = "decreasing";
|
|
235
|
+
break;
|
|
236
|
+
case "random":
|
|
237
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
238
|
+
break;
|
|
239
|
+
case "auto":
|
|
240
|
+
autoStatus = true;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
229
243
|
switch (animationOptions.startValue) {
|
|
230
244
|
case "min":
|
|
231
245
|
res.value = res.min;
|
|
232
|
-
|
|
246
|
+
if (autoStatus) {
|
|
247
|
+
res.status = "increasing";
|
|
248
|
+
}
|
|
233
249
|
break;
|
|
234
250
|
case "random":
|
|
235
251
|
res.value = randomInRange(res);
|
|
236
|
-
|
|
252
|
+
if (autoStatus) {
|
|
253
|
+
res.status = getRandom() >= 0.5 ? "increasing" : "decreasing";
|
|
254
|
+
}
|
|
237
255
|
break;
|
|
238
256
|
case "max":
|
|
239
257
|
default:
|
|
240
258
|
res.value = res.max;
|
|
241
|
-
|
|
259
|
+
if (autoStatus) {
|
|
260
|
+
res.status = "decreasing";
|
|
261
|
+
}
|
|
242
262
|
break;
|
|
243
263
|
}
|
|
244
264
|
}
|
package/browser/bundle.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./Core/Utils/Vector3d";
|
|
|
18
18
|
export * from "./Enums/Directions/MoveDirection";
|
|
19
19
|
export * from "./Enums/Directions/RotateDirection";
|
|
20
20
|
export * from "./Enums/Directions/OutModeDirection";
|
|
21
|
+
export * from "./Enums/Modes/AnimationMode";
|
|
21
22
|
export * from "./Enums/Modes/ClickMode";
|
|
22
23
|
export * from "./Enums/Modes/DivMode";
|
|
23
24
|
export * from "./Enums/Modes/HoverMode";
|
package/browser/index.js
CHANGED
|
@@ -53,6 +53,7 @@ export * from "./Core/Utils/Vector3d";
|
|
|
53
53
|
export * from "./Enums/Directions/MoveDirection";
|
|
54
54
|
export * from "./Enums/Directions/RotateDirection";
|
|
55
55
|
export * from "./Enums/Directions/OutModeDirection";
|
|
56
|
+
export * from "./Enums/Modes/AnimationMode";
|
|
56
57
|
export * from "./Enums/Modes/ClickMode";
|
|
57
58
|
export * from "./Enums/Modes/DivMode";
|
|
58
59
|
export * from "./Enums/Modes/HoverMode";
|
package/cjs/Core/Particle.js
CHANGED
|
@@ -304,7 +304,10 @@ class Particle {
|
|
|
304
304
|
_loadShapeData(shapeOptions, reduceDuplicates) {
|
|
305
305
|
const shapeData = shapeOptions.options[this.shape];
|
|
306
306
|
if (shapeData) {
|
|
307
|
-
return (0, Utils_1.deepExtend)({
|
|
307
|
+
return (0, Utils_1.deepExtend)({
|
|
308
|
+
close: shapeOptions.close,
|
|
309
|
+
fill: shapeOptions.fill,
|
|
310
|
+
}, (0, Utils_1.itemFromSingleOrMultiple)(shapeData, this.id, reduceDuplicates));
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
}
|