tsparticles 1.37.0 → 1.37.4
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/Container.d.ts +1 -0
- package/Core/Container.js +2 -0
- package/Core/InteractionManager.d.ts +1 -0
- package/Core/InteractionManager.js +4 -1
- package/Core/Particles.d.ts +1 -1
- package/Core/Particles.js +3 -1
- package/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +21 -0
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +2 -0
- package/Utils/EventListeners.d.ts +1 -0
- package/Utils/EventListeners.js +13 -2
- package/Utils/Plugins.d.ts +2 -2
- package/Utils/Plugins.js +4 -4
- package/browser/Core/Container.d.ts +1 -0
- package/browser/Core/Container.js +2 -0
- package/browser/Core/InteractionManager.d.ts +1 -0
- package/browser/Core/InteractionManager.js +4 -1
- package/browser/Core/Particles.d.ts +1 -1
- package/browser/Core/Particles.js +3 -1
- package/browser/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/browser/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
- package/browser/Plugins/PolygonMask/plugin.js +3 -1
- package/browser/Utils/EventListeners.d.ts +1 -0
- package/browser/Utils/EventListeners.js +14 -3
- package/browser/Utils/Plugins.d.ts +2 -2
- package/browser/Utils/Plugins.js +4 -4
- package/esm/Core/Container.d.ts +1 -0
- package/esm/Core/Container.js +2 -0
- package/esm/Core/InteractionManager.d.ts +1 -0
- package/esm/Core/InteractionManager.js +4 -1
- package/esm/Core/Particles.d.ts +1 -1
- package/esm/Core/Particles.js +3 -1
- package/esm/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/esm/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
- package/esm/Utils/EventListeners.d.ts +1 -0
- package/esm/Utils/EventListeners.js +14 -3
- package/esm/Utils/Plugins.d.ts +2 -2
- package/esm/Utils/Plugins.js +4 -4
- package/package.json +1 -1
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/tsparticles.js +601 -240
- package/tsparticles.min.js +2 -2
- package/tsparticles.pathseg.js +2 -2
- package/tsparticles.slim.js +419 -183
- package/tsparticles.slim.min.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClickMode, InteractivityDetect } from "../Enums";
|
|
2
2
|
import { Constants } from "./Constants";
|
|
3
|
-
import { itemFromArray } from "./Utils";
|
|
3
|
+
import { isSsr, itemFromArray } from "./Utils";
|
|
4
4
|
function manageListener(element, event, handler, add, options) {
|
|
5
5
|
if (add) {
|
|
6
6
|
let addOptions = { passive: true };
|
|
@@ -40,6 +40,7 @@ export class EventListeners {
|
|
|
40
40
|
this.mouseDownHandler = () => this.mouseDown();
|
|
41
41
|
this.visibilityChangeHandler = () => this.handleVisibilityChange();
|
|
42
42
|
this.themeChangeHandler = (e) => this.handleThemeChange(e);
|
|
43
|
+
this.oldThemeChangeHandler = (e) => this.handleThemeChange(e);
|
|
43
44
|
this.resizeHandler = () => this.handleWindowResize();
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
@@ -75,9 +76,19 @@ export class EventListeners {
|
|
|
75
76
|
else {
|
|
76
77
|
container.interactivity.element = container.canvas.element;
|
|
77
78
|
}
|
|
78
|
-
const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
79
|
+
const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
79
80
|
if (mediaMatch) {
|
|
80
|
-
|
|
81
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
82
|
+
manageListener(mediaMatch, "change", this.themeChangeHandler, add);
|
|
83
|
+
}
|
|
84
|
+
else if (mediaMatch.addListener !== undefined) {
|
|
85
|
+
if (add) {
|
|
86
|
+
mediaMatch.addListener(this.oldThemeChangeHandler);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
mediaMatch.removeListener(this.oldThemeChangeHandler);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
const interactivityEl = container.interactivity.element;
|
|
83
94
|
/* detect mouse pos - on hover / click event */
|
|
@@ -18,8 +18,8 @@ export declare class Plugins {
|
|
|
18
18
|
static getSupportedShapes(): IterableIterator<string>;
|
|
19
19
|
static getPathGenerator(type: string): IMovePathGenerator | undefined;
|
|
20
20
|
static addPathGenerator(type: string, pathGenerator: IMovePathGenerator): void;
|
|
21
|
-
static getInteractors(container: Container): IInteractor[];
|
|
21
|
+
static getInteractors(container: Container, force?: boolean): IInteractor[];
|
|
22
22
|
static addInteractor(name: string, initInteractor: (container: Container) => IInteractor): void;
|
|
23
|
-
static getUpdaters(container: Container): IParticleUpdater[];
|
|
23
|
+
static getUpdaters(container: Container, force?: boolean): IParticleUpdater[];
|
|
24
24
|
static addParticleUpdater(name: string, initUpdater: (container: Container) => IParticleUpdater): void;
|
|
25
25
|
}
|
package/browser/Utils/Plugins.js
CHANGED
|
@@ -60,9 +60,9 @@ export class Plugins {
|
|
|
60
60
|
pathGenerators.set(type, pathGenerator);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
static getInteractors(container) {
|
|
63
|
+
static getInteractors(container, force = false) {
|
|
64
64
|
let res = interactors.get(container);
|
|
65
|
-
if (!res) {
|
|
65
|
+
if (!res || force) {
|
|
66
66
|
res = [...interactorsInitializers.values()].map((t) => t(container));
|
|
67
67
|
interactors.set(container, res);
|
|
68
68
|
}
|
|
@@ -71,9 +71,9 @@ export class Plugins {
|
|
|
71
71
|
static addInteractor(name, initInteractor) {
|
|
72
72
|
interactorsInitializers.set(name, initInteractor);
|
|
73
73
|
}
|
|
74
|
-
static getUpdaters(container) {
|
|
74
|
+
static getUpdaters(container, force = false) {
|
|
75
75
|
let res = updaters.get(container);
|
|
76
|
-
if (!res) {
|
|
76
|
+
if (!res || force) {
|
|
77
77
|
res = [...updatersInitializers.values()].map((t) => t(container));
|
|
78
78
|
updaters.set(container, res);
|
|
79
79
|
}
|
package/esm/Core/Container.d.ts
CHANGED
package/esm/Core/Container.js
CHANGED
|
@@ -19,6 +19,7 @@ export class Container {
|
|
|
19
19
|
this.zLayers = 100;
|
|
20
20
|
this.pageHidden = false;
|
|
21
21
|
this._sourceOptions = sourceOptions;
|
|
22
|
+
this._initialSourceOptions = sourceOptions;
|
|
22
23
|
this.retina = new Retina(this);
|
|
23
24
|
this.canvas = new Canvas(this);
|
|
24
25
|
this.particles = new Particles(this);
|
|
@@ -318,6 +319,7 @@ export class Container {
|
|
|
318
319
|
this.drawers.set(type, drawer);
|
|
319
320
|
}
|
|
320
321
|
}
|
|
322
|
+
this._options.load(this._initialSourceOptions);
|
|
321
323
|
this._options.load(this._sourceOptions);
|
|
322
324
|
this.actualOptions = new Options();
|
|
323
325
|
this.actualOptions.load(this._options);
|
|
@@ -6,6 +6,7 @@ export declare class InteractionManager {
|
|
|
6
6
|
private readonly externalInteractors;
|
|
7
7
|
private readonly particleInteractors;
|
|
8
8
|
constructor(container: Container);
|
|
9
|
+
init(): void;
|
|
9
10
|
externalInteract(delta: IDelta): void;
|
|
10
11
|
particlesInteract(particle: Particle, delta: IDelta): void;
|
|
11
12
|
}
|
|
@@ -3,9 +3,12 @@ import { InteractorType } from "../Enums";
|
|
|
3
3
|
export class InteractionManager {
|
|
4
4
|
constructor(container) {
|
|
5
5
|
this.container = container;
|
|
6
|
-
const interactors = Plugins.getInteractors(container);
|
|
7
6
|
this.externalInteractors = [];
|
|
8
7
|
this.particleInteractors = [];
|
|
8
|
+
this.init();
|
|
9
|
+
}
|
|
10
|
+
init() {
|
|
11
|
+
const interactors = Plugins.getInteractors(this.container, true);
|
|
9
12
|
for (const interactor of interactors) {
|
|
10
13
|
switch (interactor.type) {
|
|
11
14
|
case InteractorType.External:
|
package/esm/Core/Particles.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Particles {
|
|
|
17
17
|
pushing?: boolean;
|
|
18
18
|
linksColor?: IRgb | string;
|
|
19
19
|
grabLineColor?: IRgb | string;
|
|
20
|
-
|
|
20
|
+
updaters: import("./Interfaces").IParticleUpdater[];
|
|
21
21
|
private interactionManager;
|
|
22
22
|
private nextId;
|
|
23
23
|
private readonly freqs;
|
package/esm/Core/Particles.js
CHANGED
|
@@ -21,7 +21,7 @@ export class Particles {
|
|
|
21
21
|
const canvasSize = this.container.canvas.size;
|
|
22
22
|
this.linksColors = new Map();
|
|
23
23
|
this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
|
|
24
|
-
this.updaters = Plugins.getUpdaters(container);
|
|
24
|
+
this.updaters = Plugins.getUpdaters(container, true);
|
|
25
25
|
}
|
|
26
26
|
get count() {
|
|
27
27
|
return this.array.length;
|
|
@@ -35,6 +35,8 @@ export class Particles {
|
|
|
35
35
|
this.freqs.links = new Map();
|
|
36
36
|
this.freqs.triangles = new Map();
|
|
37
37
|
let handled = false;
|
|
38
|
+
this.updaters = Plugins.getUpdaters(container, true);
|
|
39
|
+
this.interactionManager.init();
|
|
38
40
|
for (const [, plugin] of container.plugins) {
|
|
39
41
|
if (plugin.particlesInitialization !== undefined) {
|
|
40
42
|
handled = plugin.particlesInitialization();
|
|
@@ -5,6 +5,7 @@ import type { IAbsorber } from "./Options/Interfaces/IAbsorber";
|
|
|
5
5
|
import type { Absorbers } from "./Absorbers";
|
|
6
6
|
import { Vector } from "../../Core/Particle/Vector";
|
|
7
7
|
import { RotateDirection } from "../../Enums";
|
|
8
|
+
import { IAbsorberSizeLimit } from "./Options/Interfaces/IAbsorberSizeLimit";
|
|
8
9
|
declare type OrbitingParticle = Particle & {
|
|
9
10
|
absorberOrbit?: Vector;
|
|
10
11
|
absorberOrbitDirection?: RotateDirection;
|
|
@@ -17,7 +18,7 @@ export declare class AbsorberInstance {
|
|
|
17
18
|
opacity: number;
|
|
18
19
|
size: number;
|
|
19
20
|
color: IRgb;
|
|
20
|
-
limit
|
|
21
|
+
limit: IAbsorberSizeLimit;
|
|
21
22
|
readonly name?: string;
|
|
22
23
|
position: Vector;
|
|
23
24
|
private dragging;
|
|
@@ -3,7 +3,7 @@ import { Vector } from "../../Core/Particle/Vector";
|
|
|
3
3
|
import { RotateDirection } from "../../Enums";
|
|
4
4
|
export class AbsorberInstance {
|
|
5
5
|
constructor(absorbers, container, options, position) {
|
|
6
|
-
var _a, _b, _c;
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
7
|
this.absorbers = absorbers;
|
|
8
8
|
this.container = container;
|
|
9
9
|
this.initialPosition = position ? Vector.create(position.x, position.y) : undefined;
|
|
@@ -14,14 +14,23 @@ export class AbsorberInstance {
|
|
|
14
14
|
this.size = getRangeValue(options.size.value) * container.retina.pixelRatio;
|
|
15
15
|
this.mass = this.size * options.size.density * container.retina.reduceFactor;
|
|
16
16
|
const limit = options.size.limit;
|
|
17
|
-
this.limit =
|
|
17
|
+
this.limit =
|
|
18
|
+
typeof limit === "number"
|
|
19
|
+
? {
|
|
20
|
+
radius: limit * container.retina.pixelRatio * container.retina.reduceFactor,
|
|
21
|
+
mass: 0,
|
|
22
|
+
}
|
|
23
|
+
: {
|
|
24
|
+
radius: ((_a = limit === null || limit === void 0 ? void 0 : limit.radius) !== null && _a !== void 0 ? _a : 0) * container.retina.pixelRatio * container.retina.reduceFactor,
|
|
25
|
+
mass: (_b = limit === null || limit === void 0 ? void 0 : limit.mass) !== null && _b !== void 0 ? _b : 0,
|
|
26
|
+
};
|
|
18
27
|
const color = typeof options.color === "string" ? { value: options.color } : options.color;
|
|
19
|
-
this.color = (
|
|
28
|
+
this.color = (_c = colorToRgb(color)) !== null && _c !== void 0 ? _c : {
|
|
20
29
|
b: 0,
|
|
21
30
|
g: 0,
|
|
22
31
|
r: 0,
|
|
23
32
|
};
|
|
24
|
-
this.position = (
|
|
33
|
+
this.position = (_e = (_d = this.initialPosition) === null || _d === void 0 ? void 0 : _d.copy()) !== null && _e !== void 0 ? _e : this.calcPosition();
|
|
25
34
|
}
|
|
26
35
|
attract(particle) {
|
|
27
36
|
const container = this.container;
|
|
@@ -64,10 +73,12 @@ export class AbsorberInstance {
|
|
|
64
73
|
}
|
|
65
74
|
this.updateParticlePosition(particle, v);
|
|
66
75
|
}
|
|
67
|
-
if (this.limit
|
|
76
|
+
if (this.limit.radius <= 0 || this.size < this.limit.radius) {
|
|
68
77
|
this.size += sizeFactor;
|
|
69
78
|
}
|
|
70
|
-
this.mass
|
|
79
|
+
if (this.limit.mass <= 0 || this.mass < this.limit.mass) {
|
|
80
|
+
this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
|
|
81
|
+
}
|
|
71
82
|
}
|
|
72
83
|
else {
|
|
73
84
|
this.updateParticlePosition(particle, v);
|
|
@@ -102,9 +113,10 @@ export class AbsorberInstance {
|
|
|
102
113
|
const container = this.container;
|
|
103
114
|
const canvasSize = container.canvas.size;
|
|
104
115
|
if (particle.needsNewPosition) {
|
|
105
|
-
|
|
106
|
-
particle.position.
|
|
107
|
-
particle.
|
|
116
|
+
particle.position.x = Math.floor(Math.random() * canvasSize.width);
|
|
117
|
+
particle.position.y = Math.floor(Math.random() * canvasSize.height);
|
|
118
|
+
particle.velocity.setTo(particle.initialVelocity);
|
|
119
|
+
particle.absorberOrbit = undefined;
|
|
108
120
|
particle.needsNewPosition = false;
|
|
109
121
|
}
|
|
110
122
|
if (this.options.orbits) {
|
|
@@ -2,9 +2,10 @@ import type { IAbsorberSize } from "../Interfaces/IAbsorberSize";
|
|
|
2
2
|
import type { RecursivePartial } from "../../../../Types";
|
|
3
3
|
import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
|
|
4
4
|
import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
|
|
5
|
+
import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
|
|
5
6
|
export declare class AbsorberSize extends ValueWithRandom implements IAbsorberSize, IOptionLoader<IAbsorberSize> {
|
|
6
7
|
density: number;
|
|
7
|
-
limit
|
|
8
|
+
limit: AbsorberSizeLimit;
|
|
8
9
|
constructor();
|
|
9
10
|
load(data?: RecursivePartial<IAbsorberSize>): void;
|
|
10
11
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ValueWithRandom } from "../../../../Options/Classes/ValueWithRandom";
|
|
2
|
+
import { AbsorberSizeLimit } from "./AbsorberSizeLimit";
|
|
2
3
|
export class AbsorberSize extends ValueWithRandom {
|
|
3
4
|
constructor() {
|
|
4
5
|
super();
|
|
5
6
|
this.density = 5;
|
|
6
7
|
this.random.minimumValue = 1;
|
|
7
8
|
this.value = 50;
|
|
9
|
+
this.limit = new AbsorberSizeLimit();
|
|
8
10
|
}
|
|
9
11
|
load(data) {
|
|
10
12
|
if (!data) {
|
|
@@ -14,11 +16,11 @@ export class AbsorberSize extends ValueWithRandom {
|
|
|
14
16
|
if (data.density !== undefined) {
|
|
15
17
|
this.density = data.density;
|
|
16
18
|
}
|
|
17
|
-
if (data.limit
|
|
18
|
-
this.limit = data.limit;
|
|
19
|
+
if (typeof data.limit === "number") {
|
|
20
|
+
this.limit.radius = data.limit;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
this.limit
|
|
22
|
+
else {
|
|
23
|
+
this.limit.load(data.limit);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RecursivePartial } from "../../../../Types";
|
|
2
|
+
import type { IOptionLoader } from "../../../../Options/Interfaces/IOptionLoader";
|
|
3
|
+
import type { IAbsorberSizeLimit } from "../Interfaces/IAbsorberSizeLimit";
|
|
4
|
+
export declare class AbsorberSizeLimit implements IAbsorberSizeLimit, IOptionLoader<IAbsorberSizeLimit> {
|
|
5
|
+
radius: number;
|
|
6
|
+
mass: number;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<IAbsorberSizeLimit>): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class AbsorberSizeLimit {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.radius = 0;
|
|
4
|
+
this.mass = 0;
|
|
5
|
+
}
|
|
6
|
+
load(data) {
|
|
7
|
+
if (!data) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (data.mass !== undefined) {
|
|
11
|
+
this.mass = data.mass;
|
|
12
|
+
}
|
|
13
|
+
if (data.radius !== undefined) {
|
|
14
|
+
this.radius = data.radius;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
|
|
1
|
+
import type { IValueWithRandom } from "../../../../Options/Interfaces/IValueWithRandom";
|
|
2
|
+
import type { IAbsorberSizeLimit } from "./IAbsorberSizeLimit";
|
|
2
3
|
export interface IAbsorberSize extends IValueWithRandom {
|
|
3
|
-
limit?: number;
|
|
4
|
+
limit?: number | IAbsorberSizeLimit;
|
|
4
5
|
density: number;
|
|
5
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,7 @@ export declare class EventListeners {
|
|
|
12
12
|
private readonly mouseUpHandler;
|
|
13
13
|
private readonly visibilityChangeHandler;
|
|
14
14
|
private readonly themeChangeHandler;
|
|
15
|
+
private readonly oldThemeChangeHandler;
|
|
15
16
|
private readonly resizeHandler;
|
|
16
17
|
private canPush;
|
|
17
18
|
private resizeTimeout?;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClickMode, InteractivityDetect } from "../Enums";
|
|
2
2
|
import { Constants } from "./Constants";
|
|
3
|
-
import { itemFromArray } from "./Utils";
|
|
3
|
+
import { isSsr, itemFromArray } from "./Utils";
|
|
4
4
|
function manageListener(element, event, handler, add, options) {
|
|
5
5
|
if (add) {
|
|
6
6
|
let addOptions = { passive: true };
|
|
@@ -32,6 +32,7 @@ export class EventListeners {
|
|
|
32
32
|
this.mouseDownHandler = () => this.mouseDown();
|
|
33
33
|
this.visibilityChangeHandler = () => this.handleVisibilityChange();
|
|
34
34
|
this.themeChangeHandler = (e) => this.handleThemeChange(e);
|
|
35
|
+
this.oldThemeChangeHandler = (e) => this.handleThemeChange(e);
|
|
35
36
|
this.resizeHandler = () => this.handleWindowResize();
|
|
36
37
|
}
|
|
37
38
|
addListeners() {
|
|
@@ -57,9 +58,19 @@ export class EventListeners {
|
|
|
57
58
|
else {
|
|
58
59
|
container.interactivity.element = container.canvas.element;
|
|
59
60
|
}
|
|
60
|
-
const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
61
|
+
const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
61
62
|
if (mediaMatch) {
|
|
62
|
-
|
|
63
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
64
|
+
manageListener(mediaMatch, "change", this.themeChangeHandler, add);
|
|
65
|
+
}
|
|
66
|
+
else if (mediaMatch.addListener !== undefined) {
|
|
67
|
+
if (add) {
|
|
68
|
+
mediaMatch.addListener(this.oldThemeChangeHandler);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
mediaMatch.removeListener(this.oldThemeChangeHandler);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
63
74
|
}
|
|
64
75
|
const interactivityEl = container.interactivity.element;
|
|
65
76
|
if (!interactivityEl) {
|
package/esm/Utils/Plugins.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare class Plugins {
|
|
|
15
15
|
static getSupportedShapes(): IterableIterator<string>;
|
|
16
16
|
static getPathGenerator(type: string): IMovePathGenerator | undefined;
|
|
17
17
|
static addPathGenerator(type: string, pathGenerator: IMovePathGenerator): void;
|
|
18
|
-
static getInteractors(container: Container): IInteractor[];
|
|
18
|
+
static getInteractors(container: Container, force?: boolean): IInteractor[];
|
|
19
19
|
static addInteractor(name: string, initInteractor: (container: Container) => IInteractor): void;
|
|
20
|
-
static getUpdaters(container: Container): IParticleUpdater[];
|
|
20
|
+
static getUpdaters(container: Container, force?: boolean): IParticleUpdater[];
|
|
21
21
|
static addParticleUpdater(name: string, initUpdater: (container: Container) => IParticleUpdater): void;
|
|
22
22
|
}
|
package/esm/Utils/Plugins.js
CHANGED
|
@@ -57,9 +57,9 @@ export class Plugins {
|
|
|
57
57
|
pathGenerators.set(type, pathGenerator);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
static getInteractors(container) {
|
|
60
|
+
static getInteractors(container, force = false) {
|
|
61
61
|
let res = interactors.get(container);
|
|
62
|
-
if (!res) {
|
|
62
|
+
if (!res || force) {
|
|
63
63
|
res = [...interactorsInitializers.values()].map((t) => t(container));
|
|
64
64
|
interactors.set(container, res);
|
|
65
65
|
}
|
|
@@ -68,9 +68,9 @@ export class Plugins {
|
|
|
68
68
|
static addInteractor(name, initInteractor) {
|
|
69
69
|
interactorsInitializers.set(name, initInteractor);
|
|
70
70
|
}
|
|
71
|
-
static getUpdaters(container) {
|
|
71
|
+
static getUpdaters(container, force = false) {
|
|
72
72
|
let res = updaters.get(container);
|
|
73
|
-
if (!res) {
|
|
73
|
+
if (!res || force) {
|
|
74
74
|
res = [...updatersInitializers.values()].map((t) => t(container));
|
|
75
75
|
updaters.set(container, res);
|
|
76
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsparticles",
|
|
3
|
-
"version": "1.37.
|
|
3
|
+
"version": "1.37.4",
|
|
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": {
|