tsparticles 1.41.0 → 1.41.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.js +2 -2
- package/Core/Interfaces/IExternalInteractor.d.ts +1 -1
- package/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
- package/Core/Particle.js +2 -2
- package/Core/Particles.d.ts +3 -3
- package/Core/Particles.js +7 -7
- package/Core/Utils/ExternalInteractorBase.d.ts +1 -1
- package/Core/Utils/FrameManager.d.ts +1 -1
- package/Core/Utils/FrameManager.js +2 -2
- package/Core/Utils/InteractionManager.d.ts +2 -2
- package/Core/Utils/InteractionManager.js +4 -4
- package/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
- package/Interactions/External/Attract/Attractor.d.ts +1 -1
- package/Interactions/External/Attract/Attractor.js +1 -1
- package/Interactions/External/Bounce/Bouncer.d.ts +1 -1
- package/Interactions/External/Bounce/Bouncer.js +1 -1
- package/Interactions/External/Bubble/Bubbler.d.ts +1 -1
- package/Interactions/External/Bubble/Bubbler.js +1 -1
- package/Interactions/External/Connect/Connector.d.ts +1 -1
- package/Interactions/External/Connect/Connector.js +1 -1
- package/Interactions/External/Grab/Grabber.d.ts +1 -1
- package/Interactions/External/Grab/Grabber.js +1 -1
- package/Interactions/External/Repulse/Repulser.d.ts +1 -1
- package/Interactions/External/Repulse/Repulser.js +1 -1
- package/Interactions/External/Trail/TrailMaker.d.ts +1 -1
- package/Interactions/External/Trail/TrailMaker.js +1 -1
- package/Interactions/Particles/Attract/Attractor.d.ts +1 -1
- package/Interactions/Particles/Attract/Attractor.js +1 -1
- package/Interactions/Particles/Collisions/Collider.d.ts +1 -1
- package/Interactions/Particles/Collisions/Collider.js +1 -1
- package/Interactions/Particles/Links/Linker.d.ts +1 -1
- package/Interactions/Particles/Links/Linker.js +1 -1
- package/Plugins/PolygonMask/PolygonMaskInstance.js +1 -1
- package/Updaters/Opacity/OpacityUpdater.js +7 -5
- package/Updaters/Size/SizeUpdater.js +6 -5
- package/browser/Core/Container.js +2 -2
- package/browser/Core/Interfaces/IExternalInteractor.d.ts +1 -1
- package/browser/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
- package/browser/Core/Particle.js +2 -2
- package/browser/Core/Particles.d.ts +3 -3
- package/browser/Core/Particles.js +7 -7
- package/browser/Core/Utils/ExternalInteractorBase.d.ts +1 -1
- package/browser/Core/Utils/FrameManager.d.ts +1 -1
- package/browser/Core/Utils/FrameManager.js +2 -2
- package/browser/Core/Utils/InteractionManager.d.ts +2 -2
- package/browser/Core/Utils/InteractionManager.js +4 -4
- package/browser/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
- package/browser/Interactions/External/Attract/Attractor.d.ts +1 -1
- package/browser/Interactions/External/Attract/Attractor.js +1 -1
- package/browser/Interactions/External/Bounce/Bouncer.d.ts +1 -1
- package/browser/Interactions/External/Bounce/Bouncer.js +1 -1
- package/browser/Interactions/External/Bubble/Bubbler.d.ts +1 -1
- package/browser/Interactions/External/Bubble/Bubbler.js +1 -1
- package/browser/Interactions/External/Connect/Connector.d.ts +1 -1
- package/browser/Interactions/External/Connect/Connector.js +1 -1
- package/browser/Interactions/External/Grab/Grabber.d.ts +1 -1
- package/browser/Interactions/External/Grab/Grabber.js +1 -1
- package/browser/Interactions/External/Repulse/Repulser.d.ts +1 -1
- package/browser/Interactions/External/Repulse/Repulser.js +1 -1
- package/browser/Interactions/External/Trail/TrailMaker.d.ts +1 -1
- package/browser/Interactions/External/Trail/TrailMaker.js +1 -1
- package/browser/Interactions/Particles/Attract/Attractor.d.ts +1 -1
- package/browser/Interactions/Particles/Attract/Attractor.js +1 -1
- package/browser/Interactions/Particles/Collisions/Collider.d.ts +1 -1
- package/browser/Interactions/Particles/Collisions/Collider.js +1 -1
- package/browser/Interactions/Particles/Links/Linker.d.ts +1 -1
- package/browser/Interactions/Particles/Links/Linker.js +1 -1
- package/browser/Plugins/PolygonMask/PolygonMaskInstance.js +1 -1
- package/browser/Updaters/Opacity/OpacityUpdater.js +7 -5
- package/browser/Updaters/Size/SizeUpdater.js +6 -5
- package/esm/Core/Container.js +2 -2
- package/esm/Core/Interfaces/IExternalInteractor.d.ts +1 -1
- package/esm/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
- package/esm/Core/Particle.js +2 -2
- package/esm/Core/Particles.d.ts +3 -3
- package/esm/Core/Particles.js +7 -7
- package/esm/Core/Utils/ExternalInteractorBase.d.ts +1 -1
- package/esm/Core/Utils/FrameManager.d.ts +1 -1
- package/esm/Core/Utils/FrameManager.js +2 -2
- package/esm/Core/Utils/InteractionManager.d.ts +2 -2
- package/esm/Core/Utils/InteractionManager.js +4 -4
- package/esm/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
- package/esm/Interactions/External/Attract/Attractor.d.ts +1 -1
- package/esm/Interactions/External/Attract/Attractor.js +1 -1
- package/esm/Interactions/External/Bounce/Bouncer.d.ts +1 -1
- package/esm/Interactions/External/Bounce/Bouncer.js +1 -1
- package/esm/Interactions/External/Bubble/Bubbler.d.ts +1 -1
- package/esm/Interactions/External/Bubble/Bubbler.js +1 -1
- package/esm/Interactions/External/Connect/Connector.d.ts +1 -1
- package/esm/Interactions/External/Connect/Connector.js +1 -1
- package/esm/Interactions/External/Grab/Grabber.d.ts +1 -1
- package/esm/Interactions/External/Grab/Grabber.js +1 -1
- package/esm/Interactions/External/Repulse/Repulser.d.ts +1 -1
- package/esm/Interactions/External/Repulse/Repulser.js +1 -1
- package/esm/Interactions/External/Trail/TrailMaker.d.ts +1 -1
- package/esm/Interactions/External/Trail/TrailMaker.js +1 -1
- package/esm/Interactions/Particles/Attract/Attractor.d.ts +1 -1
- package/esm/Interactions/Particles/Attract/Attractor.js +1 -1
- package/esm/Interactions/Particles/Collisions/Collider.d.ts +1 -1
- package/esm/Interactions/Particles/Collisions/Collider.js +1 -1
- package/esm/Interactions/Particles/Links/Linker.d.ts +1 -1
- package/esm/Interactions/Particles/Links/Linker.js +1 -1
- package/esm/Plugins/PolygonMask/PolygonMaskInstance.js +1 -1
- package/esm/Updaters/Opacity/OpacityUpdater.js +7 -5
- package/esm/Updaters/Size/SizeUpdater.js +6 -5
- package/package.json +1 -1
- package/report.html +6 -5
- package/report.slim.html +6 -5
- package/tsparticles.engine.js +17 -17
- package/tsparticles.engine.min.js +2 -2
- package/tsparticles.interaction.external.attract.js +16 -16
- package/tsparticles.interaction.external.attract.min.js +2 -2
- package/tsparticles.interaction.external.bounce.js +16 -16
- package/tsparticles.interaction.external.bounce.min.js +2 -2
- package/tsparticles.interaction.external.bubble.js +16 -16
- package/tsparticles.interaction.external.bubble.min.js +2 -2
- package/tsparticles.interaction.external.connect.js +16 -16
- package/tsparticles.interaction.external.connect.min.js +2 -2
- package/tsparticles.interaction.external.grab.js +16 -16
- package/tsparticles.interaction.external.grab.min.js +2 -2
- package/tsparticles.interaction.external.repulse.js +16 -16
- package/tsparticles.interaction.external.repulse.min.js +2 -2
- package/tsparticles.interaction.external.trail.js +16 -16
- package/tsparticles.interaction.external.trail.min.js +2 -2
- package/tsparticles.interaction.particles.attract.js +16 -16
- package/tsparticles.interaction.particles.attract.min.js +2 -2
- package/tsparticles.interaction.particles.collisions.js +16 -16
- package/tsparticles.interaction.particles.collisions.min.js +2 -2
- package/tsparticles.interaction.particles.links.js +16 -16
- package/tsparticles.interaction.particles.links.min.js +2 -2
- package/tsparticles.js +35 -35
- package/tsparticles.min.js +2 -2
- package/tsparticles.pathseg.min.js +1 -1
- package/tsparticles.plugins.absorbers.js +15 -15
- package/tsparticles.plugins.absorbers.min.js +1 -1
- package/tsparticles.plugins.emitters.js +15 -15
- package/tsparticles.plugins.emitters.min.js +1 -1
- package/tsparticles.plugins.polygonMask.js +17 -17
- package/tsparticles.plugins.polygonMask.min.js +2 -2
- package/tsparticles.shape.circle.min.js +1 -1
- package/tsparticles.shape.image.js +15 -15
- package/tsparticles.shape.image.min.js +1 -1
- package/tsparticles.shape.line.min.js +1 -1
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.square.min.js +1 -1
- package/tsparticles.shape.star.min.js +1 -1
- package/tsparticles.shape.text.js +15 -15
- package/tsparticles.shape.text.min.js +1 -1
- package/tsparticles.slim.js +32 -32
- package/tsparticles.slim.min.js +2 -2
- package/tsparticles.updater.angle.js +15 -15
- package/tsparticles.updater.angle.min.js +1 -1
- package/tsparticles.updater.color.js +15 -15
- package/tsparticles.updater.color.min.js +1 -1
- package/tsparticles.updater.life.js +15 -15
- package/tsparticles.updater.life.min.js +1 -1
- package/tsparticles.updater.opacity.js +18 -18
- package/tsparticles.updater.opacity.min.js +2 -2
- package/tsparticles.updater.outModes.js +15 -15
- package/tsparticles.updater.outModes.min.js +1 -1
- package/tsparticles.updater.roll.js +15 -15
- package/tsparticles.updater.roll.min.js +1 -1
- package/tsparticles.updater.size.js +18 -18
- package/tsparticles.updater.size.min.js +2 -2
- package/tsparticles.updater.strokeColor.js +15 -15
- package/tsparticles.updater.strokeColor.min.js +1 -1
- package/tsparticles.updater.tilt.js +15 -15
- package/tsparticles.updater.tilt.min.js +1 -1
- package/tsparticles.updater.wobble.js +15 -15
- package/tsparticles.updater.wobble.min.js +1 -1
- package/umd/Core/Container.js +2 -2
- package/umd/Core/Interfaces/IExternalInteractor.d.ts +1 -1
- package/umd/Core/Interfaces/IParticlesInteractor.d.ts +1 -1
- package/umd/Core/Particle.js +2 -2
- package/umd/Core/Particles.d.ts +3 -3
- package/umd/Core/Particles.js +7 -7
- package/umd/Core/Utils/ExternalInteractorBase.d.ts +1 -1
- package/umd/Core/Utils/FrameManager.d.ts +1 -1
- package/umd/Core/Utils/FrameManager.js +2 -2
- package/umd/Core/Utils/InteractionManager.d.ts +2 -2
- package/umd/Core/Utils/InteractionManager.js +4 -4
- package/umd/Core/Utils/ParticlesInteractorBase.d.ts +1 -1
- package/umd/Interactions/External/Attract/Attractor.d.ts +1 -1
- package/umd/Interactions/External/Attract/Attractor.js +1 -1
- package/umd/Interactions/External/Bounce/Bouncer.d.ts +1 -1
- package/umd/Interactions/External/Bounce/Bouncer.js +1 -1
- package/umd/Interactions/External/Bubble/Bubbler.d.ts +1 -1
- package/umd/Interactions/External/Bubble/Bubbler.js +1 -1
- package/umd/Interactions/External/Connect/Connector.d.ts +1 -1
- package/umd/Interactions/External/Connect/Connector.js +1 -1
- package/umd/Interactions/External/Grab/Grabber.d.ts +1 -1
- package/umd/Interactions/External/Grab/Grabber.js +1 -1
- package/umd/Interactions/External/Repulse/Repulser.d.ts +1 -1
- package/umd/Interactions/External/Repulse/Repulser.js +1 -1
- package/umd/Interactions/External/Trail/TrailMaker.d.ts +1 -1
- package/umd/Interactions/External/Trail/TrailMaker.js +1 -1
- package/umd/Interactions/Particles/Attract/Attractor.d.ts +1 -1
- package/umd/Interactions/Particles/Attract/Attractor.js +1 -1
- package/umd/Interactions/Particles/Collisions/Collider.d.ts +1 -1
- package/umd/Interactions/Particles/Collisions/Collider.js +1 -1
- package/umd/Interactions/Particles/Links/Linker.d.ts +1 -1
- package/umd/Interactions/Particles/Links/Linker.js +1 -1
- package/umd/Plugins/PolygonMask/PolygonMaskInstance.js +1 -1
- package/umd/Updaters/Opacity/OpacityUpdater.js +7 -5
- package/umd/Updaters/Size/SizeUpdater.js +6 -5
package/Core/Container.js
CHANGED
|
@@ -115,12 +115,12 @@ class Container {
|
|
|
115
115
|
}
|
|
116
116
|
draw(force) {
|
|
117
117
|
let refreshTime = force;
|
|
118
|
-
this.drawAnimationFrame = (0, Utils_2.animate)()((timestamp) => {
|
|
118
|
+
this.drawAnimationFrame = (0, Utils_2.animate)()(async (timestamp) => {
|
|
119
119
|
if (refreshTime) {
|
|
120
120
|
this.lastFrameTime = undefined;
|
|
121
121
|
refreshTime = false;
|
|
122
122
|
}
|
|
123
|
-
this.drawer.nextFrame(timestamp);
|
|
123
|
+
await this.drawer.nextFrame(timestamp);
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
getAnimationStatus() {
|
|
@@ -3,5 +3,5 @@ import type { IInteractor } from "./IInteractor";
|
|
|
3
3
|
import type { Particle } from "../Particle";
|
|
4
4
|
export interface IParticlesInteractor extends IInteractor {
|
|
5
5
|
isEnabled(particle: Particle): boolean;
|
|
6
|
-
interact(particle: Particle, delta: IDelta): void
|
|
6
|
+
interact(particle: Particle, delta: IDelta): Promise<void>;
|
|
7
7
|
}
|
package/Core/Particle.js
CHANGED
|
@@ -210,10 +210,10 @@ class Particle {
|
|
|
210
210
|
return (this.getRadius() ** 2 * Math.PI) / 2;
|
|
211
211
|
}
|
|
212
212
|
getFillColor() {
|
|
213
|
-
var _a, _b
|
|
213
|
+
var _a, _b;
|
|
214
214
|
const color = (_a = this.bubble.color) !== null && _a !== void 0 ? _a : (0, Utils_2.getHslFromAnimation)(this.color);
|
|
215
215
|
if (color && this.roll && (this.backColor || this.roll.alter)) {
|
|
216
|
-
const
|
|
216
|
+
const backFactor = this.options.roll.mode === "both" ? 2 : 1, backSum = this.options.roll.mode === "horizontal" ? Math.PI / 2 : 0, rolled = Math.floor((((_b = this.roll.angle) !== null && _b !== void 0 ? _b : 0) + backSum) / (Math.PI / backFactor)) % 2;
|
|
217
217
|
if (rolled) {
|
|
218
218
|
if (this.backColor) {
|
|
219
219
|
return this.backColor;
|
package/Core/Particles.d.ts
CHANGED
|
@@ -26,11 +26,11 @@ export declare class Particles {
|
|
|
26
26
|
private readonly mover;
|
|
27
27
|
constructor(engine: Engine, container: Container);
|
|
28
28
|
init(): void;
|
|
29
|
-
redraw(): void
|
|
29
|
+
redraw(): Promise<void>;
|
|
30
30
|
removeAt(index: number, quantity?: number, group?: string, override?: boolean): void;
|
|
31
31
|
remove(particle: Particle, group?: string, override?: boolean): void;
|
|
32
|
-
update(delta: IDelta): void
|
|
33
|
-
draw(delta: IDelta): void
|
|
32
|
+
update(delta: IDelta): Promise<void>;
|
|
33
|
+
draw(delta: IDelta): Promise<void>;
|
|
34
34
|
clear(): void;
|
|
35
35
|
push(nb: number, mouse?: IMouseData, overrideOptions?: RecursivePartial<IParticles>, group?: string): void;
|
|
36
36
|
addParticle(position?: ICoordinates, overrideOptions?: RecursivePartial<IParticles>, group?: string): Particle | undefined;
|
package/Core/Particles.js
CHANGED
|
@@ -75,10 +75,10 @@ class Particles {
|
|
|
75
75
|
}
|
|
76
76
|
container.pathGenerator.init(container);
|
|
77
77
|
}
|
|
78
|
-
redraw() {
|
|
78
|
+
async redraw() {
|
|
79
79
|
this.clear();
|
|
80
80
|
this.init();
|
|
81
|
-
this.draw({ value: 0, factor: 0 });
|
|
81
|
+
await this.draw({ value: 0, factor: 0 });
|
|
82
82
|
}
|
|
83
83
|
removeAt(index, quantity = 1, group, override) {
|
|
84
84
|
if (!(index >= 0 && index <= this.count)) {
|
|
@@ -100,7 +100,7 @@ class Particles {
|
|
|
100
100
|
remove(particle, group, override) {
|
|
101
101
|
this.removeAt(this.array.indexOf(particle), undefined, group, override);
|
|
102
102
|
}
|
|
103
|
-
update(delta) {
|
|
103
|
+
async update(delta) {
|
|
104
104
|
const container = this.container;
|
|
105
105
|
const particlesToDelete = [];
|
|
106
106
|
container.pathGenerator.update();
|
|
@@ -134,23 +134,23 @@ class Particles {
|
|
|
134
134
|
for (const particle of particlesToDelete) {
|
|
135
135
|
this.remove(particle);
|
|
136
136
|
}
|
|
137
|
-
this.interactionManager.externalInteract(delta);
|
|
137
|
+
await this.interactionManager.externalInteract(delta);
|
|
138
138
|
for (const particle of container.particles.array) {
|
|
139
139
|
for (const updater of this.updaters) {
|
|
140
140
|
updater.update(particle, delta);
|
|
141
141
|
}
|
|
142
142
|
if (!particle.destroyed && !particle.spawning) {
|
|
143
|
-
this.interactionManager.particlesInteract(particle, delta);
|
|
143
|
+
await this.interactionManager.particlesInteract(particle, delta);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
delete container.canvas.resizeFactor;
|
|
147
147
|
}
|
|
148
|
-
draw(delta) {
|
|
148
|
+
async draw(delta) {
|
|
149
149
|
const container = this.container;
|
|
150
150
|
container.canvas.clear();
|
|
151
151
|
const canvasSize = this.container.canvas.size;
|
|
152
152
|
this.quadTree = new Utils_1.QuadTree(new Utils_1.Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
|
|
153
|
-
this.update(delta);
|
|
153
|
+
await this.update(delta);
|
|
154
154
|
if (this.needsSort) {
|
|
155
155
|
this.zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
156
156
|
this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
|
|
@@ -6,7 +6,7 @@ export declare abstract class ExternalInteractorBase implements IExternalInterac
|
|
|
6
6
|
protected readonly container: Container;
|
|
7
7
|
protected constructor(container: Container);
|
|
8
8
|
type: InteractorType;
|
|
9
|
-
abstract interact(delta: IDelta): void
|
|
9
|
+
abstract interact(delta: IDelta): Promise<void>;
|
|
10
10
|
abstract isEnabled(): boolean;
|
|
11
11
|
abstract reset(particle: Particle): void;
|
|
12
12
|
}
|
|
@@ -5,7 +5,7 @@ class FrameManager {
|
|
|
5
5
|
constructor(container) {
|
|
6
6
|
this.container = container;
|
|
7
7
|
}
|
|
8
|
-
nextFrame(timestamp) {
|
|
8
|
+
async nextFrame(timestamp) {
|
|
9
9
|
var _a;
|
|
10
10
|
try {
|
|
11
11
|
const container = this.container;
|
|
@@ -26,7 +26,7 @@ class FrameManager {
|
|
|
26
26
|
container.draw(false);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
container.particles.draw(delta);
|
|
29
|
+
await container.particles.draw(delta);
|
|
30
30
|
if (container.duration > 0 && container.lifeTime > container.duration) {
|
|
31
31
|
container.destroy();
|
|
32
32
|
return;
|
|
@@ -9,6 +9,6 @@ export declare class InteractionManager {
|
|
|
9
9
|
private particleInteractors;
|
|
10
10
|
constructor(engine: Engine, container: Container);
|
|
11
11
|
init(): void;
|
|
12
|
-
externalInteract(delta: IDelta): void
|
|
13
|
-
particlesInteract(particle: Particle, delta: IDelta): void
|
|
12
|
+
externalInteract(delta: IDelta): Promise<void>;
|
|
13
|
+
particlesInteract(particle: Particle, delta: IDelta): Promise<void>;
|
|
14
14
|
}
|
|
@@ -37,20 +37,20 @@ class InteractionManager {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
externalInteract(delta) {
|
|
40
|
+
async externalInteract(delta) {
|
|
41
41
|
for (const interactor of this.externalInteractors) {
|
|
42
42
|
if (interactor.isEnabled()) {
|
|
43
|
-
interactor.interact(delta);
|
|
43
|
+
await interactor.interact(delta);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
particlesInteract(particle, delta) {
|
|
47
|
+
async particlesInteract(particle, delta) {
|
|
48
48
|
for (const interactor of this.externalInteractors) {
|
|
49
49
|
interactor.reset(particle);
|
|
50
50
|
}
|
|
51
51
|
for (const interactor of this.particleInteractors) {
|
|
52
52
|
if (interactor.isEnabled(particle)) {
|
|
53
|
-
interactor.interact(particle, delta);
|
|
53
|
+
await interactor.interact(particle, delta);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -6,7 +6,7 @@ export declare abstract class ParticlesInteractorBase implements IParticlesInter
|
|
|
6
6
|
protected readonly container: Container;
|
|
7
7
|
protected constructor(container: Container);
|
|
8
8
|
type: InteractorType;
|
|
9
|
-
abstract interact(particle: Particle, delta: IDelta): void
|
|
9
|
+
abstract interact(particle: Particle, delta: IDelta): Promise<void>;
|
|
10
10
|
abstract isEnabled(particle: Particle): boolean;
|
|
11
11
|
abstract reset(particle: Particle): void;
|
|
12
12
|
}
|
|
@@ -17,7 +17,7 @@ class Attractor extends Core_1.ExternalInteractorBase {
|
|
|
17
17
|
}
|
|
18
18
|
reset() {
|
|
19
19
|
}
|
|
20
|
-
interact() {
|
|
20
|
+
async interact() {
|
|
21
21
|
const container = this.container, options = container.actualOptions, mouseMoveStatus = container.interactivity.status === Core_1.Constants.mouseMoveEvent, events = options.interactivity.events, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, clickEnabled = events.onClick.enable, clickMode = events.onClick.mode;
|
|
22
22
|
if (mouseMoveStatus && hoverEnabled && (0, Utils_1.isInArray)("attract", hoverMode)) {
|
|
23
23
|
this.hoverAttract();
|
|
@@ -3,7 +3,7 @@ import type { Container } from "../../../Core";
|
|
|
3
3
|
export declare class Bouncer extends ExternalInteractorBase {
|
|
4
4
|
constructor(container: Container);
|
|
5
5
|
isEnabled(): boolean;
|
|
6
|
-
interact(): void
|
|
6
|
+
interact(): Promise<void>;
|
|
7
7
|
reset(): void;
|
|
8
8
|
private processMouseBounce;
|
|
9
9
|
private singleSelectorBounce;
|
|
@@ -12,7 +12,7 @@ class Bouncer extends Core_1.ExternalInteractorBase {
|
|
|
12
12
|
return ((mouse.position && events.onHover.enable && (0, Utils_1.isInArray)("bounce", events.onHover.mode)) ||
|
|
13
13
|
(0, Utils_1.isDivModeEnabled)("bounce", divs));
|
|
14
14
|
}
|
|
15
|
-
interact() {
|
|
15
|
+
async interact() {
|
|
16
16
|
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === Core_1.Constants.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
17
17
|
if (mouseMoveStatus && hoverEnabled && (0, Utils_1.isInArray)("bounce", hoverMode)) {
|
|
18
18
|
this.processMouseBounce();
|
|
@@ -5,7 +5,7 @@ export declare class Bubbler extends ExternalInteractorBase {
|
|
|
5
5
|
constructor(container: Container);
|
|
6
6
|
isEnabled(): boolean;
|
|
7
7
|
reset(particle: Particle, force?: boolean): void;
|
|
8
|
-
interact(): void
|
|
8
|
+
interact(): Promise<void>;
|
|
9
9
|
private singleSelectorHover;
|
|
10
10
|
private process;
|
|
11
11
|
private clickBubble;
|
|
@@ -35,7 +35,7 @@ class Bubbler extends Core_1.ExternalInteractorBase {
|
|
|
35
35
|
delete particle.bubble.radius;
|
|
36
36
|
delete particle.bubble.color;
|
|
37
37
|
}
|
|
38
|
-
interact() {
|
|
38
|
+
async interact() {
|
|
39
39
|
const options = this.container.actualOptions, events = options.interactivity.events, onHover = events.onHover, onClick = events.onClick, hoverEnabled = onHover.enable, hoverMode = onHover.mode, clickEnabled = onClick.enable, clickMode = onClick.mode, divs = events.onDiv;
|
|
40
40
|
if (hoverEnabled && (0, Utils_1.isInArray)("bubble", hoverMode)) {
|
|
41
41
|
this.hoverBubble();
|
|
@@ -16,7 +16,7 @@ class Connector extends Core_1.ExternalInteractorBase {
|
|
|
16
16
|
}
|
|
17
17
|
reset() {
|
|
18
18
|
}
|
|
19
|
-
interact() {
|
|
19
|
+
async interact() {
|
|
20
20
|
const container = this.container, options = container.actualOptions;
|
|
21
21
|
if (options.interactivity.events.onHover.enable && container.interactivity.status === "mousemove") {
|
|
22
22
|
const mousePos = container.interactivity.mouse.position;
|
|
@@ -13,7 +13,7 @@ class Grabber extends Core_1.ExternalInteractorBase {
|
|
|
13
13
|
}
|
|
14
14
|
reset() {
|
|
15
15
|
}
|
|
16
|
-
interact() {
|
|
16
|
+
async interact() {
|
|
17
17
|
var _a;
|
|
18
18
|
const container = this.container, options = container.actualOptions, interactivity = options.interactivity;
|
|
19
19
|
if (interactivity.events.onHover.enable && container.interactivity.status === Core_1.Constants.mouseMoveEvent) {
|
|
@@ -4,7 +4,7 @@ export declare class Repulser extends ExternalInteractorBase {
|
|
|
4
4
|
constructor(container: Container);
|
|
5
5
|
isEnabled(): boolean;
|
|
6
6
|
reset(): void;
|
|
7
|
-
interact(): void
|
|
7
|
+
interact(): Promise<void>;
|
|
8
8
|
private singleSelectorRepulse;
|
|
9
9
|
private hoverRepulse;
|
|
10
10
|
private processRepulse;
|
|
@@ -17,7 +17,7 @@ class Repulser extends Core_1.ExternalInteractorBase {
|
|
|
17
17
|
}
|
|
18
18
|
reset() {
|
|
19
19
|
}
|
|
20
|
-
interact() {
|
|
20
|
+
async interact() {
|
|
21
21
|
const container = this.container, options = container.actualOptions, mouseMoveStatus = container.interactivity.status === Core_1.Constants.mouseMoveEvent, events = options.interactivity.events, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, clickEnabled = events.onClick.enable, clickMode = events.onClick.mode, divs = events.onDiv;
|
|
22
22
|
if (mouseMoveStatus && hoverEnabled && (0, Utils_1.isInArray)("repulse", hoverMode)) {
|
|
23
23
|
this.hoverRepulse();
|
|
@@ -2,7 +2,7 @@ import type { Container, IParticle, Particle } from "../../../Core";
|
|
|
2
2
|
import { ParticlesInteractorBase } from "../../../Core";
|
|
3
3
|
export declare class Attractor extends ParticlesInteractorBase {
|
|
4
4
|
constructor(container: Container);
|
|
5
|
-
interact(p1: IParticle): void
|
|
5
|
+
interact(p1: IParticle): Promise<void>;
|
|
6
6
|
isEnabled(particle: Particle): boolean;
|
|
7
7
|
reset(): void;
|
|
8
8
|
}
|
|
@@ -7,7 +7,7 @@ class Attractor extends Core_1.ParticlesInteractorBase {
|
|
|
7
7
|
constructor(container) {
|
|
8
8
|
super(container);
|
|
9
9
|
}
|
|
10
|
-
interact(p1) {
|
|
10
|
+
async interact(p1) {
|
|
11
11
|
var _a;
|
|
12
12
|
const container = this.container, distance = (_a = p1.retina.attractDistance) !== null && _a !== void 0 ? _a : container.retina.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
|
|
13
13
|
for (const p2 of query) {
|
|
@@ -4,7 +4,7 @@ export declare class Collider extends ParticlesInteractorBase {
|
|
|
4
4
|
constructor(container: Container);
|
|
5
5
|
isEnabled(particle: Particle): boolean;
|
|
6
6
|
reset(): void;
|
|
7
|
-
interact(p1: Particle): void
|
|
7
|
+
interact(p1: Particle): Promise<void>;
|
|
8
8
|
private resolveCollision;
|
|
9
9
|
private absorb;
|
|
10
10
|
}
|
|
@@ -23,9 +23,9 @@ function updateOpacity(particle, delta) {
|
|
|
23
23
|
}
|
|
24
24
|
const minValue = particle.opacity.min;
|
|
25
25
|
const maxValue = particle.opacity.max;
|
|
26
|
-
if (
|
|
27
|
-
particle.opacity.enable
|
|
28
|
-
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0)
|
|
26
|
+
if (particle.destroyed ||
|
|
27
|
+
!particle.opacity.enable ||
|
|
28
|
+
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) > 0 && ((_b = particle.opacity.loops) !== null && _b !== void 0 ? _b : 0) > ((_c = particle.opacity.maxLoops) !== null && _c !== void 0 ? _c : 0))) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
switch (particle.opacity.status) {
|
|
@@ -102,12 +102,14 @@ class OpacityUpdater {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
isEnabled(particle) {
|
|
105
|
-
var _a, _b, _c;
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
106
|
return (!particle.destroyed &&
|
|
107
107
|
!particle.spawning &&
|
|
108
108
|
!!particle.opacity &&
|
|
109
109
|
particle.opacity.enable &&
|
|
110
|
-
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
|
|
110
|
+
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
|
|
111
|
+
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 &&
|
|
112
|
+
((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))));
|
|
111
113
|
}
|
|
112
114
|
update(particle, delta) {
|
|
113
115
|
if (!this.isEnabled(particle)) {
|
|
@@ -21,9 +21,9 @@ function updateSize(particle, delta) {
|
|
|
21
21
|
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor;
|
|
22
22
|
const minValue = particle.size.min;
|
|
23
23
|
const maxValue = particle.size.max;
|
|
24
|
-
if (
|
|
25
|
-
particle.size.enable
|
|
26
|
-
(((_b = particle.size.
|
|
24
|
+
if (particle.destroyed ||
|
|
25
|
+
!particle.size.enable ||
|
|
26
|
+
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
switch (particle.size.status) {
|
|
@@ -60,11 +60,12 @@ class SizeUpdater {
|
|
|
60
60
|
init() {
|
|
61
61
|
}
|
|
62
62
|
isEnabled(particle) {
|
|
63
|
-
var _a, _b, _c;
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
64
|
return (!particle.destroyed &&
|
|
65
65
|
!particle.spawning &&
|
|
66
66
|
particle.size.enable &&
|
|
67
|
-
(((_a = particle.size.
|
|
67
|
+
(((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
|
|
68
|
+
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))));
|
|
68
69
|
}
|
|
69
70
|
update(particle, delta) {
|
|
70
71
|
if (!this.isEnabled(particle)) {
|
|
@@ -146,12 +146,12 @@ export class Container {
|
|
|
146
146
|
*/
|
|
147
147
|
draw(force) {
|
|
148
148
|
let refreshTime = force;
|
|
149
|
-
this.drawAnimationFrame = animate()((timestamp) => {
|
|
149
|
+
this.drawAnimationFrame = animate()(async (timestamp) => {
|
|
150
150
|
if (refreshTime) {
|
|
151
151
|
this.lastFrameTime = undefined;
|
|
152
152
|
refreshTime = false;
|
|
153
153
|
}
|
|
154
|
-
this.drawer.nextFrame(timestamp);
|
|
154
|
+
await this.drawer.nextFrame(timestamp);
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
@@ -6,5 +6,5 @@ import type { Particle } from "../Particle";
|
|
|
6
6
|
*/
|
|
7
7
|
export interface IParticlesInteractor extends IInteractor {
|
|
8
8
|
isEnabled(particle: Particle): boolean;
|
|
9
|
-
interact(particle: Particle, delta: IDelta): void
|
|
9
|
+
interact(particle: Particle, delta: IDelta): Promise<void>;
|
|
10
10
|
}
|
package/browser/Core/Particle.js
CHANGED
|
@@ -216,10 +216,10 @@ export class Particle {
|
|
|
216
216
|
return (this.getRadius() ** 2 * Math.PI) / 2;
|
|
217
217
|
}
|
|
218
218
|
getFillColor() {
|
|
219
|
-
var _a, _b
|
|
219
|
+
var _a, _b;
|
|
220
220
|
const color = (_a = this.bubble.color) !== null && _a !== void 0 ? _a : getHslFromAnimation(this.color);
|
|
221
221
|
if (color && this.roll && (this.backColor || this.roll.alter)) {
|
|
222
|
-
const
|
|
222
|
+
const backFactor = this.options.roll.mode === "both" /* both */ ? 2 : 1, backSum = this.options.roll.mode === "horizontal" /* horizontal */ ? Math.PI / 2 : 0, rolled = Math.floor((((_b = this.roll.angle) !== null && _b !== void 0 ? _b : 0) + backSum) / (Math.PI / backFactor)) % 2;
|
|
223
223
|
if (rolled) {
|
|
224
224
|
if (this.backColor) {
|
|
225
225
|
return this.backColor;
|
|
@@ -36,11 +36,11 @@ export declare class Particles {
|
|
|
36
36
|
private readonly mover;
|
|
37
37
|
constructor(engine: Engine, container: Container);
|
|
38
38
|
init(): void;
|
|
39
|
-
redraw(): void
|
|
39
|
+
redraw(): Promise<void>;
|
|
40
40
|
removeAt(index: number, quantity?: number, group?: string, override?: boolean): void;
|
|
41
41
|
remove(particle: Particle, group?: string, override?: boolean): void;
|
|
42
|
-
update(delta: IDelta): void
|
|
43
|
-
draw(delta: IDelta): void
|
|
42
|
+
update(delta: IDelta): Promise<void>;
|
|
43
|
+
draw(delta: IDelta): Promise<void>;
|
|
44
44
|
/**
|
|
45
45
|
* Removes all particles from the array
|
|
46
46
|
*/
|
|
@@ -77,10 +77,10 @@ export class Particles {
|
|
|
77
77
|
}
|
|
78
78
|
container.pathGenerator.init(container);
|
|
79
79
|
}
|
|
80
|
-
redraw() {
|
|
80
|
+
async redraw() {
|
|
81
81
|
this.clear();
|
|
82
82
|
this.init();
|
|
83
|
-
this.draw({ value: 0, factor: 0 });
|
|
83
|
+
await this.draw({ value: 0, factor: 0 });
|
|
84
84
|
}
|
|
85
85
|
removeAt(index, quantity = 1, group, override) {
|
|
86
86
|
if (!(index >= 0 && index <= this.count)) {
|
|
@@ -102,7 +102,7 @@ export class Particles {
|
|
|
102
102
|
remove(particle, group, override) {
|
|
103
103
|
this.removeAt(this.array.indexOf(particle), undefined, group, override);
|
|
104
104
|
}
|
|
105
|
-
update(delta) {
|
|
105
|
+
async update(delta) {
|
|
106
106
|
const container = this.container;
|
|
107
107
|
const particlesToDelete = [];
|
|
108
108
|
container.pathGenerator.update();
|
|
@@ -144,26 +144,26 @@ export class Particles {
|
|
|
144
144
|
for (const particle of particlesToDelete) {
|
|
145
145
|
this.remove(particle);
|
|
146
146
|
}
|
|
147
|
-
this.interactionManager.externalInteract(delta);
|
|
147
|
+
await this.interactionManager.externalInteract(delta);
|
|
148
148
|
// this loop is required to be done after mouse interactions
|
|
149
149
|
for (const particle of container.particles.array) {
|
|
150
150
|
for (const updater of this.updaters) {
|
|
151
151
|
updater.update(particle, delta);
|
|
152
152
|
}
|
|
153
153
|
if (!particle.destroyed && !particle.spawning) {
|
|
154
|
-
this.interactionManager.particlesInteract(particle, delta);
|
|
154
|
+
await this.interactionManager.particlesInteract(particle, delta);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
delete container.canvas.resizeFactor;
|
|
158
158
|
}
|
|
159
|
-
draw(delta) {
|
|
159
|
+
async draw(delta) {
|
|
160
160
|
const container = this.container;
|
|
161
161
|
/* clear canvas */
|
|
162
162
|
container.canvas.clear();
|
|
163
163
|
const canvasSize = this.container.canvas.size;
|
|
164
164
|
this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
|
|
165
165
|
/* update each particles param */
|
|
166
|
-
this.update(delta);
|
|
166
|
+
await this.update(delta);
|
|
167
167
|
if (this.needsSort) {
|
|
168
168
|
this.zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
169
169
|
this.lastZIndex = this.zArray[this.zArray.length - 1].position.z;
|
|
@@ -6,7 +6,7 @@ export declare abstract class ExternalInteractorBase implements IExternalInterac
|
|
|
6
6
|
protected readonly container: Container;
|
|
7
7
|
protected constructor(container: Container);
|
|
8
8
|
type: InteractorType;
|
|
9
|
-
abstract interact(delta: IDelta): void
|
|
9
|
+
abstract interact(delta: IDelta): Promise<void>;
|
|
10
10
|
abstract isEnabled(): boolean;
|
|
11
11
|
abstract reset(particle: Particle): void;
|
|
12
12
|
}
|
|
@@ -10,7 +10,7 @@ export class FrameManager {
|
|
|
10
10
|
* limiting it if it's needed by the current configuration
|
|
11
11
|
* @param timestamp
|
|
12
12
|
*/
|
|
13
|
-
nextFrame(timestamp) {
|
|
13
|
+
async nextFrame(timestamp) {
|
|
14
14
|
var _a;
|
|
15
15
|
try {
|
|
16
16
|
const container = this.container;
|
|
@@ -32,7 +32,7 @@ export class FrameManager {
|
|
|
32
32
|
container.draw(false);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
container.particles.draw(delta);
|
|
35
|
+
await container.particles.draw(delta);
|
|
36
36
|
if (container.duration > 0 && container.lifeTime > container.duration) {
|
|
37
37
|
container.destroy();
|
|
38
38
|
return;
|
|
@@ -12,6 +12,6 @@ export declare class InteractionManager {
|
|
|
12
12
|
private particleInteractors;
|
|
13
13
|
constructor(engine: Engine, container: Container);
|
|
14
14
|
init(): void;
|
|
15
|
-
externalInteract(delta: IDelta): void
|
|
16
|
-
particlesInteract(particle: Particle, delta: IDelta): void
|
|
15
|
+
externalInteract(delta: IDelta): Promise<void>;
|
|
16
|
+
particlesInteract(particle: Particle, delta: IDelta): Promise<void>;
|
|
17
17
|
}
|