@tsparticles/engine 4.0.0-alpha.1 → 4.0.0-alpha.14
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/219.min.js +1 -0
- package/README.md +2 -5
- package/browser/Core/Canvas.js +238 -154
- package/browser/Core/Container.js +111 -227
- package/browser/Core/Engine.js +84 -124
- package/browser/Core/Particle.js +236 -140
- package/browser/Core/Particles.js +212 -123
- package/browser/Core/Retina.js +5 -0
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +69 -310
- package/browser/Core/Utils/Point.js +2 -0
- package/browser/Core/Utils/QuadTree.js +13 -8
- package/browser/Core/Utils/Ranges.js +4 -0
- package/browser/Core/Utils/Vectors.js +7 -4
- package/browser/Enums/Types/EasingType.js +18 -3
- package/browser/Options/Classes/AnimatableColor.js +1 -0
- package/browser/Options/Classes/AnimationOptions.js +8 -0
- package/browser/Options/Classes/Background/Background.js +6 -0
- package/browser/Options/Classes/ColorAnimation.js +1 -0
- package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/browser/Options/Classes/HslAnimation.js +3 -5
- package/browser/Options/Classes/Options.js +32 -78
- package/browser/Options/Classes/OptionsColor.js +1 -0
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/browser/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/browser/Options/Classes/Particles/Move/Move.js +18 -0
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/browser/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/browser/Options/Classes/Particles/Size/Size.js +1 -0
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/browser/Options/Classes/Particles/Stroke.js +3 -0
- package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +3 -1
- package/browser/Options/Classes/ValueWithRandom.js +3 -4
- package/browser/Utils/CanvasUtils.js +31 -106
- package/browser/Utils/ColorUtils.js +17 -2
- package/browser/Utils/EventDispatcher.js +1 -0
- package/browser/Utils/MathUtils.js +3 -2
- package/browser/Utils/Utils.js +53 -44
- package/browser/exports.js +1 -21
- package/cjs/Core/Canvas.js +238 -154
- package/cjs/Core/Container.js +111 -227
- package/cjs/Core/Engine.js +84 -124
- package/cjs/Core/Particle.js +236 -140
- package/cjs/Core/Particles.js +212 -123
- package/cjs/Core/Retina.js +5 -0
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +69 -310
- package/cjs/Core/Utils/Point.js +2 -0
- package/cjs/Core/Utils/QuadTree.js +13 -8
- package/cjs/Core/Utils/Ranges.js +4 -0
- package/cjs/Core/Utils/Vectors.js +7 -4
- package/cjs/Enums/Types/EasingType.js +18 -3
- package/cjs/Options/Classes/AnimatableColor.js +1 -0
- package/cjs/Options/Classes/AnimationOptions.js +8 -0
- package/cjs/Options/Classes/Background/Background.js +6 -0
- package/cjs/Options/Classes/ColorAnimation.js +1 -0
- package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/cjs/Options/Classes/HslAnimation.js +3 -5
- package/cjs/Options/Classes/Options.js +32 -78
- package/cjs/Options/Classes/OptionsColor.js +1 -0
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/cjs/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +18 -0
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/cjs/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/Stroke.js +3 -0
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +3 -1
- package/cjs/Options/Classes/ValueWithRandom.js +3 -4
- package/cjs/Utils/CanvasUtils.js +31 -106
- package/cjs/Utils/ColorUtils.js +17 -2
- package/cjs/Utils/EventDispatcher.js +1 -0
- package/cjs/Utils/MathUtils.js +3 -2
- package/cjs/Utils/Utils.js +53 -44
- package/cjs/exports.js +1 -21
- package/dist_browser_Core_Container_js.js +8 -18
- package/esm/Core/Canvas.js +238 -154
- package/esm/Core/Container.js +111 -227
- package/esm/Core/Engine.js +84 -124
- package/esm/Core/Particle.js +236 -140
- package/esm/Core/Particles.js +212 -123
- package/esm/Core/Retina.js +5 -0
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +69 -310
- package/esm/Core/Utils/Point.js +2 -0
- package/esm/Core/Utils/QuadTree.js +13 -8
- package/esm/Core/Utils/Ranges.js +4 -0
- package/esm/Core/Utils/Vectors.js +7 -4
- package/esm/Enums/Types/EasingType.js +18 -3
- package/esm/Options/Classes/AnimatableColor.js +1 -0
- package/esm/Options/Classes/AnimationOptions.js +8 -0
- package/esm/Options/Classes/Background/Background.js +6 -0
- package/esm/Options/Classes/ColorAnimation.js +1 -0
- package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/esm/Options/Classes/HslAnimation.js +3 -5
- package/esm/Options/Classes/Options.js +32 -78
- package/esm/Options/Classes/OptionsColor.js +1 -0
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/esm/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/esm/Options/Classes/Particles/Move/Move.js +18 -0
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/esm/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/esm/Options/Classes/Particles/Size/Size.js +1 -0
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/esm/Options/Classes/Particles/Stroke.js +3 -0
- package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +3 -1
- package/esm/Options/Classes/ValueWithRandom.js +3 -4
- package/esm/Utils/CanvasUtils.js +31 -106
- package/esm/Utils/ColorUtils.js +17 -2
- package/esm/Utils/EventDispatcher.js +1 -0
- package/esm/Utils/MathUtils.js +3 -2
- package/esm/Utils/Utils.js +53 -44
- package/esm/exports.js +1 -21
- package/package.json +1 -1
- package/report.html +3 -3
- package/scripts/install.js +28 -9
- package/tsparticles.engine.js +67 -247
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Canvas.d.ts +15 -4
- package/types/Core/Container.d.ts +5 -20
- package/types/Core/Engine.d.ts +18 -32
- package/types/Core/Interfaces/IColorManager.d.ts +0 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +12 -2
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +1 -2
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleRotateData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleTransformValues.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +1 -1
- package/types/Core/Interfaces/IPlugin.d.ts +5 -1
- package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
- package/types/Core/Particle.d.ts +13 -2
- package/types/Core/Particles.d.ts +17 -8
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +0 -14
- package/types/Enums/Types/EasingType.d.ts +20 -5
- package/types/Options/Classes/HslAnimation.d.ts +3 -4
- 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/Classes/ValueWithRandom.d.ts +0 -1
- package/types/Options/Interfaces/IOptions.d.ts +2 -8
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
- package/types/Types/CustomEventListener.d.ts +1 -1
- package/types/Types/EngineInitializers.d.ts +19 -0
- package/types/Utils/CanvasUtils.d.ts +6 -25
- package/types/Utils/EventDispatcher.d.ts +1 -1
- package/types/Utils/Utils.d.ts +5 -7
- package/types/export-types.d.ts +3 -19
- package/types/exports.d.ts +1 -21
- package/umd/Core/Canvas.js +236 -152
- package/umd/Core/Container.js +111 -227
- package/umd/Core/Engine.js +83 -123
- package/umd/Core/Particle.js +236 -140
- package/umd/Core/Particles.js +213 -124
- package/umd/Core/Retina.js +5 -0
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +69 -310
- package/umd/Core/Utils/Point.js +2 -0
- package/umd/Core/Utils/QuadTree.js +13 -8
- package/umd/Core/Utils/Ranges.js +4 -0
- package/umd/Core/Utils/Vectors.js +7 -4
- package/umd/Enums/Types/EasingType.js +18 -3
- package/umd/Options/Classes/AnimatableColor.js +1 -0
- package/umd/Options/Classes/AnimationOptions.js +8 -0
- package/umd/Options/Classes/Background/Background.js +6 -0
- package/umd/Options/Classes/ColorAnimation.js +1 -0
- package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/umd/Options/Classes/HslAnimation.js +3 -5
- package/umd/Options/Classes/Options.js +32 -78
- package/umd/Options/Classes/OptionsColor.js +1 -0
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/umd/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/umd/Options/Classes/Particles/Move/Move.js +18 -0
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/umd/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/umd/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/umd/Options/Classes/Particles/Size/Size.js +1 -0
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/umd/Options/Classes/Particles/Stroke.js +3 -0
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +4 -2
- package/umd/Options/Classes/ValueWithRandom.js +3 -4
- package/umd/Utils/CanvasUtils.js +30 -108
- package/umd/Utils/ColorUtils.js +17 -2
- package/umd/Utils/EventDispatcher.js +1 -0
- package/umd/Utils/MathUtils.js +3 -2
- package/umd/Utils/Utils.js +55 -48
- package/umd/exports.js +2 -22
- package/638.min.js +0 -2
- package/638.min.js.LICENSE.txt +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/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/tsparticles.engine.min.js.LICENSE.txt +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/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/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/browser/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/browser/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
- /package/{browser/Core/Interfaces/IMouseData.js → cjs/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Core/Interfaces/IParticlesInteractor.js → cjs/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/IManualParticle.js → cjs/Types/EngineInitializers.js} +0 -0
- /package/{browser/Options/Interfaces/IResponsive.js → esm/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IClickEvent.js → esm/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IDivEvent.js → esm/Types/EngineInitializers.js} +0 -0
- /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
- /package/umd/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/umd/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/umd/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
package/esm/Core/Container.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { animate, cancelAnimation, getRangeValue } from "../Utils/MathUtils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { defaultFps, defaultFpsLimit, millisecondsToSeconds, minFpsLimit, removeDeleteCount, removeMinIndex, } from "./Utils/Constants.js";
|
|
3
3
|
import { Canvas } from "./Canvas.js";
|
|
4
4
|
import { EventListeners } from "./Utils/EventListeners.js";
|
|
5
5
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
@@ -8,15 +8,12 @@ import { Particles } from "./Particles.js";
|
|
|
8
8
|
import { Retina } from "./Retina.js";
|
|
9
9
|
import { getLogger } from "../Utils/LogUtils.js";
|
|
10
10
|
import { loadOptions } from "../Utils/OptionsUtils.js";
|
|
11
|
-
import { safeIntersectionObserver } from "../Utils/Utils.js";
|
|
12
11
|
function guardCheck(container) {
|
|
13
12
|
return !container.destroyed;
|
|
14
13
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
factor: smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds,
|
|
19
|
-
};
|
|
14
|
+
function updateDelta(delta, value, fpsLimit = defaultFps, smooth = false) {
|
|
15
|
+
delta.value = value;
|
|
16
|
+
delta.factor = smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds;
|
|
20
17
|
}
|
|
21
18
|
function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
22
19
|
const options = new Options(engine, container);
|
|
@@ -24,52 +21,37 @@ function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
|
24
21
|
return options;
|
|
25
22
|
}
|
|
26
23
|
export class Container {
|
|
24
|
+
actualOptions;
|
|
25
|
+
canvas;
|
|
26
|
+
destroyed;
|
|
27
|
+
fpsLimit;
|
|
28
|
+
hdr;
|
|
29
|
+
id;
|
|
30
|
+
pageHidden;
|
|
31
|
+
particleCreatedPlugins;
|
|
32
|
+
particleDestroyedPlugins;
|
|
33
|
+
particlePositionPlugins;
|
|
34
|
+
particles;
|
|
35
|
+
plugins;
|
|
36
|
+
retina;
|
|
37
|
+
started;
|
|
38
|
+
zLayers;
|
|
39
|
+
_delay;
|
|
40
|
+
_delayTimeout;
|
|
41
|
+
_delta = { value: 0, factor: 0 };
|
|
42
|
+
_drawAnimationFrame;
|
|
43
|
+
_duration;
|
|
44
|
+
_engine;
|
|
45
|
+
_eventListeners;
|
|
46
|
+
_firstStart;
|
|
47
|
+
_initialSourceOptions;
|
|
48
|
+
_lastFrameTime;
|
|
49
|
+
_lifeTime;
|
|
50
|
+
_options;
|
|
51
|
+
_paused;
|
|
52
|
+
_smooth;
|
|
53
|
+
_sourceOptions;
|
|
27
54
|
constructor(engine, id, sourceOptions) {
|
|
28
|
-
this._intersectionManager = entries => {
|
|
29
|
-
if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
for (const entry of entries) {
|
|
33
|
-
if (entry.target !== this.interactivity.element) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (entry.isIntersecting) {
|
|
37
|
-
this.play();
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.pause();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this._nextFrame = (timestamp) => {
|
|
45
|
-
try {
|
|
46
|
-
if (!this._smooth &&
|
|
47
|
-
this._lastFrameTime !== undefined &&
|
|
48
|
-
timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
|
|
49
|
-
this.draw(false);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this._lastFrameTime ??= timestamp;
|
|
53
|
-
const delta = initDelta(timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
|
|
54
|
-
this.addLifeTime(delta.value);
|
|
55
|
-
this._lastFrameTime = timestamp;
|
|
56
|
-
if (delta.value > millisecondsToSeconds) {
|
|
57
|
-
this.draw(false);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
this.canvas.drawParticles(delta);
|
|
61
|
-
if (!this.alive()) {
|
|
62
|
-
this.destroy();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (this.animationStatus) {
|
|
66
|
-
this.draw(false);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
getLogger().error("error in animation loop", e);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
55
|
this._engine = engine;
|
|
74
56
|
this.id = Symbol(id);
|
|
75
57
|
this.fpsLimit = 120;
|
|
@@ -85,28 +67,18 @@ export class Container {
|
|
|
85
67
|
this._lastFrameTime = 0;
|
|
86
68
|
this.zLayers = 100;
|
|
87
69
|
this.pageHidden = false;
|
|
88
|
-
this._clickHandlers = new Map();
|
|
89
70
|
this._sourceOptions = sourceOptions;
|
|
90
71
|
this._initialSourceOptions = sourceOptions;
|
|
91
72
|
this.retina = new Retina(this);
|
|
92
73
|
this.canvas = new Canvas(this, this._engine);
|
|
93
74
|
this.particles = new Particles(this._engine, this);
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
inside: false,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
this.plugins = new Map();
|
|
102
|
-
this.effectDrawers = new Map();
|
|
103
|
-
this.shapeDrawers = new Map();
|
|
75
|
+
this.plugins = [];
|
|
76
|
+
this.particleDestroyedPlugins = [];
|
|
77
|
+
this.particleCreatedPlugins = [];
|
|
78
|
+
this.particlePositionPlugins = [];
|
|
104
79
|
this._options = loadContainerOptions(this._engine, this);
|
|
105
80
|
this.actualOptions = loadContainerOptions(this._engine, this);
|
|
106
81
|
this._eventListeners = new EventListeners(this);
|
|
107
|
-
this._intersectionObserver = safeIntersectionObserver(entries => {
|
|
108
|
-
this._intersectionManager(entries);
|
|
109
|
-
});
|
|
110
82
|
this._engine.dispatchEvent(EventType.containerBuilt, { container: this });
|
|
111
83
|
}
|
|
112
84
|
get animationStatus() {
|
|
@@ -118,123 +90,27 @@ export class Container {
|
|
|
118
90
|
get sourceOptions() {
|
|
119
91
|
return this._sourceOptions;
|
|
120
92
|
}
|
|
121
|
-
addClickHandler(callback) {
|
|
122
|
-
if (!guardCheck(this)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const el = this.interactivity.element;
|
|
126
|
-
if (!el) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const clickOrTouchHandler = (e, pos, radius) => {
|
|
130
|
-
if (!guardCheck(this)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const pxRatio = this.retina.pixelRatio, posRetina = {
|
|
134
|
-
x: pos.x * pxRatio,
|
|
135
|
-
y: pos.y * pxRatio,
|
|
136
|
-
}, particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
|
|
137
|
-
callback(e, particles);
|
|
138
|
-
}, clickHandler = (e) => {
|
|
139
|
-
if (!guardCheck(this)) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const mouseEvent = e, pos = {
|
|
143
|
-
x: mouseEvent.offsetX || mouseEvent.clientX,
|
|
144
|
-
y: mouseEvent.offsetY || mouseEvent.clientY,
|
|
145
|
-
};
|
|
146
|
-
clickOrTouchHandler(e, pos, clickRadius);
|
|
147
|
-
}, touchStartHandler = () => {
|
|
148
|
-
if (!guardCheck(this)) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
touched = true;
|
|
152
|
-
touchMoved = false;
|
|
153
|
-
}, touchMoveHandler = () => {
|
|
154
|
-
if (!guardCheck(this)) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
touchMoved = true;
|
|
158
|
-
}, touchEndHandler = (e) => {
|
|
159
|
-
if (!guardCheck(this)) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (touched && !touchMoved) {
|
|
163
|
-
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - touchEndLengthOffset];
|
|
164
|
-
if (!lastTouch) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const element = this.canvas.element, canvasRect = element ? element.getBoundingClientRect() : undefined, pos = {
|
|
168
|
-
x: lastTouch.clientX - (canvasRect ? canvasRect.left : minCoordinate),
|
|
169
|
-
y: lastTouch.clientY - (canvasRect ? canvasRect.top : minCoordinate),
|
|
170
|
-
};
|
|
171
|
-
clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
|
|
172
|
-
}
|
|
173
|
-
touched = false;
|
|
174
|
-
touchMoved = false;
|
|
175
|
-
}, touchCancelHandler = () => {
|
|
176
|
-
if (!guardCheck(this)) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
touched = false;
|
|
180
|
-
touchMoved = false;
|
|
181
|
-
};
|
|
182
|
-
let touched = false, touchMoved = false;
|
|
183
|
-
this._clickHandlers.set("click", clickHandler);
|
|
184
|
-
this._clickHandlers.set("touchstart", touchStartHandler);
|
|
185
|
-
this._clickHandlers.set("touchmove", touchMoveHandler);
|
|
186
|
-
this._clickHandlers.set("touchend", touchEndHandler);
|
|
187
|
-
this._clickHandlers.set("touchcancel", touchCancelHandler);
|
|
188
|
-
for (const [key, handler] of this._clickHandlers) {
|
|
189
|
-
el.addEventListener(key, handler);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
93
|
addLifeTime(value) {
|
|
193
94
|
this._lifeTime += value;
|
|
194
95
|
}
|
|
195
|
-
addPath(key, generator, override = false) {
|
|
196
|
-
if (!guardCheck(this) || (!override && this.pathGenerators.has(key))) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
this.pathGenerators.set(key, generator);
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
96
|
alive() {
|
|
203
97
|
return !this._duration || this._lifeTime <= this._duration;
|
|
204
98
|
}
|
|
205
|
-
clearClickHandlers() {
|
|
206
|
-
if (!guardCheck(this)) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
for (const [key, handler] of this._clickHandlers) {
|
|
210
|
-
this.interactivity.element?.removeEventListener(key, handler);
|
|
211
|
-
}
|
|
212
|
-
this._clickHandlers.clear();
|
|
213
|
-
}
|
|
214
99
|
destroy(remove = true) {
|
|
215
100
|
if (!guardCheck(this)) {
|
|
216
101
|
return;
|
|
217
102
|
}
|
|
218
103
|
this.stop();
|
|
219
|
-
this.clearClickHandlers();
|
|
220
104
|
this.particles.destroy();
|
|
221
105
|
this.canvas.destroy();
|
|
222
|
-
for (const
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
for (const shapeDrawer of this.shapeDrawers.values()) {
|
|
226
|
-
shapeDrawer.destroy?.(this);
|
|
227
|
-
}
|
|
228
|
-
for (const key of this.effectDrawers.keys()) {
|
|
229
|
-
this.effectDrawers.delete(key);
|
|
230
|
-
}
|
|
231
|
-
for (const key of this.shapeDrawers.keys()) {
|
|
232
|
-
this.shapeDrawers.delete(key);
|
|
106
|
+
for (const plugin of this.plugins) {
|
|
107
|
+
plugin.destroy?.();
|
|
233
108
|
}
|
|
109
|
+
this.plugins.length = 0;
|
|
234
110
|
this._engine.clearPlugins(this);
|
|
235
111
|
this.destroyed = true;
|
|
236
112
|
if (remove) {
|
|
237
|
-
const mainArr = this._engine.items, idx = mainArr.
|
|
113
|
+
const mainArr = this._engine.items, idx = mainArr.indexOf(this);
|
|
238
114
|
if (idx >= removeMinIndex) {
|
|
239
115
|
mainArr.splice(idx, removeDeleteCount);
|
|
240
116
|
}
|
|
@@ -258,7 +134,7 @@ export class Container {
|
|
|
258
134
|
});
|
|
259
135
|
}
|
|
260
136
|
async export(type, options = {}) {
|
|
261
|
-
for (const plugin of this.plugins
|
|
137
|
+
for (const plugin of this.plugins) {
|
|
262
138
|
if (!plugin.export) {
|
|
263
139
|
continue;
|
|
264
140
|
}
|
|
@@ -271,39 +147,38 @@ export class Container {
|
|
|
271
147
|
getLogger().error(`Export plugin with type ${type} not found`);
|
|
272
148
|
return undefined;
|
|
273
149
|
}
|
|
274
|
-
handleClickMode(mode) {
|
|
275
|
-
if (!guardCheck(this)) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
this.particles.handleClickMode(mode);
|
|
279
|
-
for (const plugin of this.plugins.values()) {
|
|
280
|
-
plugin.handleClickMode?.(mode);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
150
|
async init() {
|
|
284
151
|
if (!guardCheck(this)) {
|
|
285
152
|
return;
|
|
286
153
|
}
|
|
287
|
-
const
|
|
288
|
-
for (const
|
|
289
|
-
const
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
const shapes = this._engine.getSupportedShapes();
|
|
295
|
-
for (const type of shapes) {
|
|
296
|
-
const drawer = this._engine.getShapeDrawer(type);
|
|
297
|
-
if (drawer) {
|
|
298
|
-
this.shapeDrawers.set(type, drawer);
|
|
154
|
+
const allContainerPlugins = new Map();
|
|
155
|
+
for (const plugin of this._engine.plugins) {
|
|
156
|
+
const containerPlugin = await plugin.getPlugin(this);
|
|
157
|
+
if (containerPlugin.preInit) {
|
|
158
|
+
await containerPlugin.preInit();
|
|
299
159
|
}
|
|
160
|
+
allContainerPlugins.set(plugin, containerPlugin);
|
|
300
161
|
}
|
|
301
162
|
await this.particles.initPlugins();
|
|
302
163
|
this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
|
|
303
164
|
this.actualOptions = loadContainerOptions(this._engine, this, this._options);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
165
|
+
this.plugins.length = 0;
|
|
166
|
+
this.particleDestroyedPlugins.length = 0;
|
|
167
|
+
this.particleCreatedPlugins.length = 0;
|
|
168
|
+
this.particlePositionPlugins.length = 0;
|
|
169
|
+
for (const [plugin, containerPlugin] of allContainerPlugins) {
|
|
170
|
+
if (plugin.needsPlugin(this.actualOptions)) {
|
|
171
|
+
this.plugins.push(containerPlugin);
|
|
172
|
+
if (containerPlugin.particleCreated) {
|
|
173
|
+
this.particleCreatedPlugins.push(containerPlugin);
|
|
174
|
+
}
|
|
175
|
+
if (containerPlugin.particleDestroyed) {
|
|
176
|
+
this.particleDestroyedPlugins.push(containerPlugin);
|
|
177
|
+
}
|
|
178
|
+
if (containerPlugin.particlePosition) {
|
|
179
|
+
this.particlePositionPlugins.push(containerPlugin);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
307
182
|
}
|
|
308
183
|
this.retina.init();
|
|
309
184
|
this.canvas.init();
|
|
@@ -318,30 +193,17 @@ export class Container {
|
|
|
318
193
|
this._lifeTime = 0;
|
|
319
194
|
this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
|
|
320
195
|
this._smooth = smooth;
|
|
321
|
-
for (const
|
|
322
|
-
await drawer.init?.(this);
|
|
323
|
-
}
|
|
324
|
-
for (const drawer of this.shapeDrawers.values()) {
|
|
325
|
-
await drawer.init?.(this);
|
|
326
|
-
}
|
|
327
|
-
for (const plugin of this.plugins.values()) {
|
|
196
|
+
for (const plugin of this.plugins) {
|
|
328
197
|
await plugin.init?.();
|
|
329
198
|
}
|
|
330
|
-
this._engine.dispatchEvent(EventType.containerInit, { container: this });
|
|
331
199
|
await this.particles.init();
|
|
200
|
+
this._engine.dispatchEvent(EventType.containerInit, { container: this });
|
|
332
201
|
this.particles.setDensity();
|
|
333
|
-
for (const plugin of this.plugins
|
|
202
|
+
for (const plugin of this.plugins) {
|
|
334
203
|
plugin.particlesSetup?.();
|
|
335
204
|
}
|
|
336
205
|
this._engine.dispatchEvent(EventType.particlesSetup, { container: this });
|
|
337
206
|
}
|
|
338
|
-
async loadTheme(name) {
|
|
339
|
-
if (!guardCheck(this)) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
this._currentTheme = name;
|
|
343
|
-
await this.refresh();
|
|
344
|
-
}
|
|
345
207
|
pause() {
|
|
346
208
|
if (!guardCheck(this)) {
|
|
347
209
|
return;
|
|
@@ -353,7 +215,7 @@ export class Container {
|
|
|
353
215
|
if (this._paused) {
|
|
354
216
|
return;
|
|
355
217
|
}
|
|
356
|
-
for (const plugin of this.plugins
|
|
218
|
+
for (const plugin of this.plugins) {
|
|
357
219
|
plugin.pause?.();
|
|
358
220
|
}
|
|
359
221
|
if (!this.pageHidden) {
|
|
@@ -374,7 +236,7 @@ export class Container {
|
|
|
374
236
|
this._paused = false;
|
|
375
237
|
}
|
|
376
238
|
if (needsUpdate) {
|
|
377
|
-
for (const plugin of this.plugins
|
|
239
|
+
for (const plugin of this.plugins) {
|
|
378
240
|
if (plugin.play) {
|
|
379
241
|
plugin.play();
|
|
380
242
|
}
|
|
@@ -409,10 +271,7 @@ export class Container {
|
|
|
409
271
|
await new Promise(resolve => {
|
|
410
272
|
const start = async () => {
|
|
411
273
|
this._eventListeners.addListeners();
|
|
412
|
-
|
|
413
|
-
this._intersectionObserver.observe(this.interactivity.element);
|
|
414
|
-
}
|
|
415
|
-
for (const plugin of this.plugins.values()) {
|
|
274
|
+
for (const plugin of this.plugins) {
|
|
416
275
|
await plugin.start?.();
|
|
417
276
|
}
|
|
418
277
|
this._engine.dispatchEvent(EventType.containerStarted, { container: this });
|
|
@@ -436,26 +295,51 @@ export class Container {
|
|
|
436
295
|
this.pause();
|
|
437
296
|
this.particles.clear();
|
|
438
297
|
this.canvas.stop();
|
|
439
|
-
|
|
440
|
-
this._intersectionObserver.unobserve(this.interactivity.element);
|
|
441
|
-
}
|
|
442
|
-
for (const plugin of this.plugins.values()) {
|
|
298
|
+
for (const plugin of this.plugins) {
|
|
443
299
|
plugin.stop?.();
|
|
444
300
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
301
|
+
this.particleCreatedPlugins.length = 0;
|
|
302
|
+
this.particleDestroyedPlugins.length = 0;
|
|
303
|
+
this.particlePositionPlugins.length = 0;
|
|
448
304
|
this._sourceOptions = this._options;
|
|
449
305
|
this._engine.dispatchEvent(EventType.containerStopped, { container: this });
|
|
450
306
|
}
|
|
451
307
|
updateActualOptions() {
|
|
452
|
-
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
308
|
+
let refresh = false;
|
|
309
|
+
for (const plugin of this.plugins) {
|
|
310
|
+
if (plugin.updateActualOptions) {
|
|
311
|
+
refresh = plugin.updateActualOptions() || refresh;
|
|
312
|
+
}
|
|
457
313
|
}
|
|
458
|
-
|
|
459
|
-
return true;
|
|
314
|
+
return refresh;
|
|
460
315
|
}
|
|
316
|
+
_nextFrame = (timestamp) => {
|
|
317
|
+
try {
|
|
318
|
+
if (!this._smooth &&
|
|
319
|
+
this._lastFrameTime !== undefined &&
|
|
320
|
+
timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
|
|
321
|
+
this.draw(false);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
this._lastFrameTime ??= timestamp;
|
|
325
|
+
updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
|
|
326
|
+
this.addLifeTime(this._delta.value);
|
|
327
|
+
this._lastFrameTime = timestamp;
|
|
328
|
+
if (this._delta.value > millisecondsToSeconds) {
|
|
329
|
+
this.draw(false);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
this.canvas.drawParticles(this._delta);
|
|
333
|
+
if (!this.alive()) {
|
|
334
|
+
this.destroy();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (this.animationStatus) {
|
|
338
|
+
this.draw(false);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (e) {
|
|
342
|
+
getLogger().error("error in animation loop", e);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
461
345
|
}
|