@tsparticles/engine 4.0.0-alpha.3 → 4.0.0-alpha.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/794.min.js +2 -0
- package/794.min.js.LICENSE.txt +1 -0
- package/README.md +2 -5
- package/browser/Core/Canvas.js +3 -3
- package/browser/Core/Container.js +35 -155
- package/browser/Core/Engine.js +10 -51
- package/browser/Core/Particle.js +5 -10
- package/browser/Core/Particles.js +36 -25
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +5 -250
- package/browser/Options/Classes/Options.js +7 -75
- package/browser/Options/Classes/Particles/ParticlesOptions.js +5 -11
- package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +1 -1
- package/browser/Utils/ColorUtils.js +7 -5
- package/browser/Utils/Utils.js +25 -32
- package/browser/exports.js +1 -21
- package/cjs/Core/Canvas.js +3 -3
- package/cjs/Core/Container.js +35 -155
- package/cjs/Core/Engine.js +10 -51
- package/cjs/Core/Particle.js +5 -10
- package/cjs/Core/Particles.js +36 -25
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +5 -250
- package/cjs/Options/Classes/Options.js +7 -75
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +5 -11
- package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +1 -1
- package/cjs/Utils/ColorUtils.js +7 -5
- package/cjs/Utils/Utils.js +25 -32
- package/cjs/exports.js +1 -21
- package/dist_browser_Core_Container_js.js +6 -16
- package/esm/Core/Canvas.js +3 -3
- package/esm/Core/Container.js +35 -155
- package/esm/Core/Engine.js +10 -51
- package/esm/Core/Particle.js +5 -10
- package/esm/Core/Particles.js +36 -25
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +5 -250
- package/esm/Options/Classes/Options.js +7 -75
- package/esm/Options/Classes/Particles/ParticlesOptions.js +5 -11
- package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +1 -1
- package/esm/Utils/ColorUtils.js +7 -5
- package/esm/Utils/Utils.js +25 -32
- package/esm/exports.js +1 -21
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +14 -206
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Container.d.ts +3 -15
- package/types/Core/Engine.d.ts +3 -18
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -1
- package/types/Core/Interfaces/IPlugin.d.ts +5 -1
- package/types/Core/Particle.d.ts +0 -2
- package/types/Core/Particles.d.ts +1 -5
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +0 -14
- package/types/Options/Classes/Options.d.ts +2 -11
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -2
- package/types/Options/Classes/ResizeEvent.d.ts +9 -0
- package/types/Options/Interfaces/IOptions.d.ts +2 -8
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
- package/types/Types/EngineInitializers.d.ts +10 -0
- package/types/Utils/Utils.d.ts +4 -6
- package/types/export-types.d.ts +3 -19
- package/types/exports.d.ts +1 -21
- package/umd/Core/Canvas.js +3 -3
- package/umd/Core/Container.js +35 -155
- package/umd/Core/Engine.js +11 -52
- package/umd/Core/Particle.js +6 -11
- package/umd/Core/Particles.js +37 -26
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +7 -252
- package/umd/Options/Classes/Options.js +7 -75
- package/umd/Options/Classes/Particles/ParticlesOptions.js +5 -11
- package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +2 -2
- package/umd/Utils/ColorUtils.js +7 -5
- package/umd/Utils/Utils.js +26 -35
- package/umd/exports.js +2 -22
- package/638.min.js +0 -2
- package/638.min.js.LICENSE.txt +0 -1
- package/browser/Core/Interfaces/IMouseData.js +0 -1
- package/browser/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/browser/Core/Utils/ExternalInteractorBase.js +0 -7
- package/browser/Core/Utils/InteractionManager.js +0 -60
- package/browser/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/browser/Enums/InteractivityDetect.js +0 -6
- package/browser/Enums/Modes/ResponsiveMode.js +0 -5
- package/browser/Enums/Modes/ThemeMode.js +0 -6
- package/browser/Enums/Types/DivType.js +0 -5
- package/browser/Enums/Types/InteractorType.js +0 -5
- package/browser/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/browser/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/browser/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/browser/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/browser/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/browser/Options/Classes/ManualParticle.js +0 -21
- package/browser/Options/Classes/Responsive.js +0 -29
- package/browser/Options/Classes/Theme/Theme.js +0 -21
- package/browser/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/browser/Options/Interfaces/IManualParticle.js +0 -1
- package/browser/Options/Interfaces/IResponsive.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/browser/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/browser/Options/Interfaces/Theme/ITheme.js +0 -1
- package/browser/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/cjs/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/cjs/Core/Interfaces/IExternalInteractor.js +0 -1
- package/cjs/Core/Interfaces/IInteractor.js +0 -1
- package/cjs/Core/Interfaces/IMouseData.js +0 -1
- package/cjs/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/cjs/Core/Utils/ExternalInteractorBase.js +0 -7
- package/cjs/Core/Utils/InteractionManager.js +0 -60
- package/cjs/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/cjs/Enums/InteractivityDetect.js +0 -6
- package/cjs/Enums/Modes/ResponsiveMode.js +0 -5
- package/cjs/Enums/Modes/ThemeMode.js +0 -6
- package/cjs/Enums/Types/DivType.js +0 -5
- package/cjs/Enums/Types/InteractorType.js +0 -5
- package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/cjs/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/cjs/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/cjs/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/cjs/Options/Classes/ManualParticle.js +0 -21
- package/cjs/Options/Classes/Responsive.js +0 -29
- package/cjs/Options/Classes/Theme/Theme.js +0 -21
- package/cjs/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/cjs/Options/Interfaces/IManualParticle.js +0 -1
- package/cjs/Options/Interfaces/IResponsive.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/cjs/Options/Interfaces/Theme/ITheme.js +0 -1
- package/cjs/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/esm/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/esm/Core/Interfaces/IExternalInteractor.js +0 -1
- package/esm/Core/Interfaces/IInteractor.js +0 -1
- package/esm/Core/Interfaces/IMouseData.js +0 -1
- package/esm/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/esm/Core/Utils/ExternalInteractorBase.js +0 -7
- package/esm/Core/Utils/InteractionManager.js +0 -60
- package/esm/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/esm/Enums/InteractivityDetect.js +0 -6
- package/esm/Enums/Modes/ResponsiveMode.js +0 -5
- package/esm/Enums/Modes/ThemeMode.js +0 -6
- package/esm/Enums/Types/DivType.js +0 -5
- package/esm/Enums/Types/InteractorType.js +0 -5
- package/esm/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/esm/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/esm/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/esm/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/esm/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/esm/Options/Classes/ManualParticle.js +0 -21
- package/esm/Options/Classes/Responsive.js +0 -29
- package/esm/Options/Classes/Theme/Theme.js +0 -21
- package/esm/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/esm/Options/Interfaces/IManualParticle.js +0 -1
- package/esm/Options/Interfaces/IResponsive.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/esm/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/esm/Options/Interfaces/Theme/ITheme.js +0 -1
- package/esm/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/types/Core/Interfaces/IContainerInteractivity.d.ts +0 -6
- package/types/Core/Interfaces/IExternalInteractor.d.ts +0 -12
- package/types/Core/Interfaces/IInteractor.d.ts +0 -16
- package/types/Core/Interfaces/IMouseData.d.ts +0 -9
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +0 -7
- package/types/Core/Utils/ExternalInteractorBase.d.ts +0 -15
- package/types/Core/Utils/InteractionManager.d.ts +0 -17
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +0 -15
- package/types/Enums/InteractivityDetect.d.ts +0 -5
- package/types/Enums/Modes/ResponsiveMode.d.ts +0 -4
- package/types/Enums/Modes/ThemeMode.d.ts +0 -5
- package/types/Enums/Types/DivType.d.ts +0 -4
- package/types/Enums/Types/InteractorType.d.ts +0 -4
- package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -13
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +0 -12
- package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +0 -9
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +0 -12
- package/types/Options/Classes/ManualParticle.d.ts +0 -10
- package/types/Options/Classes/Responsive.d.ts +0 -12
- package/types/Options/Classes/Theme/Theme.d.ts +0 -12
- package/types/Options/Classes/Theme/ThemeDefault.d.ts +0 -11
- package/types/Options/Interfaces/IManualParticle.d.ts +0 -7
- package/types/Options/Interfaces/IResponsive.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -8
- package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -11
- package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IParallax.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -9
- package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -4
- package/types/Options/Interfaces/Interactivity/Modes/IModes.d.ts +0 -1
- package/types/Options/Interfaces/Theme/ITheme.d.ts +0 -7
- package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +0 -6
- package/umd/Core/Interfaces/IExternalInteractor.js +0 -12
- package/umd/Core/Interfaces/IInteractor.js +0 -12
- package/umd/Core/Interfaces/IMouseData.js +0 -12
- package/umd/Core/Interfaces/IParticlesInteractor.js +0 -12
- package/umd/Core/Utils/ExternalInteractorBase.js +0 -21
- package/umd/Core/Utils/InteractionManager.js +0 -74
- package/umd/Core/Utils/ParticlesInteractorBase.js +0 -21
- package/umd/Enums/InteractivityDetect.js +0 -19
- package/umd/Enums/Modes/ResponsiveMode.js +0 -18
- package/umd/Enums/Modes/ThemeMode.js +0 -19
- package/umd/Enums/Types/DivType.js +0 -18
- package/umd/Enums/Types/InteractorType.js +0 -18
- package/umd/Options/Classes/Interactivity/Events/ClickEvent.js +0 -32
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +0 -41
- package/umd/Options/Classes/Interactivity/Events/Events.js +0 -44
- package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +0 -35
- package/umd/Options/Classes/Interactivity/Events/Parallax.js +0 -36
- package/umd/Options/Classes/Interactivity/Interactivity.js +0 -36
- package/umd/Options/Classes/Interactivity/Modes/Modes.js +0 -39
- package/umd/Options/Classes/ManualParticle.js +0 -35
- package/umd/Options/Classes/Responsive.js +0 -43
- package/umd/Options/Classes/Theme/Theme.js +0 -35
- package/umd/Options/Classes/Theme/ThemeDefault.js +0 -37
- package/umd/Options/Interfaces/IManualParticle.js +0 -12
- package/umd/Options/Interfaces/IResponsive.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IEvents.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IParallax.js +0 -12
- package/umd/Options/Interfaces/Interactivity/IInteractivity.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModes.js +0 -12
- package/umd/Options/Interfaces/Theme/ITheme.js +0 -12
- package/umd/Options/Interfaces/Theme/IThemeDefault.js +0 -12
- /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/browser/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
- /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Core/Interfaces/IExternalInteractor.js → cjs/Types/EngineInitializers.js} +0 -0
- /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Core/Interfaces/IInteractor.js → esm/Types/EngineInitializers.js} +0 -0
- /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
- /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/umd/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
|
@@ -4,65 +4,19 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "../../Utils/Utils.js", "./Constants.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EventListeners = void 0;
|
|
13
|
-
const Constants_js_1 = require("./Constants.js");
|
|
14
13
|
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
15
|
-
const
|
|
16
|
-
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
17
|
-
function manageListener(element, event, handler, add, options) {
|
|
18
|
-
if (add) {
|
|
19
|
-
let addOptions = { passive: true };
|
|
20
|
-
if ((0, TypeUtils_js_1.isBoolean)(options)) {
|
|
21
|
-
addOptions.capture = options;
|
|
22
|
-
}
|
|
23
|
-
else if (options !== undefined) {
|
|
24
|
-
addOptions = options;
|
|
25
|
-
}
|
|
26
|
-
element.addEventListener(event, handler, addOptions);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const removeOptions = options;
|
|
30
|
-
element.removeEventListener(event, handler, removeOptions);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
14
|
+
const Constants_js_1 = require("./Constants.js");
|
|
33
15
|
class EventListeners {
|
|
34
16
|
constructor(container) {
|
|
35
17
|
this.container = container;
|
|
36
|
-
this._canPush = true;
|
|
37
|
-
this._doMouseTouchClick = e => {
|
|
38
|
-
const container = this.container, options = container.actualOptions;
|
|
39
|
-
if (this._canPush) {
|
|
40
|
-
const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
|
|
41
|
-
if (!mousePos) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
mouseInteractivity.clickPosition = { ...mousePos };
|
|
45
|
-
mouseInteractivity.clickTime = Date.now();
|
|
46
|
-
const onClick = options.interactivity.events.onClick;
|
|
47
|
-
(0, Utils_js_1.executeOnSingleOrMultiple)(onClick.mode, mode => {
|
|
48
|
-
this.container.handleClickMode(mode);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (e.type === "touchend") {
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
this._mouseTouchFinish();
|
|
54
|
-
}, Constants_js_1.touchDelay);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this._handleThemeChange = (e) => {
|
|
58
|
-
const mediaEvent = e, container = this.container, options = container.options, defaultThemes = options.defaultThemes, themeName = mediaEvent.matches ? defaultThemes.dark : defaultThemes.light, theme = options.themes.find(theme => theme.name === themeName);
|
|
59
|
-
if (theme?.default.auto) {
|
|
60
|
-
void container.loadTheme(themeName);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
18
|
this._handleVisibilityChange = () => {
|
|
64
19
|
const container = this.container, options = container.actualOptions;
|
|
65
|
-
this._mouseTouchFinish();
|
|
66
20
|
if (!options.pauseOnBlur) {
|
|
67
21
|
return;
|
|
68
22
|
}
|
|
@@ -89,64 +43,20 @@
|
|
|
89
43
|
const canvas = this.container.canvas;
|
|
90
44
|
await canvas.windowResize();
|
|
91
45
|
};
|
|
92
|
-
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.
|
|
93
|
-
};
|
|
94
|
-
this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
|
|
95
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions, interactivityEl = container.interactivity.element;
|
|
96
|
-
if (!interactivityEl) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const html = interactivityEl, canvas = container.canvas;
|
|
100
|
-
canvas.setPointerEvents(html === canvas.element ? "initial" : "none");
|
|
101
|
-
if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
manageListener(interactivityEl, Constants_js_1.mouseMoveEvent, handlers.mouseMove, add);
|
|
105
|
-
manageListener(interactivityEl, Constants_js_1.touchStartEvent, handlers.touchStart, add);
|
|
106
|
-
manageListener(interactivityEl, Constants_js_1.touchMoveEvent, handlers.touchMove, add);
|
|
107
|
-
if (options.interactivity.events.onClick.enable) {
|
|
108
|
-
manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEndClick, add);
|
|
109
|
-
manageListener(interactivityEl, Constants_js_1.mouseUpEvent, handlers.mouseUp, add);
|
|
110
|
-
manageListener(interactivityEl, Constants_js_1.mouseDownEvent, handlers.mouseDown, add);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEnd, add);
|
|
114
|
-
}
|
|
115
|
-
manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
|
|
116
|
-
manageListener(interactivityEl, Constants_js_1.touchCancelEvent, handlers.touchCancel, add);
|
|
46
|
+
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * Constants_js_1.millisecondsToSeconds);
|
|
117
47
|
};
|
|
118
48
|
this._manageListeners = add => {
|
|
119
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
|
|
120
|
-
let mouseLeaveTmpEvent = Constants_js_1.mouseLeaveEvent;
|
|
121
|
-
if (detectType === InteractivityDetect_js_1.InteractivityDetect.window) {
|
|
122
|
-
container.interactivity.element = window;
|
|
123
|
-
mouseLeaveTmpEvent = Constants_js_1.mouseOutEvent;
|
|
124
|
-
}
|
|
125
|
-
else if (detectType === InteractivityDetect_js_1.InteractivityDetect.parent && canvasEl) {
|
|
126
|
-
container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
container.interactivity.element = canvasEl;
|
|
130
|
-
}
|
|
131
|
-
this._manageMediaMatch(add);
|
|
132
|
-
this._manageResize(add);
|
|
133
|
-
this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
|
|
134
|
-
manageListener(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
135
|
-
};
|
|
136
|
-
this._manageMediaMatch = add => {
|
|
137
49
|
const handlers = this._handlers;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
manageListener(this._matchMedia, "change", handlers.themeChange, add);
|
|
50
|
+
this._manageResize(add);
|
|
51
|
+
(0, Utils_js_1.manageListener)(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
142
52
|
};
|
|
143
53
|
this._manageResize = add => {
|
|
144
54
|
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
145
|
-
if (!options.
|
|
55
|
+
if (!options.resize.enable) {
|
|
146
56
|
return;
|
|
147
57
|
}
|
|
148
58
|
if (typeof ResizeObserver === "undefined") {
|
|
149
|
-
manageListener(globalThis, Constants_js_1.resizeEvent, handlers.resize, add);
|
|
59
|
+
(0, Utils_js_1.manageListener)(globalThis, Constants_js_1.resizeEvent, handlers.resize, add);
|
|
150
60
|
return;
|
|
151
61
|
}
|
|
152
62
|
const canvasEl = container.canvas.element;
|
|
@@ -168,165 +78,10 @@
|
|
|
168
78
|
this._resizeObserver.observe(canvasEl);
|
|
169
79
|
}
|
|
170
80
|
};
|
|
171
|
-
this._mouseDown = () => {
|
|
172
|
-
const { interactivity } = this.container, { mouse } = interactivity;
|
|
173
|
-
mouse.clicking = true;
|
|
174
|
-
mouse.downPosition = mouse.position;
|
|
175
|
-
};
|
|
176
|
-
this._mouseTouchClick = e => {
|
|
177
|
-
const container = this.container, options = container.actualOptions, { mouse } = container.interactivity;
|
|
178
|
-
mouse.inside = true;
|
|
179
|
-
let handled = false;
|
|
180
|
-
const mousePosition = mouse.position;
|
|
181
|
-
if (!mousePosition || !options.interactivity.events.onClick.enable) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
for (const plugin of container.plugins.values()) {
|
|
185
|
-
if (!plugin.clickPositionValid) {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
handled = plugin.clickPositionValid(mousePosition);
|
|
189
|
-
if (handled) {
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (!handled) {
|
|
194
|
-
this._doMouseTouchClick(e);
|
|
195
|
-
}
|
|
196
|
-
mouse.clicking = false;
|
|
197
|
-
};
|
|
198
|
-
this._mouseTouchFinish = () => {
|
|
199
|
-
const { interactivity } = this.container, { mouse } = interactivity;
|
|
200
|
-
delete mouse.position;
|
|
201
|
-
delete mouse.clickPosition;
|
|
202
|
-
delete mouse.downPosition;
|
|
203
|
-
interactivity.status = Constants_js_1.mouseLeaveEvent;
|
|
204
|
-
mouse.inside = false;
|
|
205
|
-
mouse.clicking = false;
|
|
206
|
-
};
|
|
207
|
-
this._mouseTouchMove = e => {
|
|
208
|
-
const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
|
|
209
|
-
if (!interactivity.element) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
interactivity.mouse.inside = true;
|
|
213
|
-
let pos;
|
|
214
|
-
if (e.type.startsWith("pointer")) {
|
|
215
|
-
this._canPush = true;
|
|
216
|
-
const mouseEvent = e;
|
|
217
|
-
if (interactivity.element === window) {
|
|
218
|
-
if (canvasEl) {
|
|
219
|
-
const clientRect = canvasEl.getBoundingClientRect();
|
|
220
|
-
pos = {
|
|
221
|
-
x: mouseEvent.clientX - clientRect.left,
|
|
222
|
-
y: mouseEvent.clientY - clientRect.top,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
else if (options.interactivity.detectsOn === InteractivityDetect_js_1.InteractivityDetect.parent) {
|
|
227
|
-
const source = mouseEvent.target, target = mouseEvent.currentTarget;
|
|
228
|
-
if (canvasEl) {
|
|
229
|
-
const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
|
|
230
|
-
pos = {
|
|
231
|
-
x: mouseEvent.offsetX + Constants_js_1.double * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
232
|
-
y: mouseEvent.offsetY + Constants_js_1.double * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
pos = {
|
|
237
|
-
x: mouseEvent.offsetX,
|
|
238
|
-
y: mouseEvent.offsetY,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else if (mouseEvent.target === canvasEl) {
|
|
243
|
-
pos = {
|
|
244
|
-
x: mouseEvent.offsetX,
|
|
245
|
-
y: mouseEvent.offsetY,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
this._canPush = e.type !== "touchmove";
|
|
251
|
-
if (canvasEl) {
|
|
252
|
-
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - Constants_js_1.lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
|
|
253
|
-
if (!lastTouch) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
pos = {
|
|
257
|
-
x: lastTouch.clientX - canvasRect.left,
|
|
258
|
-
y: lastTouch.clientY - canvasRect.top,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const pxRatio = container.retina.pixelRatio;
|
|
263
|
-
if (pos) {
|
|
264
|
-
pos.x *= pxRatio;
|
|
265
|
-
pos.y *= pxRatio;
|
|
266
|
-
}
|
|
267
|
-
interactivity.mouse.position = pos;
|
|
268
|
-
interactivity.status = Constants_js_1.mouseMoveEvent;
|
|
269
|
-
};
|
|
270
|
-
this._touchEnd = e => {
|
|
271
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
272
|
-
for (const touch of touches) {
|
|
273
|
-
this._touches.delete(touch.identifier);
|
|
274
|
-
}
|
|
275
|
-
this._mouseTouchFinish();
|
|
276
|
-
};
|
|
277
|
-
this._touchEndClick = e => {
|
|
278
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
279
|
-
for (const touch of touches) {
|
|
280
|
-
this._touches.delete(touch.identifier);
|
|
281
|
-
}
|
|
282
|
-
this._mouseTouchClick(e);
|
|
283
|
-
};
|
|
284
|
-
this._touchStart = e => {
|
|
285
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
286
|
-
for (const touch of touches) {
|
|
287
|
-
this._touches.set(touch.identifier, performance.now());
|
|
288
|
-
}
|
|
289
|
-
this._mouseTouchMove(e);
|
|
290
|
-
};
|
|
291
|
-
this._matchMedia = (0, Utils_js_1.safeMatchMedia)("(prefers-color-scheme: dark)");
|
|
292
|
-
this._touches = new Map();
|
|
293
81
|
this._handlers = {
|
|
294
|
-
mouseDown: () => {
|
|
295
|
-
this._mouseDown();
|
|
296
|
-
},
|
|
297
|
-
mouseLeave: () => {
|
|
298
|
-
this._mouseTouchFinish();
|
|
299
|
-
},
|
|
300
|
-
mouseMove: (e) => {
|
|
301
|
-
this._mouseTouchMove(e);
|
|
302
|
-
},
|
|
303
|
-
mouseUp: (e) => {
|
|
304
|
-
this._mouseTouchClick(e);
|
|
305
|
-
},
|
|
306
|
-
touchStart: (e) => {
|
|
307
|
-
this._touchStart(e);
|
|
308
|
-
},
|
|
309
|
-
touchMove: (e) => {
|
|
310
|
-
this._mouseTouchMove(e);
|
|
311
|
-
},
|
|
312
|
-
touchEnd: (e) => {
|
|
313
|
-
this._touchEnd(e);
|
|
314
|
-
},
|
|
315
|
-
touchCancel: (e) => {
|
|
316
|
-
this._touchEnd(e);
|
|
317
|
-
},
|
|
318
|
-
touchEndClick: (e) => {
|
|
319
|
-
this._touchEndClick(e);
|
|
320
|
-
},
|
|
321
82
|
visibilityChange: () => {
|
|
322
83
|
this._handleVisibilityChange();
|
|
323
84
|
},
|
|
324
|
-
themeChange: (e) => {
|
|
325
|
-
this._handleThemeChange(e);
|
|
326
|
-
},
|
|
327
|
-
oldThemeChange: (e) => {
|
|
328
|
-
this._handleThemeChange(e);
|
|
329
|
-
},
|
|
330
85
|
resize: () => {
|
|
331
86
|
this._handleWindowResize();
|
|
332
87
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Utils/Utils.js", "../../Utils/TypeUtils.js", "./Background/Background.js", "./FullScreen/FullScreen.js", "./
|
|
7
|
+
define(["require", "exports", "../../Utils/Utils.js", "../../Utils/TypeUtils.js", "./Background/Background.js", "./FullScreen/FullScreen.js", "./ResizeEvent.js", "../../Utils/OptionsUtils.js", "../../Utils/MathUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -14,20 +14,11 @@
|
|
|
14
14
|
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
15
15
|
const Background_js_1 = require("./Background/Background.js");
|
|
16
16
|
const FullScreen_js_1 = require("./FullScreen/FullScreen.js");
|
|
17
|
-
const
|
|
18
|
-
const ManualParticle_js_1 = require("./ManualParticle.js");
|
|
19
|
-
const Responsive_js_1 = require("./Responsive.js");
|
|
20
|
-
const ResponsiveMode_js_1 = require("../../Enums/Modes/ResponsiveMode.js");
|
|
21
|
-
const Theme_js_1 = require("./Theme/Theme.js");
|
|
22
|
-
const ThemeMode_js_1 = require("../../Enums/Modes/ThemeMode.js");
|
|
17
|
+
const ResizeEvent_js_1 = require("./ResizeEvent.js");
|
|
23
18
|
const OptionsUtils_js_1 = require("../../Utils/OptionsUtils.js");
|
|
24
19
|
const MathUtils_js_1 = require("../../Utils/MathUtils.js");
|
|
25
20
|
class Options {
|
|
26
21
|
constructor(engine, container) {
|
|
27
|
-
this._findDefaultTheme = mode => {
|
|
28
|
-
return (this.themes.find(theme => theme.default.value && theme.default.mode === mode) ??
|
|
29
|
-
this.themes.find(theme => theme.default.value && theme.default.mode === ThemeMode_js_1.ThemeMode.any));
|
|
30
|
-
};
|
|
31
22
|
this._importPreset = preset => {
|
|
32
23
|
this.load(this._engine.getPreset(preset));
|
|
33
24
|
};
|
|
@@ -43,15 +34,12 @@
|
|
|
43
34
|
this.duration = 0;
|
|
44
35
|
this.fpsLimit = 120;
|
|
45
36
|
this.hdr = true;
|
|
46
|
-
this.interactivity = new Interactivity_js_1.Interactivity(engine, container);
|
|
47
|
-
this.manualParticles = [];
|
|
48
37
|
this.particles = (0, OptionsUtils_js_1.loadParticlesOptions)(this._engine, this._container);
|
|
49
38
|
this.pauseOnBlur = true;
|
|
50
39
|
this.pauseOnOutsideViewport = true;
|
|
51
|
-
this.
|
|
40
|
+
this.resize = new ResizeEvent_js_1.ResizeEvent();
|
|
52
41
|
this.smooth = false;
|
|
53
42
|
this.style = {};
|
|
54
|
-
this.themes = [];
|
|
55
43
|
this.zLayers = 100;
|
|
56
44
|
}
|
|
57
45
|
load(data) {
|
|
@@ -109,71 +97,15 @@
|
|
|
109
97
|
else {
|
|
110
98
|
this.fullScreen.load(fullScreen);
|
|
111
99
|
}
|
|
112
|
-
this.interactivity.load(data.interactivity);
|
|
113
|
-
if (data.manualParticles) {
|
|
114
|
-
this.manualParticles = data.manualParticles.map(t => {
|
|
115
|
-
const tmp = new ManualParticle_js_1.ManualParticle();
|
|
116
|
-
tmp.load(t);
|
|
117
|
-
return tmp;
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
100
|
this.particles.load(data.particles);
|
|
101
|
+
this.resize.load(data.resize);
|
|
121
102
|
this.style = (0, Utils_js_1.deepExtend)(this.style, data.style);
|
|
122
|
-
this._engine.loadOptions(this, data);
|
|
123
103
|
if (data.smooth !== undefined) {
|
|
124
104
|
this.smooth = data.smooth;
|
|
125
105
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (interactor.loadOptions) {
|
|
130
|
-
interactor.loadOptions(this, data);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (data.responsive !== undefined) {
|
|
135
|
-
for (const responsive of data.responsive) {
|
|
136
|
-
const optResponsive = new Responsive_js_1.Responsive();
|
|
137
|
-
optResponsive.load(responsive);
|
|
138
|
-
this.responsive.push(optResponsive);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
this.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
|
|
142
|
-
if (data.themes !== undefined) {
|
|
143
|
-
for (const theme of data.themes) {
|
|
144
|
-
const existingTheme = this.themes.find(t => t.name === theme.name);
|
|
145
|
-
if (existingTheme) {
|
|
146
|
-
existingTheme.load(theme);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const optTheme = new Theme_js_1.Theme();
|
|
150
|
-
optTheme.load(theme);
|
|
151
|
-
this.themes.push(optTheme);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
this.defaultThemes.dark = this._findDefaultTheme(ThemeMode_js_1.ThemeMode.dark)?.name;
|
|
156
|
-
this.defaultThemes.light = this._findDefaultTheme(ThemeMode_js_1.ThemeMode.light)?.name;
|
|
157
|
-
}
|
|
158
|
-
setResponsive(width, pxRatio, defaultOptions) {
|
|
159
|
-
this.load(defaultOptions);
|
|
160
|
-
const responsiveOptions = this.responsive.find(t => t.mode === ResponsiveMode_js_1.ResponsiveMode.screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
|
|
161
|
-
this.load(responsiveOptions?.options);
|
|
162
|
-
return responsiveOptions?.maxWidth;
|
|
163
|
-
}
|
|
164
|
-
setTheme(name) {
|
|
165
|
-
if (name) {
|
|
166
|
-
const chosenTheme = this.themes.find(theme => theme.name === name);
|
|
167
|
-
if (chosenTheme) {
|
|
168
|
-
this.load(chosenTheme.options);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
const mediaMatch = (0, Utils_js_1.safeMatchMedia)("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch?.matches, defaultTheme = this._findDefaultTheme(clientDarkMode ? ThemeMode_js_1.ThemeMode.dark : ThemeMode_js_1.ThemeMode.light);
|
|
173
|
-
if (defaultTheme) {
|
|
174
|
-
this.load(defaultTheme.options);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
106
|
+
this._engine.plugins.forEach(plugin => {
|
|
107
|
+
plugin.loadOptions(this._container, this, data);
|
|
108
|
+
});
|
|
177
109
|
}
|
|
178
110
|
}
|
|
179
111
|
exports.Options = Options;
|
|
@@ -67,9 +67,6 @@
|
|
|
67
67
|
this.shape.load(data.shape);
|
|
68
68
|
this.size.load(data.size);
|
|
69
69
|
this.zIndex.load(data.zIndex);
|
|
70
|
-
if (data.interactivity !== undefined) {
|
|
71
|
-
this.interactivity = (0, Utils_js_1.deepExtend)({}, data.interactivity);
|
|
72
|
-
}
|
|
73
70
|
const strokeToLoad = data.stroke;
|
|
74
71
|
if (strokeToLoad) {
|
|
75
72
|
this.stroke = (0, Utils_js_1.executeOnSingleOrMultiple)(strokeToLoad, t => {
|
|
@@ -79,6 +76,11 @@
|
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
if (this._container) {
|
|
79
|
+
for (const plugin of this._engine.plugins) {
|
|
80
|
+
if (plugin.loadParticlesOptions) {
|
|
81
|
+
plugin.loadParticlesOptions(this._container, this, data);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
82
84
|
const updaters = this._engine.updaters.get(this._container);
|
|
83
85
|
if (updaters) {
|
|
84
86
|
for (const updater of updaters) {
|
|
@@ -87,14 +89,6 @@
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
|
-
const interactors = this._engine.interactors.get(this._container);
|
|
91
|
-
if (interactors) {
|
|
92
|
-
for (const interactor of interactors) {
|
|
93
|
-
if (interactor.loadParticlesOptions) {
|
|
94
|
-
interactor.loadParticlesOptions(this, data);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
92
|
}
|
|
99
93
|
}
|
|
100
94
|
}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "../../Utils/TypeUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ResizeEvent = void 0;
|
|
13
|
-
const TypeUtils_js_1 = require("
|
|
13
|
+
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
14
14
|
class ResizeEvent {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.delay = 0.5;
|
package/umd/Utils/ColorUtils.js
CHANGED
|
@@ -33,14 +33,16 @@
|
|
|
33
33
|
const TypeUtils_js_1 = require("./TypeUtils.js");
|
|
34
34
|
const AnimationStatus_js_1 = require("../Enums/AnimationStatus.js");
|
|
35
35
|
const Utils_js_1 = require("./Utils.js");
|
|
36
|
-
const styleCache = new Map(), maxCacheSize = 1000;
|
|
36
|
+
const styleCache = new Map(), maxCacheSize = 1000, firstIndex = 0, rgbFixedPrecision = 2, hslFixedPrecision = 2;
|
|
37
37
|
function getCachedStyle(key, generator) {
|
|
38
38
|
let cached = styleCache.get(key);
|
|
39
39
|
if (!cached) {
|
|
40
40
|
cached = generator();
|
|
41
|
-
if (styleCache.size
|
|
42
|
-
styleCache.
|
|
41
|
+
if (styleCache.size >= maxCacheSize) {
|
|
42
|
+
const keysToDelete = [...styleCache.keys()].slice(firstIndex, maxCacheSize * Constants_js_1.half);
|
|
43
|
+
keysToDelete.forEach(k => styleCache.delete(k));
|
|
43
44
|
}
|
|
45
|
+
styleCache.set(key, cached);
|
|
44
46
|
}
|
|
45
47
|
return cached;
|
|
46
48
|
}
|
|
@@ -196,7 +198,7 @@
|
|
|
196
198
|
};
|
|
197
199
|
}
|
|
198
200
|
function getStyleFromRgb(color, hdr, opacity) {
|
|
199
|
-
const op = opacity ?? Constants_js_1.defaultOpacity, key = `rgb-${color.r.
|
|
201
|
+
const op = opacity ?? Constants_js_1.defaultOpacity, key = `rgb-${color.r.toFixed(rgbFixedPrecision)}-${color.g.toFixed(rgbFixedPrecision)}-${color.b.toFixed(rgbFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
200
202
|
return getCachedStyle(key, () => (hdr ? getHdrStyleFromRgb(color, opacity) : getSdrStyleFromRgb(color, opacity)));
|
|
201
203
|
}
|
|
202
204
|
function getHdrStyleFromRgb(color, opacity) {
|
|
@@ -206,7 +208,7 @@
|
|
|
206
208
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? Constants_js_1.defaultOpacity).toString()})`;
|
|
207
209
|
}
|
|
208
210
|
function getStyleFromHsl(color, hdr, opacity) {
|
|
209
|
-
const op = opacity ?? Constants_js_1.defaultOpacity, key = `hsl-${color.h.
|
|
211
|
+
const op = opacity ?? Constants_js_1.defaultOpacity, key = `hsl-${color.h.toFixed(hslFixedPrecision)}-${color.s.toFixed(hslFixedPrecision)}-${color.l.toFixed(hslFixedPrecision)}-${hdr ? "hdr" : "sdr"}-${op.toString()}`;
|
|
210
212
|
return getCachedStyle(key, () => (hdr ? getHdrStyleFromHsl(color, opacity) : getSdrStyleFromHsl(color, opacity)));
|
|
211
213
|
}
|
|
212
214
|
function getHdrStyleFromHsl(color, opacity) {
|
package/umd/Utils/Utils.js
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
exports.areBoundsInside = areBoundsInside;
|
|
24
24
|
exports.calculateBounds = calculateBounds;
|
|
25
25
|
exports.deepExtend = deepExtend;
|
|
26
|
-
exports.isDivModeEnabled = isDivModeEnabled;
|
|
27
|
-
exports.divModeExecute = divModeExecute;
|
|
28
|
-
exports.singleDivModeExecute = singleDivModeExecute;
|
|
29
|
-
exports.divMode = divMode;
|
|
30
26
|
exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
|
|
31
27
|
exports.circleBounce = circleBounce;
|
|
32
28
|
exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
|
|
@@ -37,6 +33,8 @@
|
|
|
37
33
|
exports.getSize = getSize;
|
|
38
34
|
exports.updateAnimation = updateAnimation;
|
|
39
35
|
exports.cloneStyle = cloneStyle;
|
|
36
|
+
exports.manageListener = manageListener;
|
|
37
|
+
exports.getItemsFromInitializer = getItemsFromInitializer;
|
|
40
38
|
const MathUtils_js_1 = require("./MathUtils.js");
|
|
41
39
|
const Constants_js_1 = require("../Core/Utils/Constants.js");
|
|
42
40
|
const TypeUtils_js_1 = require("./TypeUtils.js");
|
|
@@ -60,12 +58,6 @@
|
|
|
60
58
|
return result;
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
|
-
function checkSelector(element, selectors) {
|
|
64
|
-
const res = executeOnSingleOrMultiple(selectors, selector => {
|
|
65
|
-
return element.matches(selector);
|
|
66
|
-
});
|
|
67
|
-
return (0, TypeUtils_js_1.isArray)(res) ? res.some(t => t) : res;
|
|
68
|
-
}
|
|
69
61
|
function hasMatchMedia() {
|
|
70
62
|
return typeof matchMedia !== "undefined";
|
|
71
63
|
}
|
|
@@ -162,31 +154,6 @@
|
|
|
162
154
|
}
|
|
163
155
|
return destination;
|
|
164
156
|
}
|
|
165
|
-
function isDivModeEnabled(mode, divs) {
|
|
166
|
-
return !!findItemFromSingleOrMultiple(divs, t => t.enable && isInArray(mode, t.mode));
|
|
167
|
-
}
|
|
168
|
-
function divModeExecute(mode, divs, callback) {
|
|
169
|
-
executeOnSingleOrMultiple(divs, div => {
|
|
170
|
-
const divMode = div.mode, divEnabled = div.enable;
|
|
171
|
-
if (divEnabled && isInArray(mode, divMode)) {
|
|
172
|
-
singleDivModeExecute(div, callback);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function singleDivModeExecute(div, callback) {
|
|
177
|
-
const selectors = div.selectors;
|
|
178
|
-
executeOnSingleOrMultiple(selectors, selector => {
|
|
179
|
-
callback(selector, div);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
function divMode(divs, element) {
|
|
183
|
-
if (!element || !divs) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
return findItemFromSingleOrMultiple(divs, div => {
|
|
187
|
-
return checkSelector(element, div.selectors);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
157
|
function circleBounceDataFromParticle(p) {
|
|
191
158
|
return {
|
|
192
159
|
position: p.getPosition(),
|
|
@@ -407,4 +374,28 @@
|
|
|
407
374
|
return fullScreenStyle;
|
|
408
375
|
}
|
|
409
376
|
exports.getFullScreenStyle = memoize(computeFullScreenStyle);
|
|
377
|
+
function manageListener(element, event, handler, add, options) {
|
|
378
|
+
if (add) {
|
|
379
|
+
let addOptions = { passive: true };
|
|
380
|
+
if ((0, TypeUtils_js_1.isBoolean)(options)) {
|
|
381
|
+
addOptions.capture = options;
|
|
382
|
+
}
|
|
383
|
+
else if (options !== undefined) {
|
|
384
|
+
addOptions = options;
|
|
385
|
+
}
|
|
386
|
+
element.addEventListener(event, handler, addOptions);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const removeOptions = options;
|
|
390
|
+
element.removeEventListener(event, handler, removeOptions);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async function getItemsFromInitializer(container, map, initializers, force = false) {
|
|
394
|
+
let res = map.get(container);
|
|
395
|
+
if (!res || force) {
|
|
396
|
+
res = await Promise.all([...initializers.values()].map(t => t(container)));
|
|
397
|
+
map.set(container, res);
|
|
398
|
+
}
|
|
399
|
+
return res;
|
|
400
|
+
}
|
|
410
401
|
});
|