@tsparticles/engine 3.3.0 → 3.4.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/README.md +0 -4
- package/browser/Core/Canvas.js +27 -22
- package/browser/Core/Container.js +55 -42
- package/browser/Core/Engine.js +82 -74
- package/browser/Core/Particle.js +29 -15
- package/browser/Core/Particles.js +23 -24
- package/browser/Core/Utils/EventListeners.js +18 -17
- package/browser/Core/Utils/ExternalInteractorBase.js +2 -1
- package/browser/Core/Utils/InteractionManager.js +3 -2
- package/browser/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Core/Utils/Ranges.js +5 -4
- package/browser/Enums/AnimationStatus.js +5 -1
- package/browser/Enums/Directions/MoveDirection.js +14 -1
- package/browser/Enums/Directions/OutModeDirection.js +7 -1
- package/browser/Enums/Directions/RotateDirection.js +6 -1
- package/browser/Enums/InteractivityDetect.js +6 -1
- package/browser/Enums/Modes/AnimationMode.js +7 -1
- package/browser/Enums/Modes/CollisionMode.js +6 -1
- package/browser/Enums/Modes/LimitMode.js +5 -1
- package/browser/Enums/Modes/OutMode.js +8 -1
- package/browser/Enums/Modes/PixelMode.js +5 -1
- package/browser/Enums/Modes/ResponsiveMode.js +5 -1
- package/browser/Enums/Modes/ThemeMode.js +6 -1
- package/browser/Enums/Types/AlterType.js +5 -1
- package/browser/Enums/Types/DestroyType.js +6 -1
- package/browser/Enums/Types/DivType.js +5 -1
- package/browser/Enums/Types/EasingType.js +30 -1
- package/browser/Enums/Types/EventType.js +15 -1
- package/browser/Enums/Types/GradientType.js +6 -1
- package/browser/Enums/Types/InteractorType.js +5 -1
- package/browser/Enums/Types/ParticleOutType.js +6 -1
- package/browser/Enums/Types/StartValueType.js +6 -1
- package/browser/Options/Classes/AnimationOptions.js +4 -2
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/browser/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/browser/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/browser/Options/Classes/ManualParticle.js +2 -1
- package/browser/Options/Classes/Options.js +14 -12
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/browser/Options/Classes/Particles/Move/Move.js +2 -1
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/browser/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/browser/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/browser/Options/Classes/Responsive.js +5 -4
- package/browser/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/browser/Types/RangeType.js +5 -1
- package/browser/Utils/CanvasUtils.js +13 -7
- package/browser/Utils/ColorUtils.js +17 -9
- package/browser/Utils/EventDispatcher.js +1 -1
- package/browser/Utils/HslColorManager.js +11 -4
- package/browser/Utils/NumberUtils.js +11 -10
- package/browser/Utils/RgbColorManager.js +11 -4
- package/browser/Utils/Utils.js +37 -31
- package/cjs/Core/Canvas.js +27 -22
- package/cjs/Core/Container.js +55 -42
- package/cjs/Core/Engine.js +82 -74
- package/cjs/Core/Particle.js +29 -15
- package/cjs/Core/Particles.js +23 -24
- package/cjs/Core/Utils/EventListeners.js +18 -17
- package/cjs/Core/Utils/ExternalInteractorBase.js +2 -1
- package/cjs/Core/Utils/InteractionManager.js +3 -2
- package/cjs/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/cjs/Core/Utils/QuadTree.js +1 -1
- package/cjs/Core/Utils/Ranges.js +5 -4
- package/cjs/Enums/AnimationStatus.js +6 -0
- package/cjs/Enums/Directions/MoveDirection.js +15 -0
- package/cjs/Enums/Directions/OutModeDirection.js +8 -0
- package/cjs/Enums/Directions/RotateDirection.js +7 -0
- package/cjs/Enums/InteractivityDetect.js +7 -0
- package/cjs/Enums/Modes/AnimationMode.js +8 -0
- package/cjs/Enums/Modes/CollisionMode.js +7 -0
- package/cjs/Enums/Modes/LimitMode.js +6 -0
- package/cjs/Enums/Modes/OutMode.js +9 -0
- package/cjs/Enums/Modes/PixelMode.js +6 -0
- package/cjs/Enums/Modes/ResponsiveMode.js +6 -0
- package/cjs/Enums/Modes/ThemeMode.js +7 -0
- package/cjs/Enums/Types/AlterType.js +6 -0
- package/cjs/Enums/Types/DestroyType.js +7 -0
- package/cjs/Enums/Types/DivType.js +6 -0
- package/cjs/Enums/Types/EasingType.js +31 -0
- package/cjs/Enums/Types/EventType.js +16 -0
- package/cjs/Enums/Types/GradientType.js +7 -0
- package/cjs/Enums/Types/InteractorType.js +6 -0
- package/cjs/Enums/Types/ParticleOutType.js +7 -0
- package/cjs/Enums/Types/StartValueType.js +7 -0
- package/cjs/Options/Classes/AnimationOptions.js +4 -2
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/cjs/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/cjs/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/cjs/Options/Classes/ManualParticle.js +2 -1
- package/cjs/Options/Classes/Options.js +14 -12
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/cjs/Options/Classes/Particles/Move/Move.js +2 -1
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/cjs/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/cjs/Options/Classes/Responsive.js +5 -4
- package/cjs/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/cjs/Types/RangeType.js +6 -0
- package/cjs/Utils/CanvasUtils.js +13 -7
- package/cjs/Utils/ColorUtils.js +17 -9
- package/cjs/Utils/EventDispatcher.js +1 -1
- package/cjs/Utils/HslColorManager.js +11 -4
- package/cjs/Utils/NumberUtils.js +11 -10
- package/cjs/Utils/RgbColorManager.js +11 -4
- package/cjs/Utils/Utils.js +37 -31
- package/esm/Core/Canvas.js +27 -22
- package/esm/Core/Container.js +55 -42
- package/esm/Core/Engine.js +82 -74
- package/esm/Core/Particle.js +29 -15
- package/esm/Core/Particles.js +23 -24
- package/esm/Core/Utils/EventListeners.js +18 -17
- package/esm/Core/Utils/ExternalInteractorBase.js +2 -1
- package/esm/Core/Utils/InteractionManager.js +3 -2
- package/esm/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Core/Utils/Ranges.js +5 -4
- package/esm/Enums/AnimationStatus.js +5 -1
- package/esm/Enums/Directions/MoveDirection.js +14 -1
- package/esm/Enums/Directions/OutModeDirection.js +7 -1
- package/esm/Enums/Directions/RotateDirection.js +6 -1
- package/esm/Enums/InteractivityDetect.js +6 -1
- package/esm/Enums/Modes/AnimationMode.js +7 -1
- package/esm/Enums/Modes/CollisionMode.js +6 -1
- package/esm/Enums/Modes/LimitMode.js +5 -1
- package/esm/Enums/Modes/OutMode.js +8 -1
- package/esm/Enums/Modes/PixelMode.js +5 -1
- package/esm/Enums/Modes/ResponsiveMode.js +5 -1
- package/esm/Enums/Modes/ThemeMode.js +6 -1
- package/esm/Enums/Types/AlterType.js +5 -1
- package/esm/Enums/Types/DestroyType.js +6 -1
- package/esm/Enums/Types/DivType.js +5 -1
- package/esm/Enums/Types/EasingType.js +30 -1
- package/esm/Enums/Types/EventType.js +15 -1
- package/esm/Enums/Types/GradientType.js +6 -1
- package/esm/Enums/Types/InteractorType.js +5 -1
- package/esm/Enums/Types/ParticleOutType.js +6 -1
- package/esm/Enums/Types/StartValueType.js +6 -1
- package/esm/Options/Classes/AnimationOptions.js +4 -2
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/esm/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/esm/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/esm/Options/Classes/ManualParticle.js +2 -1
- package/esm/Options/Classes/Options.js +14 -12
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/esm/Options/Classes/Particles/Move/Move.js +2 -1
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/esm/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/esm/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/esm/Options/Classes/Responsive.js +5 -4
- package/esm/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/esm/Types/RangeType.js +5 -1
- package/esm/Utils/CanvasUtils.js +13 -7
- package/esm/Utils/ColorUtils.js +17 -9
- package/esm/Utils/EventDispatcher.js +1 -1
- package/esm/Utils/HslColorManager.js +11 -4
- package/esm/Utils/NumberUtils.js +11 -10
- package/esm/Utils/RgbColorManager.js +11 -4
- package/esm/Utils/Utils.js +37 -31
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +327 -225
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Container.d.ts +4 -2
- package/types/Core/Engine.d.ts +6 -5
- package/types/Core/Interfaces/IPlugin.d.ts +3 -4
- package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
- package/types/Core/Particle.d.ts +1 -0
- package/types/Enums/AnimationStatus.d.ts +1 -1
- package/types/Enums/Directions/MoveDirection.d.ts +1 -1
- package/types/Enums/Directions/OutModeDirection.d.ts +1 -1
- package/types/Enums/Directions/RotateDirection.d.ts +1 -1
- package/types/Enums/InteractivityDetect.d.ts +1 -1
- package/types/Enums/Modes/AnimationMode.d.ts +1 -1
- package/types/Enums/Modes/CollisionMode.d.ts +1 -1
- package/types/Enums/Modes/LimitMode.d.ts +1 -1
- package/types/Enums/Modes/OutMode.d.ts +1 -1
- package/types/Enums/Modes/PixelMode.d.ts +1 -1
- package/types/Enums/Modes/ResponsiveMode.d.ts +1 -1
- package/types/Enums/Modes/ThemeMode.d.ts +1 -1
- package/types/Enums/Types/AlterType.d.ts +1 -1
- package/types/Enums/Types/DestroyType.d.ts +1 -1
- package/types/Enums/Types/DivType.d.ts +1 -1
- package/types/Enums/Types/EasingType.d.ts +1 -1
- package/types/Enums/Types/EventType.d.ts +1 -1
- package/types/Enums/Types/GradientType.d.ts +1 -1
- package/types/Enums/Types/InteractorType.d.ts +1 -1
- package/types/Enums/Types/ParticleOutType.d.ts +1 -1
- package/types/Enums/Types/StartValueType.d.ts +1 -1
- package/types/Options/Classes/Options.d.ts +2 -1
- package/types/Options/Classes/Responsive.d.ts +2 -2
- package/types/Options/Classes/Theme/Theme.d.ts +2 -2
- package/types/Options/Interfaces/IResponsive.d.ts +2 -3
- package/types/Options/Interfaces/Theme/ITheme.d.ts +2 -3
- package/types/Types/RangeType.d.ts +1 -1
- package/umd/Core/Canvas.js +27 -22
- package/umd/Core/Container.js +56 -43
- package/umd/Core/Engine.js +83 -99
- package/umd/Core/Particle.js +30 -16
- package/umd/Core/Particles.js +24 -25
- package/umd/Core/Utils/EventListeners.js +19 -18
- package/umd/Core/Utils/ExternalInteractorBase.js +3 -2
- package/umd/Core/Utils/InteractionManager.js +4 -3
- package/umd/Core/Utils/ParticlesInteractorBase.js +3 -2
- package/umd/Core/Utils/QuadTree.js +1 -1
- package/umd/Core/Utils/Ranges.js +6 -5
- package/umd/Enums/AnimationStatus.js +6 -0
- package/umd/Enums/Directions/MoveDirection.js +15 -0
- package/umd/Enums/Directions/OutModeDirection.js +8 -0
- package/umd/Enums/Directions/RotateDirection.js +7 -0
- package/umd/Enums/InteractivityDetect.js +7 -0
- package/umd/Enums/Modes/AnimationMode.js +8 -0
- package/umd/Enums/Modes/CollisionMode.js +7 -0
- package/umd/Enums/Modes/LimitMode.js +6 -0
- package/umd/Enums/Modes/OutMode.js +9 -0
- package/umd/Enums/Modes/PixelMode.js +6 -0
- package/umd/Enums/Modes/ResponsiveMode.js +6 -0
- package/umd/Enums/Modes/ThemeMode.js +7 -0
- package/umd/Enums/Types/AlterType.js +6 -0
- package/umd/Enums/Types/DestroyType.js +7 -0
- package/umd/Enums/Types/DivType.js +6 -0
- package/umd/Enums/Types/EasingType.js +31 -0
- package/umd/Enums/Types/EventType.js +16 -0
- package/umd/Enums/Types/GradientType.js +7 -0
- package/umd/Enums/Types/InteractorType.js +6 -0
- package/umd/Enums/Types/ParticleOutType.js +7 -0
- package/umd/Enums/Types/StartValueType.js +7 -0
- package/umd/Options/Classes/AnimationOptions.js +5 -3
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +3 -2
- package/umd/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/umd/Options/Classes/Interactivity/Interactivity.js +3 -2
- package/umd/Options/Classes/ManualParticle.js +3 -2
- package/umd/Options/Classes/Options.js +15 -13
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +3 -2
- package/umd/Options/Classes/Particles/Move/Move.js +3 -2
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +3 -2
- package/umd/Options/Classes/Particles/Move/OutModes.js +3 -2
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +3 -2
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +3 -2
- package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +3 -2
- package/umd/Options/Classes/Responsive.js +6 -5
- package/umd/Options/Classes/Theme/ThemeDefault.js +3 -2
- package/umd/Types/RangeType.js +6 -0
- package/umd/Utils/CanvasUtils.js +14 -8
- package/umd/Utils/ColorUtils.js +18 -10
- package/umd/Utils/EventDispatcher.js +1 -1
- package/umd/Utils/HslColorManager.js +11 -4
- package/umd/Utils/NumberUtils.js +12 -11
- package/umd/Utils/RgbColorManager.js +11 -4
- package/umd/Utils/Utils.js +38 -32
- package/174.min.js +0 -2
- package/174.min.js.LICENSE.txt +0 -1
- package/dist_browser_Core_Container_js.js +0 -102
package/browser/Utils/Utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { clamp, collisionVelocity, getDistances, getRandom, getRangeMax, getRangeMin, getRangeValue, randomInRange, } from "./NumberUtils.js";
|
|
2
2
|
import { halfRandom, millisecondsToSeconds, percentDenominator } from "../Core/Utils/Constants.js";
|
|
3
3
|
import { isArray, isObject } from "./TypeUtils.js";
|
|
4
|
+
import { AnimationMode } from "../Enums/Modes/AnimationMode.js";
|
|
5
|
+
import { AnimationStatus } from "../Enums/AnimationStatus.js";
|
|
6
|
+
import { DestroyType } from "../Enums/Types/DestroyType.js";
|
|
7
|
+
import { OutModeDirection } from "../Enums/Directions/OutModeDirection.js";
|
|
8
|
+
import { PixelMode } from "../Enums/Modes/PixelMode.js";
|
|
9
|
+
import { StartValueType } from "../Enums/Types/StartValueType.js";
|
|
4
10
|
import { Vector } from "../Core/Utils/Vectors.js";
|
|
5
11
|
const _logger = {
|
|
6
12
|
debug: console.debug,
|
|
@@ -37,10 +43,10 @@ function rectSideBounce(data) {
|
|
|
37
43
|
return res;
|
|
38
44
|
}
|
|
39
45
|
function checkSelector(element, selectors) {
|
|
40
|
-
const res = executeOnSingleOrMultiple(selectors,
|
|
46
|
+
const res = executeOnSingleOrMultiple(selectors, selector => {
|
|
41
47
|
return element.matches(selector);
|
|
42
48
|
});
|
|
43
|
-
return isArray(res) ? res.some(
|
|
49
|
+
return isArray(res) ? res.some(t => t) : res;
|
|
44
50
|
}
|
|
45
51
|
export function isSsr() {
|
|
46
52
|
return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
|
|
@@ -89,16 +95,16 @@ export function isPointInside(point, size, offset, radius, direction) {
|
|
|
89
95
|
}
|
|
90
96
|
export function areBoundsInside(bounds, size, offset, direction) {
|
|
91
97
|
let inside = true;
|
|
92
|
-
if (!direction || direction ===
|
|
98
|
+
if (!direction || direction === OutModeDirection.bottom) {
|
|
93
99
|
inside = bounds.top < size.height + offset.x;
|
|
94
100
|
}
|
|
95
|
-
if (inside && (!direction || direction ===
|
|
101
|
+
if (inside && (!direction || direction === OutModeDirection.left)) {
|
|
96
102
|
inside = bounds.right > offset.x;
|
|
97
103
|
}
|
|
98
|
-
if (inside && (!direction || direction ===
|
|
104
|
+
if (inside && (!direction || direction === OutModeDirection.right)) {
|
|
99
105
|
inside = bounds.left < size.width + offset.y;
|
|
100
106
|
}
|
|
101
|
-
if (inside && (!direction || direction ===
|
|
107
|
+
if (inside && (!direction || direction === OutModeDirection.top)) {
|
|
102
108
|
inside = bounds.bottom > offset.y;
|
|
103
109
|
}
|
|
104
110
|
return inside;
|
|
@@ -134,17 +140,17 @@ export function deepExtend(destination, ...sources) {
|
|
|
134
140
|
const sourceDict = source, value = sourceDict[key], destDict = destination;
|
|
135
141
|
destDict[key] =
|
|
136
142
|
isObject(value) && Array.isArray(value)
|
|
137
|
-
? value.map(
|
|
143
|
+
? value.map(v => deepExtend(destDict[key], v))
|
|
138
144
|
: deepExtend(destDict[key], value);
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
147
|
return destination;
|
|
142
148
|
}
|
|
143
149
|
export function isDivModeEnabled(mode, divs) {
|
|
144
|
-
return !!findItemFromSingleOrMultiple(divs,
|
|
150
|
+
return !!findItemFromSingleOrMultiple(divs, t => t.enable && isInArray(mode, t.mode));
|
|
145
151
|
}
|
|
146
152
|
export function divModeExecute(mode, divs, callback) {
|
|
147
|
-
executeOnSingleOrMultiple(divs,
|
|
153
|
+
executeOnSingleOrMultiple(divs, div => {
|
|
148
154
|
const divMode = div.mode, divEnabled = div.enable;
|
|
149
155
|
if (divEnabled && isInArray(mode, divMode)) {
|
|
150
156
|
singleDivModeExecute(div, callback);
|
|
@@ -153,7 +159,7 @@ export function divModeExecute(mode, divs, callback) {
|
|
|
153
159
|
}
|
|
154
160
|
export function singleDivModeExecute(div, callback) {
|
|
155
161
|
const selectors = div.selectors;
|
|
156
|
-
executeOnSingleOrMultiple(selectors,
|
|
162
|
+
executeOnSingleOrMultiple(selectors, selector => {
|
|
157
163
|
callback(selector, div);
|
|
158
164
|
});
|
|
159
165
|
}
|
|
@@ -161,7 +167,7 @@ export function divMode(divs, element) {
|
|
|
161
167
|
if (!element || !divs) {
|
|
162
168
|
return;
|
|
163
169
|
}
|
|
164
|
-
return findItemFromSingleOrMultiple(divs,
|
|
170
|
+
return findItemFromSingleOrMultiple(divs, div => {
|
|
165
171
|
return checkSelector(element, div.selectors);
|
|
166
172
|
});
|
|
167
173
|
}
|
|
@@ -271,35 +277,35 @@ export function initParticleNumericAnimationValue(options, pxRatio) {
|
|
|
271
277
|
if (animationOptions.enable) {
|
|
272
278
|
res.decay = decayOffset - getRangeValue(animationOptions.decay);
|
|
273
279
|
switch (animationOptions.mode) {
|
|
274
|
-
case
|
|
275
|
-
res.status =
|
|
280
|
+
case AnimationMode.increase:
|
|
281
|
+
res.status = AnimationStatus.increasing;
|
|
276
282
|
break;
|
|
277
|
-
case
|
|
278
|
-
res.status =
|
|
283
|
+
case AnimationMode.decrease:
|
|
284
|
+
res.status = AnimationStatus.decreasing;
|
|
279
285
|
break;
|
|
280
|
-
case
|
|
281
|
-
res.status = getRandom() >= halfRandom ?
|
|
286
|
+
case AnimationMode.random:
|
|
287
|
+
res.status = getRandom() >= halfRandom ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
282
288
|
break;
|
|
283
289
|
}
|
|
284
|
-
const autoStatus = animationOptions.mode ===
|
|
290
|
+
const autoStatus = animationOptions.mode === AnimationMode.auto;
|
|
285
291
|
switch (animationOptions.startValue) {
|
|
286
|
-
case
|
|
292
|
+
case StartValueType.min:
|
|
287
293
|
res.value = res.min;
|
|
288
294
|
if (autoStatus) {
|
|
289
|
-
res.status =
|
|
295
|
+
res.status = AnimationStatus.increasing;
|
|
290
296
|
}
|
|
291
297
|
break;
|
|
292
|
-
case
|
|
298
|
+
case StartValueType.max:
|
|
293
299
|
res.value = res.max;
|
|
294
300
|
if (autoStatus) {
|
|
295
|
-
res.status =
|
|
301
|
+
res.status = AnimationStatus.decreasing;
|
|
296
302
|
}
|
|
297
303
|
break;
|
|
298
|
-
case
|
|
304
|
+
case StartValueType.random:
|
|
299
305
|
default:
|
|
300
306
|
res.value = randomInRange(res);
|
|
301
307
|
if (autoStatus) {
|
|
302
|
-
res.status = getRandom() >= halfRandom ?
|
|
308
|
+
res.status = getRandom() >= halfRandom ? AnimationStatus.increasing : AnimationStatus.decreasing;
|
|
303
309
|
}
|
|
304
310
|
break;
|
|
305
311
|
}
|
|
@@ -308,7 +314,7 @@ export function initParticleNumericAnimationValue(options, pxRatio) {
|
|
|
308
314
|
return res;
|
|
309
315
|
}
|
|
310
316
|
function getPositionOrSize(positionOrSize, canvasSize) {
|
|
311
|
-
const isPercent = positionOrSize.mode ===
|
|
317
|
+
const isPercent = positionOrSize.mode === PixelMode.percent;
|
|
312
318
|
if (!isPercent) {
|
|
313
319
|
const { mode: _, ...rest } = positionOrSize;
|
|
314
320
|
return rest;
|
|
@@ -335,12 +341,12 @@ export function getSize(size, canvasSize) {
|
|
|
335
341
|
}
|
|
336
342
|
function checkDestroy(particle, destroyType, value, minValue, maxValue) {
|
|
337
343
|
switch (destroyType) {
|
|
338
|
-
case
|
|
344
|
+
case DestroyType.max:
|
|
339
345
|
if (value >= maxValue) {
|
|
340
346
|
particle.destroy();
|
|
341
347
|
}
|
|
342
348
|
break;
|
|
343
|
-
case
|
|
349
|
+
case DestroyType.min:
|
|
344
350
|
if (value <= minValue) {
|
|
345
351
|
particle.destroy();
|
|
346
352
|
}
|
|
@@ -366,10 +372,10 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
|
|
|
366
372
|
return;
|
|
367
373
|
}
|
|
368
374
|
switch (data.status) {
|
|
369
|
-
case
|
|
375
|
+
case AnimationStatus.increasing:
|
|
370
376
|
if (data.value >= maxValue) {
|
|
371
377
|
if (changeDirection) {
|
|
372
|
-
data.status =
|
|
378
|
+
data.status = AnimationStatus.decreasing;
|
|
373
379
|
}
|
|
374
380
|
else {
|
|
375
381
|
data.value -= maxValue;
|
|
@@ -383,10 +389,10 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
|
|
|
383
389
|
data.value += velocity;
|
|
384
390
|
}
|
|
385
391
|
break;
|
|
386
|
-
case
|
|
392
|
+
case AnimationStatus.decreasing:
|
|
387
393
|
if (data.value <= minValue) {
|
|
388
394
|
if (changeDirection) {
|
|
389
|
-
data.status =
|
|
395
|
+
data.status = AnimationStatus.increasing;
|
|
390
396
|
}
|
|
391
397
|
else {
|
|
392
398
|
data.value += maxValue;
|
package/cjs/Core/Canvas.js
CHANGED
|
@@ -34,7 +34,7 @@ function setStyle(canvas, style, important = false) {
|
|
|
34
34
|
class Canvas {
|
|
35
35
|
constructor(container) {
|
|
36
36
|
this.container = container;
|
|
37
|
-
this._applyPostDrawUpdaters =
|
|
37
|
+
this._applyPostDrawUpdaters = particle => {
|
|
38
38
|
for (const updater of this._postDrawUpdaters) {
|
|
39
39
|
updater.afterDraw?.(particle);
|
|
40
40
|
}
|
|
@@ -64,7 +64,7 @@ class Canvas {
|
|
|
64
64
|
plugin.resize?.();
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
this._getPluginParticleColors =
|
|
67
|
+
this._getPluginParticleColors = particle => {
|
|
68
68
|
let fColor, sColor;
|
|
69
69
|
for (const plugin of this._colorPlugins) {
|
|
70
70
|
if (!fColor && plugin.particleFillColor) {
|
|
@@ -104,7 +104,7 @@ class Canvas {
|
|
|
104
104
|
};
|
|
105
105
|
resolve();
|
|
106
106
|
});
|
|
107
|
-
img.addEventListener("error",
|
|
107
|
+
img.addEventListener("error", evt => {
|
|
108
108
|
reject(evt.error);
|
|
109
109
|
});
|
|
110
110
|
img.src = cover.image;
|
|
@@ -165,28 +165,33 @@ class Canvas {
|
|
|
165
165
|
};
|
|
166
166
|
resolve();
|
|
167
167
|
});
|
|
168
|
-
img.addEventListener("error",
|
|
168
|
+
img.addEventListener("error", evt => {
|
|
169
169
|
reject(evt.error);
|
|
170
170
|
});
|
|
171
171
|
img.src = trailFill.image;
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
this._paintBase =
|
|
176
|
-
this.draw(
|
|
175
|
+
this._paintBase = baseColor => {
|
|
176
|
+
this.draw(ctx => (0, CanvasUtils_js_1.paintBase)(ctx, this.size, baseColor));
|
|
177
177
|
};
|
|
178
178
|
this._paintImage = (image, opacity) => {
|
|
179
|
-
this.draw(
|
|
179
|
+
this.draw(ctx => (0, CanvasUtils_js_1.paintImage)(ctx, this.size, image, opacity));
|
|
180
180
|
};
|
|
181
181
|
this._repairStyle = () => {
|
|
182
182
|
const element = this.element;
|
|
183
183
|
if (!element) {
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
-
this._safeMutationObserver(
|
|
186
|
+
this._safeMutationObserver(observer => observer.disconnect());
|
|
187
187
|
this._initStyle();
|
|
188
188
|
this.initBackground();
|
|
189
|
-
this._safeMutationObserver(
|
|
189
|
+
this._safeMutationObserver(observer => {
|
|
190
|
+
if (!element || !(element instanceof Node)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
observer.observe(element, { attributes: true });
|
|
194
|
+
});
|
|
190
195
|
};
|
|
191
196
|
this._resetOriginalStyle = () => {
|
|
192
197
|
const element = this.element, originalStyle = this._originalStyle;
|
|
@@ -195,7 +200,7 @@ class Canvas {
|
|
|
195
200
|
}
|
|
196
201
|
setStyle(element, originalStyle);
|
|
197
202
|
};
|
|
198
|
-
this._safeMutationObserver =
|
|
203
|
+
this._safeMutationObserver = callback => {
|
|
199
204
|
if (!this._mutationObserver) {
|
|
200
205
|
return;
|
|
201
206
|
}
|
|
@@ -244,7 +249,7 @@ class Canvas {
|
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
251
|
else if (options.clear) {
|
|
247
|
-
this.draw(
|
|
252
|
+
this.draw(ctx => {
|
|
248
253
|
(0, CanvasUtils_js_1.clear)(ctx, this.size);
|
|
249
254
|
});
|
|
250
255
|
}
|
|
@@ -319,14 +324,14 @@ class Canvas {
|
|
|
319
324
|
});
|
|
320
325
|
}
|
|
321
326
|
drawParticlePlugin(plugin, particle, delta) {
|
|
322
|
-
this.draw(
|
|
327
|
+
this.draw(ctx => (0, CanvasUtils_js_1.drawParticlePlugin)(ctx, plugin, particle, delta));
|
|
323
328
|
}
|
|
324
329
|
drawPlugin(plugin, delta) {
|
|
325
|
-
this.draw(
|
|
330
|
+
this.draw(ctx => (0, CanvasUtils_js_1.drawPlugin)(ctx, plugin, delta));
|
|
326
331
|
}
|
|
327
332
|
async init() {
|
|
328
|
-
this._safeMutationObserver(
|
|
329
|
-
this._mutationObserver = (0, Utils_js_1.safeMutationObserver)(
|
|
333
|
+
this._safeMutationObserver(obs => obs.disconnect());
|
|
334
|
+
this._mutationObserver = (0, Utils_js_1.safeMutationObserver)(records => {
|
|
330
335
|
for (const record of records) {
|
|
331
336
|
if (record.type === "attributes" && record.attributeName === "style") {
|
|
332
337
|
this._repairStyle();
|
|
@@ -343,8 +348,8 @@ class Canvas {
|
|
|
343
348
|
(0, Utils_js_1.getLogger)().error(e);
|
|
344
349
|
}
|
|
345
350
|
this.initBackground();
|
|
346
|
-
this._safeMutationObserver(
|
|
347
|
-
if (!this.element) {
|
|
351
|
+
this._safeMutationObserver(obs => {
|
|
352
|
+
if (!this.element || !(this.element instanceof Node)) {
|
|
348
353
|
return;
|
|
349
354
|
}
|
|
350
355
|
obs.observe(this.element, { attributes: true });
|
|
@@ -411,8 +416,8 @@ class Canvas {
|
|
|
411
416
|
this.size.height = canvas.offsetHeight;
|
|
412
417
|
this.size.width = canvas.offsetWidth;
|
|
413
418
|
this._context = this.element.getContext("2d");
|
|
414
|
-
this._safeMutationObserver(
|
|
415
|
-
if (!this.element) {
|
|
419
|
+
this._safeMutationObserver(obs => {
|
|
420
|
+
if (!this.element || !(this.element instanceof Node)) {
|
|
416
421
|
return;
|
|
417
422
|
}
|
|
418
423
|
obs.observe(this.element, { attributes: true });
|
|
@@ -422,7 +427,7 @@ class Canvas {
|
|
|
422
427
|
}
|
|
423
428
|
paint() {
|
|
424
429
|
const options = this.container.actualOptions;
|
|
425
|
-
this.draw(
|
|
430
|
+
this.draw(ctx => {
|
|
426
431
|
if (options.backgroundMask.enable && options.backgroundMask.cover) {
|
|
427
432
|
(0, CanvasUtils_js_1.clear)(ctx, this.size);
|
|
428
433
|
if (this._coverImage) {
|
|
@@ -466,9 +471,9 @@ class Canvas {
|
|
|
466
471
|
return true;
|
|
467
472
|
}
|
|
468
473
|
stop() {
|
|
469
|
-
this._safeMutationObserver(
|
|
474
|
+
this._safeMutationObserver(obs => obs.disconnect());
|
|
470
475
|
this._mutationObserver = undefined;
|
|
471
|
-
this.draw(
|
|
476
|
+
this.draw(ctx => (0, CanvasUtils_js_1.clear)(ctx, this.size));
|
|
472
477
|
}
|
|
473
478
|
async windowResize() {
|
|
474
479
|
if (!this.element || !this.resize()) {
|
package/cjs/Core/Container.js
CHANGED
|
@@ -5,6 +5,7 @@ const Constants_js_1 = require("./Utils/Constants.js");
|
|
|
5
5
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
6
6
|
const Canvas_js_1 = require("./Canvas.js");
|
|
7
7
|
const EventListeners_js_1 = require("./Utils/EventListeners.js");
|
|
8
|
+
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
8
9
|
const Options_js_1 = require("../Options/Classes/Options.js");
|
|
9
10
|
const Particles_js_1 = require("./Particles.js");
|
|
10
11
|
const Retina_js_1 = require("./Retina.js");
|
|
@@ -27,7 +28,7 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
|
27
28
|
}
|
|
28
29
|
class Container {
|
|
29
30
|
constructor(engine, id, sourceOptions) {
|
|
30
|
-
this._intersectionManager =
|
|
31
|
+
this._intersectionManager = entries => {
|
|
31
32
|
if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
@@ -86,6 +87,7 @@ class Container {
|
|
|
86
87
|
this._lastFrameTime = 0;
|
|
87
88
|
this.zLayers = 100;
|
|
88
89
|
this.pageHidden = false;
|
|
90
|
+
this._clickHandlers = new Map();
|
|
89
91
|
this._sourceOptions = sourceOptions;
|
|
90
92
|
this._initialSourceOptions = sourceOptions;
|
|
91
93
|
this.retina = new Retina_js_1.Retina(this);
|
|
@@ -104,8 +106,8 @@ class Container {
|
|
|
104
106
|
this._options = loadContainerOptions(this._engine, this);
|
|
105
107
|
this.actualOptions = loadContainerOptions(this._engine, this);
|
|
106
108
|
this._eventListeners = new EventListeners_js_1.EventListeners(this);
|
|
107
|
-
this._intersectionObserver = (0, Utils_js_1.safeIntersectionObserver)(
|
|
108
|
-
this._engine.dispatchEvent(
|
|
109
|
+
this._intersectionObserver = (0, Utils_js_1.safeIntersectionObserver)(entries => this._intersectionManager(entries));
|
|
110
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerBuilt, { container: this });
|
|
109
111
|
}
|
|
110
112
|
get animationStatus() {
|
|
111
113
|
return !this._paused && !this.pageHidden && guardCheck(this);
|
|
@@ -133,8 +135,7 @@ class Container {
|
|
|
133
135
|
y: pos.y * pxRatio,
|
|
134
136
|
}, particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
|
|
135
137
|
callback(e, particles);
|
|
136
|
-
}
|
|
137
|
-
const clickHandler = (e) => {
|
|
138
|
+
}, clickHandler = (e) => {
|
|
138
139
|
if (!guardCheck(this)) {
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
@@ -143,27 +144,23 @@ class Container {
|
|
|
143
144
|
y: mouseEvent.offsetY || mouseEvent.clientY,
|
|
144
145
|
}, radius = 1;
|
|
145
146
|
clickOrTouchHandler(e, pos, radius);
|
|
146
|
-
}
|
|
147
|
-
const touchStartHandler = () => {
|
|
147
|
+
}, touchStartHandler = () => {
|
|
148
148
|
if (!guardCheck(this)) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
touched = true;
|
|
152
152
|
touchMoved = false;
|
|
153
|
-
}
|
|
154
|
-
const touchMoveHandler = () => {
|
|
153
|
+
}, touchMoveHandler = () => {
|
|
155
154
|
if (!guardCheck(this)) {
|
|
156
155
|
return;
|
|
157
156
|
}
|
|
158
157
|
touchMoved = true;
|
|
159
|
-
}
|
|
160
|
-
const touchEndHandler = (e) => {
|
|
158
|
+
}, touchEndHandler = (e) => {
|
|
161
159
|
if (!guardCheck(this)) {
|
|
162
160
|
return;
|
|
163
161
|
}
|
|
164
162
|
if (touched && !touchMoved) {
|
|
165
|
-
const touchEvent = e;
|
|
166
|
-
const lengthOffset = 1;
|
|
163
|
+
const touchEvent = e, lengthOffset = 1;
|
|
167
164
|
let lastTouch = touchEvent.touches[touchEvent.touches.length - lengthOffset];
|
|
168
165
|
if (!lastTouch) {
|
|
169
166
|
lastTouch = touchEvent.changedTouches[touchEvent.changedTouches.length - lengthOffset];
|
|
@@ -179,8 +176,7 @@ class Container {
|
|
|
179
176
|
}
|
|
180
177
|
touched = false;
|
|
181
178
|
touchMoved = false;
|
|
182
|
-
}
|
|
183
|
-
const touchCancelHandler = () => {
|
|
179
|
+
}, touchCancelHandler = () => {
|
|
184
180
|
if (!guardCheck(this)) {
|
|
185
181
|
return;
|
|
186
182
|
}
|
|
@@ -188,11 +184,14 @@ class Container {
|
|
|
188
184
|
touchMoved = false;
|
|
189
185
|
};
|
|
190
186
|
let touched = false, touchMoved = false;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
187
|
+
this._clickHandlers.set("click", clickHandler);
|
|
188
|
+
this._clickHandlers.set("touchstart", touchStartHandler);
|
|
189
|
+
this._clickHandlers.set("touchmove", touchMoveHandler);
|
|
190
|
+
this._clickHandlers.set("touchend", touchEndHandler);
|
|
191
|
+
this._clickHandlers.set("touchcancel", touchCancelHandler);
|
|
192
|
+
for (const [key, handler] of this._clickHandlers) {
|
|
193
|
+
el.addEventListener(key, handler);
|
|
194
|
+
}
|
|
196
195
|
}
|
|
197
196
|
addLifeTime(value) {
|
|
198
197
|
this._lifeTime += value;
|
|
@@ -207,11 +206,21 @@ class Container {
|
|
|
207
206
|
alive() {
|
|
208
207
|
return !this._duration || this._lifeTime <= this._duration;
|
|
209
208
|
}
|
|
210
|
-
|
|
209
|
+
clearClickHandlers() {
|
|
210
|
+
if (!guardCheck(this)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
for (const [key, handler] of this._clickHandlers) {
|
|
214
|
+
this.interactivity.element?.removeEventListener(key, handler);
|
|
215
|
+
}
|
|
216
|
+
this._clickHandlers.clear();
|
|
217
|
+
}
|
|
218
|
+
destroy(remove = true) {
|
|
211
219
|
if (!guardCheck(this)) {
|
|
212
220
|
return;
|
|
213
221
|
}
|
|
214
222
|
this.stop();
|
|
223
|
+
this.clearClickHandlers();
|
|
215
224
|
this.particles.destroy();
|
|
216
225
|
this.canvas.destroy();
|
|
217
226
|
for (const [, effectDrawer] of this.effectDrawers) {
|
|
@@ -228,12 +237,14 @@ class Container {
|
|
|
228
237
|
}
|
|
229
238
|
this._engine.clearPlugins(this);
|
|
230
239
|
this.destroyed = true;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
240
|
+
if (remove) {
|
|
241
|
+
const mainArr = this._engine.items, idx = mainArr.findIndex(t => t === this), minIndex = 0;
|
|
242
|
+
if (idx >= minIndex) {
|
|
243
|
+
const deleteCount = 1;
|
|
244
|
+
mainArr.splice(idx, deleteCount);
|
|
245
|
+
}
|
|
235
246
|
}
|
|
236
|
-
this._engine.dispatchEvent(
|
|
247
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerDestroyed, { container: this });
|
|
237
248
|
}
|
|
238
249
|
draw(force) {
|
|
239
250
|
if (!guardCheck(this)) {
|
|
@@ -247,7 +258,7 @@ class Container {
|
|
|
247
258
|
}
|
|
248
259
|
this._nextFrame(timestamp);
|
|
249
260
|
};
|
|
250
|
-
this._drawAnimationFrame = requestAnimationFrame(
|
|
261
|
+
this._drawAnimationFrame = requestAnimationFrame(timestamp => frame(timestamp));
|
|
251
262
|
}
|
|
252
263
|
async export(type, options = {}) {
|
|
253
264
|
for (const [, plugin] of this.plugins) {
|
|
@@ -301,13 +312,14 @@ class Container {
|
|
|
301
312
|
this.updateActualOptions();
|
|
302
313
|
this.canvas.initBackground();
|
|
303
314
|
this.canvas.resize();
|
|
304
|
-
|
|
305
|
-
this.
|
|
306
|
-
this.
|
|
315
|
+
const { zLayers, duration, delay, fpsLimit, smooth } = this.actualOptions;
|
|
316
|
+
this.zLayers = zLayers;
|
|
317
|
+
this._duration = (0, NumberUtils_js_1.getRangeValue)(duration) * Constants_js_1.millisecondsToSeconds;
|
|
318
|
+
this._delay = (0, NumberUtils_js_1.getRangeValue)(delay) * Constants_js_1.millisecondsToSeconds;
|
|
307
319
|
this._lifeTime = 0;
|
|
308
320
|
const defaultFpsLimit = 120, minFpsLimit = 0;
|
|
309
|
-
this.fpsLimit =
|
|
310
|
-
this._smooth =
|
|
321
|
+
this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
|
|
322
|
+
this._smooth = smooth;
|
|
311
323
|
for (const [, drawer] of this.effectDrawers) {
|
|
312
324
|
await drawer.init?.(this);
|
|
313
325
|
}
|
|
@@ -317,13 +329,13 @@ class Container {
|
|
|
317
329
|
for (const [, plugin] of this.plugins) {
|
|
318
330
|
await plugin.init?.();
|
|
319
331
|
}
|
|
320
|
-
this._engine.dispatchEvent(
|
|
332
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerInit, { container: this });
|
|
321
333
|
await this.particles.init();
|
|
322
334
|
this.particles.setDensity();
|
|
323
335
|
for (const [, plugin] of this.plugins) {
|
|
324
336
|
plugin.particlesSetup?.();
|
|
325
337
|
}
|
|
326
|
-
this._engine.dispatchEvent(
|
|
338
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.particlesSetup, { container: this });
|
|
327
339
|
}
|
|
328
340
|
async loadTheme(name) {
|
|
329
341
|
if (!guardCheck(this)) {
|
|
@@ -349,7 +361,7 @@ class Container {
|
|
|
349
361
|
if (!this.pageHidden) {
|
|
350
362
|
this._paused = true;
|
|
351
363
|
}
|
|
352
|
-
this._engine.dispatchEvent(
|
|
364
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerPaused, { container: this });
|
|
353
365
|
}
|
|
354
366
|
play(force) {
|
|
355
367
|
if (!guardCheck(this)) {
|
|
@@ -370,7 +382,7 @@ class Container {
|
|
|
370
382
|
}
|
|
371
383
|
}
|
|
372
384
|
}
|
|
373
|
-
this._engine.dispatchEvent(
|
|
385
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerPlay, { container: this });
|
|
374
386
|
this.draw(needsUpdate ?? false);
|
|
375
387
|
}
|
|
376
388
|
async refresh() {
|
|
@@ -380,12 +392,13 @@ class Container {
|
|
|
380
392
|
this.stop();
|
|
381
393
|
return this.start();
|
|
382
394
|
}
|
|
383
|
-
async reset() {
|
|
395
|
+
async reset(sourceOptions) {
|
|
384
396
|
if (!guardCheck(this)) {
|
|
385
397
|
return;
|
|
386
398
|
}
|
|
387
|
-
this._initialSourceOptions =
|
|
388
|
-
this.
|
|
399
|
+
this._initialSourceOptions = sourceOptions;
|
|
400
|
+
this._sourceOptions = sourceOptions;
|
|
401
|
+
this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
|
|
389
402
|
this.actualOptions = loadContainerOptions(this._engine, this, this._options);
|
|
390
403
|
return this.refresh();
|
|
391
404
|
}
|
|
@@ -395,7 +408,7 @@ class Container {
|
|
|
395
408
|
}
|
|
396
409
|
await this.init();
|
|
397
410
|
this.started = true;
|
|
398
|
-
await new Promise(
|
|
411
|
+
await new Promise(resolve => {
|
|
399
412
|
const start = async () => {
|
|
400
413
|
this._eventListeners.addListeners();
|
|
401
414
|
if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
|
|
@@ -404,7 +417,7 @@ class Container {
|
|
|
404
417
|
for (const [, plugin] of this.plugins) {
|
|
405
418
|
await plugin.start?.();
|
|
406
419
|
}
|
|
407
|
-
this._engine.dispatchEvent(
|
|
420
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerStarted, { container: this });
|
|
408
421
|
this.play();
|
|
409
422
|
resolve();
|
|
410
423
|
};
|
|
@@ -435,7 +448,7 @@ class Container {
|
|
|
435
448
|
this.plugins.delete(key);
|
|
436
449
|
}
|
|
437
450
|
this._sourceOptions = this._options;
|
|
438
|
-
this._engine.dispatchEvent(
|
|
451
|
+
this._engine.dispatchEvent(EventType_js_1.EventType.containerStopped, { container: this });
|
|
439
452
|
}
|
|
440
453
|
updateActualOptions() {
|
|
441
454
|
this.actualOptions.responsive = [];
|