@tsparticles/engine 4.0.0-alpha.0 → 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 +219 -195
- 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
|
@@ -1,320 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { InteractivityDetect } from "../../Enums/InteractivityDetect.js";
|
|
4
|
-
import { isBoolean } from "../../Utils/TypeUtils.js";
|
|
5
|
-
function manageListener(element, event, handler, add, options) {
|
|
6
|
-
if (add) {
|
|
7
|
-
let addOptions = { passive: true };
|
|
8
|
-
if (isBoolean(options)) {
|
|
9
|
-
addOptions.capture = options;
|
|
10
|
-
}
|
|
11
|
-
else if (options !== undefined) {
|
|
12
|
-
addOptions = options;
|
|
13
|
-
}
|
|
14
|
-
element.addEventListener(event, handler, addOptions);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
const removeOptions = options;
|
|
18
|
-
element.removeEventListener(event, handler, removeOptions);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { manageListener, safeDocument } from "../../Utils/Utils.js";
|
|
2
|
+
import { millisecondsToSeconds, resizeEvent, visibilityChangeEvent } from "./Constants.js";
|
|
21
3
|
export class EventListeners {
|
|
4
|
+
container;
|
|
5
|
+
_handlers;
|
|
6
|
+
_resizeObserver;
|
|
7
|
+
_resizeTimeout;
|
|
22
8
|
constructor(container) {
|
|
23
9
|
this.container = container;
|
|
24
|
-
this._canPush = true;
|
|
25
|
-
this._doMouseTouchClick = e => {
|
|
26
|
-
const container = this.container, options = container.actualOptions;
|
|
27
|
-
if (this._canPush) {
|
|
28
|
-
const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
|
|
29
|
-
if (!mousePos) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
mouseInteractivity.clickPosition = { ...mousePos };
|
|
33
|
-
mouseInteractivity.clickTime = Date.now();
|
|
34
|
-
const onClick = options.interactivity.events.onClick;
|
|
35
|
-
executeOnSingleOrMultiple(onClick.mode, mode => {
|
|
36
|
-
this.container.handleClickMode(mode);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (e.type === "touchend") {
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
this._mouseTouchFinish();
|
|
42
|
-
}, touchDelay);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
this._handleThemeChange = (e) => {
|
|
46
|
-
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);
|
|
47
|
-
if (theme?.default.auto) {
|
|
48
|
-
void container.loadTheme(themeName);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
this._handleVisibilityChange = () => {
|
|
52
|
-
const container = this.container, options = container.actualOptions;
|
|
53
|
-
this._mouseTouchFinish();
|
|
54
|
-
if (!options.pauseOnBlur) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (safeDocument().hidden) {
|
|
58
|
-
container.pageHidden = true;
|
|
59
|
-
container.pause();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
container.pageHidden = false;
|
|
63
|
-
if (container.animationStatus) {
|
|
64
|
-
container.play(true);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
container.draw(true);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
this._handleWindowResize = () => {
|
|
72
|
-
if (this._resizeTimeout) {
|
|
73
|
-
clearTimeout(this._resizeTimeout);
|
|
74
|
-
delete this._resizeTimeout;
|
|
75
|
-
}
|
|
76
|
-
const handleResize = async () => {
|
|
77
|
-
const canvas = this.container.canvas;
|
|
78
|
-
await canvas.windowResize();
|
|
79
|
-
};
|
|
80
|
-
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay * millisecondsToSeconds);
|
|
81
|
-
};
|
|
82
|
-
this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
|
|
83
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions, interactivityEl = container.interactivity.element;
|
|
84
|
-
if (!interactivityEl) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const html = interactivityEl, canvas = container.canvas;
|
|
88
|
-
canvas.setPointerEvents(html === canvas.element ? "initial" : "none");
|
|
89
|
-
if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
|
|
93
|
-
manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
|
|
94
|
-
manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
|
|
95
|
-
if (options.interactivity.events.onClick.enable) {
|
|
96
|
-
manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add);
|
|
97
|
-
manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
|
|
98
|
-
manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add);
|
|
102
|
-
}
|
|
103
|
-
manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
|
|
104
|
-
manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
|
|
105
|
-
};
|
|
106
|
-
this._manageListeners = add => {
|
|
107
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
|
|
108
|
-
let mouseLeaveTmpEvent = mouseLeaveEvent;
|
|
109
|
-
if (detectType === InteractivityDetect.window) {
|
|
110
|
-
container.interactivity.element = window;
|
|
111
|
-
mouseLeaveTmpEvent = mouseOutEvent;
|
|
112
|
-
}
|
|
113
|
-
else if (detectType === InteractivityDetect.parent && canvasEl) {
|
|
114
|
-
container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
container.interactivity.element = canvasEl;
|
|
118
|
-
}
|
|
119
|
-
this._manageMediaMatch(add);
|
|
120
|
-
this._manageResize(add);
|
|
121
|
-
this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
|
|
122
|
-
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
123
|
-
};
|
|
124
|
-
this._manageMediaMatch = add => {
|
|
125
|
-
const handlers = this._handlers;
|
|
126
|
-
if (!this._matchMedia) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
manageListener(this._matchMedia, "change", handlers.themeChange, add);
|
|
130
|
-
};
|
|
131
|
-
this._manageResize = add => {
|
|
132
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
133
|
-
if (!options.interactivity.events.resize.enable) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (typeof ResizeObserver === "undefined") {
|
|
137
|
-
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const canvasEl = container.canvas.element;
|
|
141
|
-
if (this._resizeObserver && !add) {
|
|
142
|
-
if (canvasEl) {
|
|
143
|
-
this._resizeObserver.unobserve(canvasEl);
|
|
144
|
-
}
|
|
145
|
-
this._resizeObserver.disconnect();
|
|
146
|
-
delete this._resizeObserver;
|
|
147
|
-
}
|
|
148
|
-
else if (!this._resizeObserver && add && canvasEl) {
|
|
149
|
-
this._resizeObserver = new ResizeObserver((entries) => {
|
|
150
|
-
const entry = entries.find(e => e.target === canvasEl);
|
|
151
|
-
if (!entry) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
this._handleWindowResize();
|
|
155
|
-
});
|
|
156
|
-
this._resizeObserver.observe(canvasEl);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
this._mouseDown = () => {
|
|
160
|
-
const { interactivity } = this.container, { mouse } = interactivity;
|
|
161
|
-
mouse.clicking = true;
|
|
162
|
-
mouse.downPosition = mouse.position;
|
|
163
|
-
};
|
|
164
|
-
this._mouseTouchClick = e => {
|
|
165
|
-
const container = this.container, options = container.actualOptions, { mouse } = container.interactivity;
|
|
166
|
-
mouse.inside = true;
|
|
167
|
-
let handled = false;
|
|
168
|
-
const mousePosition = mouse.position;
|
|
169
|
-
if (!mousePosition || !options.interactivity.events.onClick.enable) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
for (const plugin of container.plugins.values()) {
|
|
173
|
-
if (!plugin.clickPositionValid) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
handled = plugin.clickPositionValid(mousePosition);
|
|
177
|
-
if (handled) {
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (!handled) {
|
|
182
|
-
this._doMouseTouchClick(e);
|
|
183
|
-
}
|
|
184
|
-
mouse.clicking = false;
|
|
185
|
-
};
|
|
186
|
-
this._mouseTouchFinish = () => {
|
|
187
|
-
const { interactivity } = this.container, { mouse } = interactivity;
|
|
188
|
-
delete mouse.position;
|
|
189
|
-
delete mouse.clickPosition;
|
|
190
|
-
delete mouse.downPosition;
|
|
191
|
-
interactivity.status = mouseLeaveEvent;
|
|
192
|
-
mouse.inside = false;
|
|
193
|
-
mouse.clicking = false;
|
|
194
|
-
};
|
|
195
|
-
this._mouseTouchMove = e => {
|
|
196
|
-
const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
|
|
197
|
-
if (!interactivity.element) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
interactivity.mouse.inside = true;
|
|
201
|
-
let pos;
|
|
202
|
-
if (e.type.startsWith("pointer")) {
|
|
203
|
-
this._canPush = true;
|
|
204
|
-
const mouseEvent = e;
|
|
205
|
-
if (interactivity.element === window) {
|
|
206
|
-
if (canvasEl) {
|
|
207
|
-
const clientRect = canvasEl.getBoundingClientRect();
|
|
208
|
-
pos = {
|
|
209
|
-
x: mouseEvent.clientX - clientRect.left,
|
|
210
|
-
y: mouseEvent.clientY - clientRect.top,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else if (options.interactivity.detectsOn === InteractivityDetect.parent) {
|
|
215
|
-
const source = mouseEvent.target, target = mouseEvent.currentTarget;
|
|
216
|
-
if (canvasEl) {
|
|
217
|
-
const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
|
|
218
|
-
pos = {
|
|
219
|
-
x: mouseEvent.offsetX + double * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
220
|
-
y: mouseEvent.offsetY + double * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
pos = {
|
|
225
|
-
x: mouseEvent.offsetX,
|
|
226
|
-
y: mouseEvent.offsetY,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else if (mouseEvent.target === canvasEl) {
|
|
231
|
-
pos = {
|
|
232
|
-
x: mouseEvent.offsetX,
|
|
233
|
-
y: mouseEvent.offsetY,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
this._canPush = e.type !== "touchmove";
|
|
239
|
-
if (canvasEl) {
|
|
240
|
-
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
|
|
241
|
-
if (!lastTouch) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
pos = {
|
|
245
|
-
x: lastTouch.clientX - canvasRect.left,
|
|
246
|
-
y: lastTouch.clientY - canvasRect.top,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
const pxRatio = container.retina.pixelRatio;
|
|
251
|
-
if (pos) {
|
|
252
|
-
pos.x *= pxRatio;
|
|
253
|
-
pos.y *= pxRatio;
|
|
254
|
-
}
|
|
255
|
-
interactivity.mouse.position = pos;
|
|
256
|
-
interactivity.status = mouseMoveEvent;
|
|
257
|
-
};
|
|
258
|
-
this._touchEnd = e => {
|
|
259
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
260
|
-
for (const touch of touches) {
|
|
261
|
-
this._touches.delete(touch.identifier);
|
|
262
|
-
}
|
|
263
|
-
this._mouseTouchFinish();
|
|
264
|
-
};
|
|
265
|
-
this._touchEndClick = e => {
|
|
266
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
267
|
-
for (const touch of touches) {
|
|
268
|
-
this._touches.delete(touch.identifier);
|
|
269
|
-
}
|
|
270
|
-
this._mouseTouchClick(e);
|
|
271
|
-
};
|
|
272
|
-
this._touchStart = e => {
|
|
273
|
-
const evt = e, touches = Array.from(evt.changedTouches);
|
|
274
|
-
for (const touch of touches) {
|
|
275
|
-
this._touches.set(touch.identifier, performance.now());
|
|
276
|
-
}
|
|
277
|
-
this._mouseTouchMove(e);
|
|
278
|
-
};
|
|
279
|
-
this._matchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
280
|
-
this._touches = new Map();
|
|
281
10
|
this._handlers = {
|
|
282
|
-
mouseDown: () => {
|
|
283
|
-
this._mouseDown();
|
|
284
|
-
},
|
|
285
|
-
mouseLeave: () => {
|
|
286
|
-
this._mouseTouchFinish();
|
|
287
|
-
},
|
|
288
|
-
mouseMove: (e) => {
|
|
289
|
-
this._mouseTouchMove(e);
|
|
290
|
-
},
|
|
291
|
-
mouseUp: (e) => {
|
|
292
|
-
this._mouseTouchClick(e);
|
|
293
|
-
},
|
|
294
|
-
touchStart: (e) => {
|
|
295
|
-
this._touchStart(e);
|
|
296
|
-
},
|
|
297
|
-
touchMove: (e) => {
|
|
298
|
-
this._mouseTouchMove(e);
|
|
299
|
-
},
|
|
300
|
-
touchEnd: (e) => {
|
|
301
|
-
this._touchEnd(e);
|
|
302
|
-
},
|
|
303
|
-
touchCancel: (e) => {
|
|
304
|
-
this._touchEnd(e);
|
|
305
|
-
},
|
|
306
|
-
touchEndClick: (e) => {
|
|
307
|
-
this._touchEndClick(e);
|
|
308
|
-
},
|
|
309
11
|
visibilityChange: () => {
|
|
310
12
|
this._handleVisibilityChange();
|
|
311
13
|
},
|
|
312
|
-
themeChange: (e) => {
|
|
313
|
-
this._handleThemeChange(e);
|
|
314
|
-
},
|
|
315
|
-
oldThemeChange: (e) => {
|
|
316
|
-
this._handleThemeChange(e);
|
|
317
|
-
},
|
|
318
14
|
resize: () => {
|
|
319
15
|
this._handleWindowResize();
|
|
320
16
|
},
|
|
@@ -326,4 +22,67 @@ export class EventListeners {
|
|
|
326
22
|
removeListeners() {
|
|
327
23
|
this._manageListeners(false);
|
|
328
24
|
}
|
|
25
|
+
_handleVisibilityChange = () => {
|
|
26
|
+
const container = this.container, options = container.actualOptions;
|
|
27
|
+
if (!options.pauseOnBlur) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (safeDocument().hidden) {
|
|
31
|
+
container.pageHidden = true;
|
|
32
|
+
container.pause();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
container.pageHidden = false;
|
|
36
|
+
if (container.animationStatus) {
|
|
37
|
+
container.play(true);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
container.draw(true);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
_handleWindowResize = () => {
|
|
45
|
+
if (this._resizeTimeout) {
|
|
46
|
+
clearTimeout(this._resizeTimeout);
|
|
47
|
+
delete this._resizeTimeout;
|
|
48
|
+
}
|
|
49
|
+
const handleResize = async () => {
|
|
50
|
+
const canvas = this.container.canvas;
|
|
51
|
+
await canvas.windowResize();
|
|
52
|
+
};
|
|
53
|
+
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
54
|
+
};
|
|
55
|
+
_manageListeners = add => {
|
|
56
|
+
const handlers = this._handlers;
|
|
57
|
+
this._manageResize(add);
|
|
58
|
+
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
59
|
+
};
|
|
60
|
+
_manageResize = add => {
|
|
61
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
62
|
+
if (!options.resize.enable) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof ResizeObserver === "undefined") {
|
|
66
|
+
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const canvasEl = container.canvas.element;
|
|
70
|
+
if (this._resizeObserver && !add) {
|
|
71
|
+
if (canvasEl) {
|
|
72
|
+
this._resizeObserver.unobserve(canvasEl);
|
|
73
|
+
}
|
|
74
|
+
this._resizeObserver.disconnect();
|
|
75
|
+
delete this._resizeObserver;
|
|
76
|
+
}
|
|
77
|
+
else if (!this._resizeObserver && add && canvasEl) {
|
|
78
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
|
79
|
+
const entry = entries.find(e => e.target === canvasEl);
|
|
80
|
+
if (!entry) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this._handleWindowResize();
|
|
84
|
+
});
|
|
85
|
+
this._resizeObserver.observe(canvasEl);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
329
88
|
}
|
|
@@ -2,17 +2,14 @@ import { Circle, Rectangle } from "./Ranges.js";
|
|
|
2
2
|
import { double, half, subdivideCount } from "./Constants.js";
|
|
3
3
|
import { getDistance } from "../../Utils/MathUtils.js";
|
|
4
4
|
export class QuadTree {
|
|
5
|
+
rectangle;
|
|
6
|
+
capacity;
|
|
7
|
+
_divided;
|
|
8
|
+
_points;
|
|
9
|
+
_subs;
|
|
5
10
|
constructor(rectangle, capacity) {
|
|
6
11
|
this.rectangle = rectangle;
|
|
7
12
|
this.capacity = capacity;
|
|
8
|
-
this._subdivide = () => {
|
|
9
|
-
const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
|
|
10
|
-
for (let i = 0; i < subdivideCount; i++) {
|
|
11
|
-
const fixedIndex = i % double;
|
|
12
|
-
this._subs.push(new QuadTree(new Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
|
|
13
|
-
}
|
|
14
|
-
this._divided = true;
|
|
15
|
-
};
|
|
16
13
|
this._points = [];
|
|
17
14
|
this._divided = false;
|
|
18
15
|
this._subs = [];
|
|
@@ -56,4 +53,12 @@ export class QuadTree {
|
|
|
56
53
|
queryRectangle(position, size, check) {
|
|
57
54
|
return this.query(new Rectangle(position.x, position.y, size.width, size.height), check);
|
|
58
55
|
}
|
|
56
|
+
_subdivide = () => {
|
|
57
|
+
const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
|
|
58
|
+
for (let i = 0; i < subdivideCount; i++) {
|
|
59
|
+
const fixedIndex = i % double;
|
|
60
|
+
this._subs.push(new QuadTree(new Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
|
|
61
|
+
}
|
|
62
|
+
this._divided = true;
|
|
63
|
+
};
|
|
59
64
|
}
|
|
@@ -2,6 +2,8 @@ import { RangeType } from "../../Enums/RangeType.js";
|
|
|
2
2
|
import { getDistance } from "../../Utils/MathUtils.js";
|
|
3
3
|
import { squareExp } from "./Constants.js";
|
|
4
4
|
export class BaseRange {
|
|
5
|
+
position;
|
|
6
|
+
type;
|
|
5
7
|
constructor(x, y, type) {
|
|
6
8
|
this.position = {
|
|
7
9
|
x: x,
|
|
@@ -11,6 +13,7 @@ export class BaseRange {
|
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
export class Circle extends BaseRange {
|
|
16
|
+
radius;
|
|
14
17
|
constructor(x, y, radius) {
|
|
15
18
|
super(x, y, RangeType.circle);
|
|
16
19
|
this.radius = radius;
|
|
@@ -35,6 +38,7 @@ export class Circle extends BaseRange {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
export class Rectangle extends BaseRange {
|
|
41
|
+
size;
|
|
38
42
|
constructor(x, y, width, height) {
|
|
39
43
|
super(x, y, RangeType.rectangle);
|
|
40
44
|
this.size = {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { inverseFactorNumerator, none, originPoint, squareExp } from "./Constants.js";
|
|
2
2
|
export class Vector3d {
|
|
3
|
+
x;
|
|
4
|
+
y;
|
|
5
|
+
z;
|
|
3
6
|
constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
|
|
4
|
-
this._updateFromAngle = (angle, length) => {
|
|
5
|
-
this.x = Math.cos(angle) * length;
|
|
6
|
-
this.y = Math.sin(angle) * length;
|
|
7
|
-
};
|
|
8
7
|
this.x = x;
|
|
9
8
|
this.y = y;
|
|
10
9
|
this.z = z;
|
|
@@ -92,6 +91,10 @@ export class Vector3d {
|
|
|
92
91
|
this.y -= v.y;
|
|
93
92
|
this.z -= v.z;
|
|
94
93
|
}
|
|
94
|
+
_updateFromAngle = (angle, length) => {
|
|
95
|
+
this.x = Math.cos(angle) * length;
|
|
96
|
+
this.y = Math.sin(angle) * length;
|
|
97
|
+
};
|
|
95
98
|
}
|
|
96
99
|
export class Vector extends Vector3d {
|
|
97
100
|
constructor(x = originPoint.x, y = originPoint.y) {
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
export var EasingType;
|
|
2
2
|
(function (EasingType) {
|
|
3
3
|
EasingType["easeInBack"] = "ease-in-back";
|
|
4
|
+
EasingType["easeInBounce"] = "ease-in-bounce";
|
|
4
5
|
EasingType["easeInCirc"] = "ease-in-circ";
|
|
5
6
|
EasingType["easeInCubic"] = "ease-in-cubic";
|
|
7
|
+
EasingType["easeInElastic"] = "ease-in-elastic";
|
|
8
|
+
EasingType["easeInExpo"] = "ease-in-expo";
|
|
9
|
+
EasingType["easeInGaussian"] = "ease-in-gaussian";
|
|
6
10
|
EasingType["easeInLinear"] = "ease-in-linear";
|
|
7
11
|
EasingType["easeInQuad"] = "ease-in-quad";
|
|
8
12
|
EasingType["easeInQuart"] = "ease-in-quart";
|
|
9
13
|
EasingType["easeInQuint"] = "ease-in-quint";
|
|
10
|
-
EasingType["
|
|
14
|
+
EasingType["easeInSigmoid"] = "ease-in-sigmoid";
|
|
11
15
|
EasingType["easeInSine"] = "ease-in-sine";
|
|
16
|
+
EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
|
|
12
17
|
EasingType["easeOutBack"] = "ease-out-back";
|
|
18
|
+
EasingType["easeOutBounce"] = "ease-out-bounce";
|
|
13
19
|
EasingType["easeOutCirc"] = "ease-out-circ";
|
|
14
20
|
EasingType["easeOutCubic"] = "ease-out-cubic";
|
|
21
|
+
EasingType["easeOutElastic"] = "ease-out-elastic";
|
|
22
|
+
EasingType["easeOutExpo"] = "ease-out-expo";
|
|
23
|
+
EasingType["easeOutGaussian"] = "ease-out-gaussian";
|
|
15
24
|
EasingType["easeOutLinear"] = "ease-out-linear";
|
|
16
25
|
EasingType["easeOutQuad"] = "ease-out-quad";
|
|
17
26
|
EasingType["easeOutQuart"] = "ease-out-quart";
|
|
18
27
|
EasingType["easeOutQuint"] = "ease-out-quint";
|
|
19
|
-
EasingType["
|
|
28
|
+
EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
|
|
20
29
|
EasingType["easeOutSine"] = "ease-out-sine";
|
|
30
|
+
EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
|
|
21
31
|
EasingType["easeInOutBack"] = "ease-in-out-back";
|
|
32
|
+
EasingType["easeInOutBounce"] = "ease-in-out-bounce";
|
|
22
33
|
EasingType["easeInOutCirc"] = "ease-in-out-circ";
|
|
23
34
|
EasingType["easeInOutCubic"] = "ease-in-out-cubic";
|
|
35
|
+
EasingType["easeInOutElastic"] = "ease-in-out-elastic";
|
|
36
|
+
EasingType["easeInOutExpo"] = "ease-in-out-expo";
|
|
37
|
+
EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
|
|
24
38
|
EasingType["easeInOutLinear"] = "ease-in-out-linear";
|
|
25
39
|
EasingType["easeInOutQuad"] = "ease-in-out-quad";
|
|
26
40
|
EasingType["easeInOutQuart"] = "ease-in-out-quart";
|
|
27
41
|
EasingType["easeInOutQuint"] = "ease-in-out-quint";
|
|
28
|
-
EasingType["
|
|
42
|
+
EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
|
|
29
43
|
EasingType["easeInOutSine"] = "ease-in-out-sine";
|
|
44
|
+
EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
|
|
30
45
|
})(EasingType || (EasingType = {}));
|
|
@@ -2,6 +2,7 @@ import { isArray, isNull, isString } from "../../Utils/TypeUtils.js";
|
|
|
2
2
|
import { HslAnimation } from "./HslAnimation.js";
|
|
3
3
|
import { OptionsColor } from "./OptionsColor.js";
|
|
4
4
|
export class AnimatableColor extends OptionsColor {
|
|
5
|
+
animation;
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
8
|
this.animation = new HslAnimation();
|
|
@@ -3,6 +3,12 @@ import { StartValueType } from "../../Enums/Types/StartValueType.js";
|
|
|
3
3
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
4
4
|
import { setRangeValue } from "../../Utils/MathUtils.js";
|
|
5
5
|
export class AnimationOptions {
|
|
6
|
+
count;
|
|
7
|
+
decay;
|
|
8
|
+
delay;
|
|
9
|
+
enable;
|
|
10
|
+
speed;
|
|
11
|
+
sync;
|
|
6
12
|
constructor() {
|
|
7
13
|
this.count = 0;
|
|
8
14
|
this.enable = false;
|
|
@@ -36,6 +42,8 @@ export class AnimationOptions {
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
export class RangedAnimationOptions extends AnimationOptions {
|
|
45
|
+
mode;
|
|
46
|
+
startValue;
|
|
39
47
|
constructor() {
|
|
40
48
|
super();
|
|
41
49
|
this.mode = AnimationMode.auto;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { OptionsColor } from "../OptionsColor.js";
|
|
2
2
|
import { isNull } from "../../../Utils/TypeUtils.js";
|
|
3
3
|
export class Background {
|
|
4
|
+
color;
|
|
5
|
+
image;
|
|
6
|
+
opacity;
|
|
7
|
+
position;
|
|
8
|
+
repeat;
|
|
9
|
+
size;
|
|
4
10
|
constructor() {
|
|
5
11
|
this.color = new OptionsColor();
|
|
6
12
|
this.color.value = "";
|
|
@@ -2,6 +2,7 @@ import { AnimationOptions } from "./AnimationOptions.js";
|
|
|
2
2
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
3
3
|
import { setRangeValue } from "../../Utils/MathUtils.js";
|
|
4
4
|
export class ColorAnimation extends AnimationOptions {
|
|
5
|
+
offset;
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
8
|
this.offset = 0;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ColorAnimation } from "./ColorAnimation.js";
|
|
2
2
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
3
3
|
export class HslAnimation {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.l = new ColorAnimation();
|
|
8
|
-
}
|
|
4
|
+
h = new ColorAnimation();
|
|
5
|
+
l = new ColorAnimation();
|
|
6
|
+
s = new ColorAnimation();
|
|
9
7
|
load(data) {
|
|
10
8
|
if (isNull(data)) {
|
|
11
9
|
return;
|