tsparticles 1.37.6 → 1.38.0
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/Core/Canvas.d.ts +2 -2
- package/Core/Canvas.js +17 -7
- package/Core/Loader.js +4 -9
- package/Options/Classes/Options.d.ts +1 -0
- package/Options/Classes/Options.js +2 -0
- package/Options/Interfaces/IOptions.d.ts +1 -0
- package/Utils/Constants.d.ts +1 -1
- package/Utils/Constants.js +1 -1
- package/Utils/EventListeners.js +1 -1
- package/browser/Core/Canvas.d.ts +2 -2
- package/browser/Core/Canvas.js +17 -7
- package/browser/Core/Loader.js +4 -9
- package/browser/Options/Classes/Options.d.ts +1 -0
- package/browser/Options/Classes/Options.js +3 -1
- package/browser/Options/Interfaces/IOptions.d.ts +1 -0
- package/browser/Utils/Constants.d.ts +1 -4
- package/browser/Utils/Constants.js +1 -4
- package/browser/Utils/EventListeners.js +1 -1
- package/esm/Core/Canvas.d.ts +2 -2
- package/esm/Core/Canvas.js +17 -7
- package/esm/Core/Loader.js +4 -9
- package/esm/Options/Classes/Options.d.ts +1 -0
- package/esm/Options/Classes/Options.js +3 -1
- package/esm/Options/Interfaces/IOptions.d.ts +1 -0
- package/esm/Utils/Constants.d.ts +1 -1
- package/esm/Utils/Constants.js +1 -1
- package/esm/Utils/EventListeners.js +1 -1
- package/package.json +1 -1
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/tsparticles.js +23 -19
- package/tsparticles.min.js +2 -2
- package/tsparticles.slim.js +23 -19
- package/tsparticles.slim.min.js +2 -2
package/Core/Canvas.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ export declare class Canvas {
|
|
|
13
13
|
private originalStyle?;
|
|
14
14
|
constructor(container: Container);
|
|
15
15
|
init(): void;
|
|
16
|
-
loadCanvas(canvas: HTMLCanvasElement
|
|
16
|
+
loadCanvas(canvas: HTMLCanvasElement): void;
|
|
17
17
|
destroy(): void;
|
|
18
18
|
paint(): void;
|
|
19
19
|
clear(): void;
|
|
20
|
-
windowResize(): void
|
|
20
|
+
windowResize(): Promise<void>;
|
|
21
21
|
resize(): void;
|
|
22
22
|
drawConnectLine(p1: IParticle, p2: IParticle): void;
|
|
23
23
|
drawGrabLine(particle: IParticle, lineColor: IRgb, opacity: number, mousePos: ICoordinates): void;
|
package/Core/Canvas.js
CHANGED
|
@@ -21,15 +21,15 @@ class Canvas {
|
|
|
21
21
|
this.initBackground();
|
|
22
22
|
this.paint();
|
|
23
23
|
}
|
|
24
|
-
loadCanvas(canvas
|
|
24
|
+
loadCanvas(canvas) {
|
|
25
25
|
var _a;
|
|
26
|
-
if (!canvas.className) {
|
|
27
|
-
canvas.className = Utils_1.Constants.canvasClass;
|
|
28
|
-
}
|
|
29
26
|
if (this.generatedCanvas) {
|
|
30
27
|
(_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
|
|
31
28
|
}
|
|
32
|
-
this.generatedCanvas =
|
|
29
|
+
this.generatedCanvas =
|
|
30
|
+
canvas.dataset && Utils_1.Constants.generatedAttribute in canvas.dataset
|
|
31
|
+
? canvas.dataset[Utils_1.Constants.generatedAttribute] === "true"
|
|
32
|
+
: this.generatedCanvas;
|
|
33
33
|
this.element = canvas;
|
|
34
34
|
this.originalStyle = (0, Utils_1.deepExtend)({}, this.element.style);
|
|
35
35
|
this.size.height = canvas.offsetHeight;
|
|
@@ -74,7 +74,7 @@ class Canvas {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
windowResize() {
|
|
77
|
+
async windowResize() {
|
|
78
78
|
if (!this.element) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
@@ -88,7 +88,7 @@ class Canvas {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
if (needsRefresh) {
|
|
91
|
-
container.refresh();
|
|
91
|
+
await container.refresh();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
resize() {
|
|
@@ -291,6 +291,16 @@ class Canvas {
|
|
|
291
291
|
element.style.width = originalStyle.width;
|
|
292
292
|
element.style.height = originalStyle.height;
|
|
293
293
|
}
|
|
294
|
+
for (const key in options.style) {
|
|
295
|
+
if (!key || !options.style) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const value = options.style[key];
|
|
299
|
+
if (!value) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
element.style[key] = value;
|
|
303
|
+
}
|
|
294
304
|
}
|
|
295
305
|
paintBase(baseColor) {
|
|
296
306
|
this.draw((ctx) => {
|
package/Core/Loader.js
CHANGED
|
@@ -41,24 +41,19 @@ class Loader {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
let canvasEl;
|
|
44
|
-
let generatedCanvas;
|
|
45
44
|
if (domContainer.tagName.toLowerCase() === "canvas") {
|
|
46
45
|
canvasEl = domContainer;
|
|
47
|
-
|
|
46
|
+
canvasEl.dataset[Utils_1.Constants.generatedAttribute] = "false";
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
49
|
const existingCanvases = domContainer.getElementsByTagName("canvas");
|
|
51
50
|
if (existingCanvases.length) {
|
|
52
51
|
canvasEl = existingCanvases[0];
|
|
53
|
-
|
|
54
|
-
canvasEl.className = Utils_1.Constants.canvasClass;
|
|
55
|
-
}
|
|
56
|
-
generatedCanvas = false;
|
|
52
|
+
canvasEl.dataset[Utils_1.Constants.generatedAttribute] = "false";
|
|
57
53
|
}
|
|
58
54
|
else {
|
|
59
|
-
generatedCanvas = true;
|
|
60
55
|
canvasEl = document.createElement("canvas");
|
|
61
|
-
canvasEl.
|
|
56
|
+
canvasEl.dataset[Utils_1.Constants.generatedAttribute] = "true";
|
|
62
57
|
canvasEl.style.width = "100%";
|
|
63
58
|
canvasEl.style.height = "100%";
|
|
64
59
|
domContainer.appendChild(canvasEl);
|
|
@@ -71,7 +66,7 @@ class Loader {
|
|
|
71
66
|
else {
|
|
72
67
|
dom.push(newItem);
|
|
73
68
|
}
|
|
74
|
-
newItem.canvas.loadCanvas(canvasEl
|
|
69
|
+
newItem.canvas.loadCanvas(canvasEl);
|
|
75
70
|
await newItem.start();
|
|
76
71
|
return newItem;
|
|
77
72
|
}
|
|
@@ -32,6 +32,7 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
|
|
|
32
32
|
pauseOnBlur: boolean;
|
|
33
33
|
pauseOnOutsideViewport: boolean;
|
|
34
34
|
preset?: string | string[];
|
|
35
|
+
style: RecursivePartial<CSSStyleDeclaration>;
|
|
35
36
|
responsive: Responsive[];
|
|
36
37
|
themes: Theme[];
|
|
37
38
|
zLayers: number;
|
|
@@ -35,6 +35,7 @@ class Options {
|
|
|
35
35
|
this.pauseOnBlur = true;
|
|
36
36
|
this.pauseOnOutsideViewport = true;
|
|
37
37
|
this.responsive = [];
|
|
38
|
+
this.style = {};
|
|
38
39
|
this.themes = [];
|
|
39
40
|
this.zLayers = 100;
|
|
40
41
|
}
|
|
@@ -113,6 +114,7 @@ class Options {
|
|
|
113
114
|
}
|
|
114
115
|
this.motion.load(data.motion);
|
|
115
116
|
this.particles.load(data.particles);
|
|
117
|
+
this.style = (0, Utils_1.deepExtend)(this.style, data.style);
|
|
116
118
|
Utils_1.Plugins.loadOptions(this, data);
|
|
117
119
|
if (data.responsive !== undefined) {
|
|
118
120
|
for (const responsive of data.responsive) {
|
package/Utils/Constants.d.ts
CHANGED
package/Utils/Constants.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Constants = void 0;
|
|
|
4
4
|
class Constants {
|
|
5
5
|
}
|
|
6
6
|
exports.Constants = Constants;
|
|
7
|
-
Constants.
|
|
7
|
+
Constants.generatedAttribute = "generated";
|
|
8
8
|
Constants.randomColorValue = "random";
|
|
9
9
|
Constants.midColorValue = "mid";
|
|
10
10
|
Constants.touchEndEvent = "touchend";
|
package/Utils/EventListeners.js
CHANGED
|
@@ -131,7 +131,7 @@ class EventListeners {
|
|
|
131
131
|
clearTimeout(this.resizeTimeout);
|
|
132
132
|
delete this.resizeTimeout;
|
|
133
133
|
}
|
|
134
|
-
this.resizeTimeout = setTimeout(() => { var _a; return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); }, 500);
|
|
134
|
+
this.resizeTimeout = setTimeout(async () => { var _a; return await ((_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize()); }, 500);
|
|
135
135
|
}
|
|
136
136
|
handleVisibilityChange() {
|
|
137
137
|
const container = this.container;
|
package/browser/Core/Canvas.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare class Canvas {
|
|
|
33
33
|
* Initializes the canvas element
|
|
34
34
|
*/
|
|
35
35
|
init(): void;
|
|
36
|
-
loadCanvas(canvas: HTMLCanvasElement
|
|
36
|
+
loadCanvas(canvas: HTMLCanvasElement): void;
|
|
37
37
|
destroy(): void;
|
|
38
38
|
/**
|
|
39
39
|
* Paints the canvas background
|
|
@@ -43,7 +43,7 @@ export declare class Canvas {
|
|
|
43
43
|
* Clears the canvas content
|
|
44
44
|
*/
|
|
45
45
|
clear(): void;
|
|
46
|
-
windowResize(): void
|
|
46
|
+
windowResize(): Promise<void>;
|
|
47
47
|
/**
|
|
48
48
|
* Calculates the size of the canvas
|
|
49
49
|
*/
|
package/browser/Core/Canvas.js
CHANGED
|
@@ -30,15 +30,15 @@ export class Canvas {
|
|
|
30
30
|
this.initBackground();
|
|
31
31
|
this.paint();
|
|
32
32
|
}
|
|
33
|
-
loadCanvas(canvas
|
|
33
|
+
loadCanvas(canvas) {
|
|
34
34
|
var _a;
|
|
35
|
-
if (!canvas.className) {
|
|
36
|
-
canvas.className = Constants.canvasClass;
|
|
37
|
-
}
|
|
38
35
|
if (this.generatedCanvas) {
|
|
39
36
|
(_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
|
|
40
37
|
}
|
|
41
|
-
this.generatedCanvas =
|
|
38
|
+
this.generatedCanvas =
|
|
39
|
+
canvas.dataset && Constants.generatedAttribute in canvas.dataset
|
|
40
|
+
? canvas.dataset[Constants.generatedAttribute] === "true"
|
|
41
|
+
: this.generatedCanvas;
|
|
42
42
|
this.element = canvas;
|
|
43
43
|
this.originalStyle = deepExtend({}, this.element.style);
|
|
44
44
|
this.size.height = canvas.offsetHeight;
|
|
@@ -89,7 +89,7 @@ export class Canvas {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
windowResize() {
|
|
92
|
+
async windowResize() {
|
|
93
93
|
if (!this.element) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
@@ -104,7 +104,7 @@ export class Canvas {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if (needsRefresh) {
|
|
107
|
-
container.refresh();
|
|
107
|
+
await container.refresh();
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
@@ -310,6 +310,16 @@ export class Canvas {
|
|
|
310
310
|
element.style.width = originalStyle.width;
|
|
311
311
|
element.style.height = originalStyle.height;
|
|
312
312
|
}
|
|
313
|
+
for (const key in options.style) {
|
|
314
|
+
if (!key || !options.style) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const value = options.style[key];
|
|
318
|
+
if (!value) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
element.style[key] = value;
|
|
322
|
+
}
|
|
313
323
|
}
|
|
314
324
|
paintBase(baseColor) {
|
|
315
325
|
this.draw((ctx) => {
|
package/browser/Core/Loader.js
CHANGED
|
@@ -50,26 +50,21 @@ export class Loader {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
let canvasEl;
|
|
53
|
-
let generatedCanvas;
|
|
54
53
|
if (domContainer.tagName.toLowerCase() === "canvas") {
|
|
55
54
|
canvasEl = domContainer;
|
|
56
|
-
|
|
55
|
+
canvasEl.dataset[Constants.generatedAttribute] = "false";
|
|
57
56
|
}
|
|
58
57
|
else {
|
|
59
58
|
const existingCanvases = domContainer.getElementsByTagName("canvas");
|
|
60
59
|
/* get existing canvas if present, otherwise a new one will be created */
|
|
61
60
|
if (existingCanvases.length) {
|
|
62
61
|
canvasEl = existingCanvases[0];
|
|
63
|
-
|
|
64
|
-
canvasEl.className = Constants.canvasClass;
|
|
65
|
-
}
|
|
66
|
-
generatedCanvas = false;
|
|
62
|
+
canvasEl.dataset[Constants.generatedAttribute] = "false";
|
|
67
63
|
}
|
|
68
64
|
else {
|
|
69
|
-
generatedCanvas = true;
|
|
70
65
|
/* create canvas element */
|
|
71
66
|
canvasEl = document.createElement("canvas");
|
|
72
|
-
canvasEl.
|
|
67
|
+
canvasEl.dataset[Constants.generatedAttribute] = "true";
|
|
73
68
|
/* set size canvas */
|
|
74
69
|
canvasEl.style.width = "100%";
|
|
75
70
|
canvasEl.style.height = "100%";
|
|
@@ -85,7 +80,7 @@ export class Loader {
|
|
|
85
80
|
else {
|
|
86
81
|
dom.push(newItem);
|
|
87
82
|
}
|
|
88
|
-
newItem.canvas.loadCanvas(canvasEl
|
|
83
|
+
newItem.canvas.loadCanvas(canvasEl);
|
|
89
84
|
await newItem.start();
|
|
90
85
|
return newItem;
|
|
91
86
|
}
|
|
@@ -58,6 +58,7 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
|
|
|
58
58
|
pauseOnBlur: boolean;
|
|
59
59
|
pauseOnOutsideViewport: boolean;
|
|
60
60
|
preset?: string | string[];
|
|
61
|
+
style: RecursivePartial<CSSStyleDeclaration>;
|
|
61
62
|
responsive: Responsive[];
|
|
62
63
|
themes: Theme[];
|
|
63
64
|
zLayers: number;
|
|
@@ -8,7 +8,7 @@ import { Interactivity } from "./Interactivity/Interactivity";
|
|
|
8
8
|
import { ParticlesOptions } from "./Particles/ParticlesOptions";
|
|
9
9
|
import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
|
|
10
10
|
import { Background } from "./Background/Background";
|
|
11
|
-
import { Plugins } from "../../Utils";
|
|
11
|
+
import { deepExtend, Plugins } from "../../Utils";
|
|
12
12
|
import { Theme } from "./Theme/Theme";
|
|
13
13
|
import { ResponsiveMode, ThemeMode } from "../../Enums";
|
|
14
14
|
import { FullScreen } from "./FullScreen/FullScreen";
|
|
@@ -36,6 +36,7 @@ export class Options {
|
|
|
36
36
|
this.pauseOnBlur = true;
|
|
37
37
|
this.pauseOnOutsideViewport = true;
|
|
38
38
|
this.responsive = [];
|
|
39
|
+
this.style = {};
|
|
39
40
|
this.themes = [];
|
|
40
41
|
this.zLayers = 100;
|
|
41
42
|
}
|
|
@@ -140,6 +141,7 @@ export class Options {
|
|
|
140
141
|
}
|
|
141
142
|
this.motion.load(data.motion);
|
|
142
143
|
this.particles.load(data.particles);
|
|
144
|
+
this.style = deepExtend(this.style, data.style);
|
|
143
145
|
Plugins.loadOptions(this, data);
|
|
144
146
|
if (data.responsive !== undefined) {
|
|
145
147
|
for (const responsive of data.responsive) {
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
* @category Utils
|
|
4
4
|
*/
|
|
5
5
|
export declare class Constants {
|
|
6
|
-
|
|
7
|
-
* Particles canvas element class name
|
|
8
|
-
*/
|
|
9
|
-
static readonly canvasClass: string;
|
|
6
|
+
static readonly generatedAttribute: string;
|
|
10
7
|
static readonly randomColorValue: string;
|
|
11
8
|
static readonly midColorValue: string;
|
|
12
9
|
static readonly touchEndEvent: string;
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export class Constants {
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
* Particles canvas element class name
|
|
9
|
-
*/
|
|
10
|
-
Constants.canvasClass = "tsparticles-canvas-el";
|
|
7
|
+
Constants.generatedAttribute = "generated";
|
|
11
8
|
Constants.randomColorValue = "random";
|
|
12
9
|
Constants.midColorValue = "mid";
|
|
13
10
|
Constants.touchEndEvent = "touchend";
|
|
@@ -153,7 +153,7 @@ export class EventListeners {
|
|
|
153
153
|
clearTimeout(this.resizeTimeout);
|
|
154
154
|
delete this.resizeTimeout;
|
|
155
155
|
}
|
|
156
|
-
this.resizeTimeout = setTimeout(() => { var _a; return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); }, 500);
|
|
156
|
+
this.resizeTimeout = setTimeout(async () => { var _a; return await ((_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize()); }, 500);
|
|
157
157
|
}
|
|
158
158
|
handleVisibilityChange() {
|
|
159
159
|
const container = this.container;
|
package/esm/Core/Canvas.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ export declare class Canvas {
|
|
|
13
13
|
private originalStyle?;
|
|
14
14
|
constructor(container: Container);
|
|
15
15
|
init(): void;
|
|
16
|
-
loadCanvas(canvas: HTMLCanvasElement
|
|
16
|
+
loadCanvas(canvas: HTMLCanvasElement): void;
|
|
17
17
|
destroy(): void;
|
|
18
18
|
paint(): void;
|
|
19
19
|
clear(): void;
|
|
20
|
-
windowResize(): void
|
|
20
|
+
windowResize(): Promise<void>;
|
|
21
21
|
resize(): void;
|
|
22
22
|
drawConnectLine(p1: IParticle, p2: IParticle): void;
|
|
23
23
|
drawGrabLine(particle: IParticle, lineColor: IRgb, opacity: number, mousePos: ICoordinates): void;
|
package/esm/Core/Canvas.js
CHANGED
|
@@ -18,15 +18,15 @@ export class Canvas {
|
|
|
18
18
|
this.initBackground();
|
|
19
19
|
this.paint();
|
|
20
20
|
}
|
|
21
|
-
loadCanvas(canvas
|
|
21
|
+
loadCanvas(canvas) {
|
|
22
22
|
var _a;
|
|
23
|
-
if (!canvas.className) {
|
|
24
|
-
canvas.className = Constants.canvasClass;
|
|
25
|
-
}
|
|
26
23
|
if (this.generatedCanvas) {
|
|
27
24
|
(_a = this.element) === null || _a === void 0 ? void 0 : _a.remove();
|
|
28
25
|
}
|
|
29
|
-
this.generatedCanvas =
|
|
26
|
+
this.generatedCanvas =
|
|
27
|
+
canvas.dataset && Constants.generatedAttribute in canvas.dataset
|
|
28
|
+
? canvas.dataset[Constants.generatedAttribute] === "true"
|
|
29
|
+
: this.generatedCanvas;
|
|
30
30
|
this.element = canvas;
|
|
31
31
|
this.originalStyle = deepExtend({}, this.element.style);
|
|
32
32
|
this.size.height = canvas.offsetHeight;
|
|
@@ -71,7 +71,7 @@ export class Canvas {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
windowResize() {
|
|
74
|
+
async windowResize() {
|
|
75
75
|
if (!this.element) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -85,7 +85,7 @@ export class Canvas {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
if (needsRefresh) {
|
|
88
|
-
container.refresh();
|
|
88
|
+
await container.refresh();
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
resize() {
|
|
@@ -288,6 +288,16 @@ export class Canvas {
|
|
|
288
288
|
element.style.width = originalStyle.width;
|
|
289
289
|
element.style.height = originalStyle.height;
|
|
290
290
|
}
|
|
291
|
+
for (const key in options.style) {
|
|
292
|
+
if (!key || !options.style) {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const value = options.style[key];
|
|
296
|
+
if (!value) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
element.style[key] = value;
|
|
300
|
+
}
|
|
291
301
|
}
|
|
292
302
|
paintBase(baseColor) {
|
|
293
303
|
this.draw((ctx) => {
|
package/esm/Core/Loader.js
CHANGED
|
@@ -38,24 +38,19 @@ export class Loader {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
let canvasEl;
|
|
41
|
-
let generatedCanvas;
|
|
42
41
|
if (domContainer.tagName.toLowerCase() === "canvas") {
|
|
43
42
|
canvasEl = domContainer;
|
|
44
|
-
|
|
43
|
+
canvasEl.dataset[Constants.generatedAttribute] = "false";
|
|
45
44
|
}
|
|
46
45
|
else {
|
|
47
46
|
const existingCanvases = domContainer.getElementsByTagName("canvas");
|
|
48
47
|
if (existingCanvases.length) {
|
|
49
48
|
canvasEl = existingCanvases[0];
|
|
50
|
-
|
|
51
|
-
canvasEl.className = Constants.canvasClass;
|
|
52
|
-
}
|
|
53
|
-
generatedCanvas = false;
|
|
49
|
+
canvasEl.dataset[Constants.generatedAttribute] = "false";
|
|
54
50
|
}
|
|
55
51
|
else {
|
|
56
|
-
generatedCanvas = true;
|
|
57
52
|
canvasEl = document.createElement("canvas");
|
|
58
|
-
canvasEl.
|
|
53
|
+
canvasEl.dataset[Constants.generatedAttribute] = "true";
|
|
59
54
|
canvasEl.style.width = "100%";
|
|
60
55
|
canvasEl.style.height = "100%";
|
|
61
56
|
domContainer.appendChild(canvasEl);
|
|
@@ -68,7 +63,7 @@ export class Loader {
|
|
|
68
63
|
else {
|
|
69
64
|
dom.push(newItem);
|
|
70
65
|
}
|
|
71
|
-
newItem.canvas.loadCanvas(canvasEl
|
|
66
|
+
newItem.canvas.loadCanvas(canvasEl);
|
|
72
67
|
await newItem.start();
|
|
73
68
|
return newItem;
|
|
74
69
|
}
|
|
@@ -32,6 +32,7 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
|
|
|
32
32
|
pauseOnBlur: boolean;
|
|
33
33
|
pauseOnOutsideViewport: boolean;
|
|
34
34
|
preset?: string | string[];
|
|
35
|
+
style: RecursivePartial<CSSStyleDeclaration>;
|
|
35
36
|
responsive: Responsive[];
|
|
36
37
|
themes: Theme[];
|
|
37
38
|
zLayers: number;
|
|
@@ -8,7 +8,7 @@ import { Interactivity } from "./Interactivity/Interactivity";
|
|
|
8
8
|
import { ParticlesOptions } from "./Particles/ParticlesOptions";
|
|
9
9
|
import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
|
|
10
10
|
import { Background } from "./Background/Background";
|
|
11
|
-
import { Plugins } from "../../Utils";
|
|
11
|
+
import { deepExtend, Plugins } from "../../Utils";
|
|
12
12
|
import { Theme } from "./Theme/Theme";
|
|
13
13
|
import { ResponsiveMode, ThemeMode } from "../../Enums";
|
|
14
14
|
import { FullScreen } from "./FullScreen/FullScreen";
|
|
@@ -32,6 +32,7 @@ export class Options {
|
|
|
32
32
|
this.pauseOnBlur = true;
|
|
33
33
|
this.pauseOnOutsideViewport = true;
|
|
34
34
|
this.responsive = [];
|
|
35
|
+
this.style = {};
|
|
35
36
|
this.themes = [];
|
|
36
37
|
this.zLayers = 100;
|
|
37
38
|
}
|
|
@@ -110,6 +111,7 @@ export class Options {
|
|
|
110
111
|
}
|
|
111
112
|
this.motion.load(data.motion);
|
|
112
113
|
this.particles.load(data.particles);
|
|
114
|
+
this.style = deepExtend(this.style, data.style);
|
|
113
115
|
Plugins.loadOptions(this, data);
|
|
114
116
|
if (data.responsive !== undefined) {
|
|
115
117
|
for (const responsive of data.responsive) {
|
package/esm/Utils/Constants.d.ts
CHANGED
package/esm/Utils/Constants.js
CHANGED
|
@@ -128,7 +128,7 @@ export class EventListeners {
|
|
|
128
128
|
clearTimeout(this.resizeTimeout);
|
|
129
129
|
delete this.resizeTimeout;
|
|
130
130
|
}
|
|
131
|
-
this.resizeTimeout = setTimeout(() => { var _a; return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); }, 500);
|
|
131
|
+
this.resizeTimeout = setTimeout(async () => { var _a; return await ((_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize()); }, 500);
|
|
132
132
|
}
|
|
133
133
|
handleVisibilityChange() {
|
|
134
134
|
const container = this.container;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsparticles",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
|
|
5
5
|
"homepage": "https://particles.js.org/",
|
|
6
6
|
"scripts": {
|