@tsparticles/engine 3.0.0-alpha.1 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -188
- package/browser/Core/Canvas.js +273 -243
- package/browser/Core/Container.js +97 -113
- package/browser/Core/Engine.js +271 -0
- package/browser/Core/Particle.js +165 -172
- package/browser/Core/Particles.js +153 -148
- package/browser/Core/Retina.js +17 -15
- package/browser/Core/Utils/Circle.js +12 -8
- package/browser/Core/Utils/Constants.js +4 -3
- package/browser/Core/Utils/EventListeners.js +259 -235
- package/browser/Core/Utils/InteractionManager.js +6 -16
- package/browser/Core/Utils/QuadTree.js +17 -23
- package/browser/Core/Utils/Rectangle.js +2 -2
- package/browser/Core/Utils/Vector.js +1 -1
- package/browser/Core/Utils/Vector3d.js +17 -9
- package/browser/Options/Classes/AnimatableColor.js +4 -3
- package/browser/Options/Classes/AnimationOptions.js +5 -4
- package/browser/Options/Classes/Background/Background.js +1 -1
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
- package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +1 -1
- package/browser/Options/Classes/ColorAnimation.js +5 -1
- package/browser/Options/Classes/HslAnimation.js +1 -1
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/browser/Options/Classes/Interactivity/Events/Events.js +9 -28
- package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +1 -1
- package/browser/Options/Classes/Interactivity/Interactivity.js +3 -10
- package/browser/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/browser/Options/Classes/ManualParticle.js +6 -7
- package/browser/Options/Classes/Options.js +28 -48
- package/browser/Options/Classes/OptionsColor.js +3 -2
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +1 -1
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +1 -1
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +8 -3
- package/browser/Options/Classes/Particles/Move/Move.js +20 -50
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +10 -21
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveTrail.js +3 -9
- package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +1 -1
- package/browser/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/browser/Options/Classes/Particles/Move/Path/MovePath.js +2 -2
- package/browser/Options/Classes/Particles/Move/Spin.js +5 -3
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -10
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +12 -8
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -10
- package/browser/Options/Classes/Particles/ParticlesOptions.js +18 -23
- package/browser/Options/Classes/Particles/Shadow.js +1 -1
- package/browser/Options/Classes/Particles/Shape/Shape.js +10 -11
- package/browser/Options/Classes/Particles/Size/Size.js +12 -8
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -10
- package/browser/Options/Classes/Particles/Stroke.js +2 -2
- package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +1 -1
- package/browser/Options/Classes/Responsive.js +1 -1
- package/browser/Options/Classes/Theme/Theme.js +2 -2
- package/browser/Options/Classes/ValueWithRandom.js +6 -19
- package/browser/Utils/CanvasUtils.js +19 -55
- package/browser/Utils/ColorUtils.js +18 -20
- package/browser/Utils/EventDispatcher.js +7 -6
- package/browser/Utils/HslColorManager.js +4 -6
- package/browser/Utils/NumberUtils.js +42 -46
- package/browser/Utils/OptionsUtils.js +1 -1
- package/browser/Utils/RgbColorManager.js +3 -5
- package/browser/Utils/Utils.js +135 -64
- package/browser/bundle.js +4 -97
- package/browser/export-types.js +97 -0
- package/browser/exports.js +89 -0
- package/browser/index.js +8 -199
- package/browser/init.js +12 -0
- package/browser/package.json +1 -0
- package/cjs/Core/Canvas.js +278 -248
- package/cjs/Core/Container.js +104 -120
- package/cjs/Core/Engine.js +275 -0
- package/cjs/Core/Particle.js +173 -180
- package/cjs/Core/Particles.js +154 -149
- package/cjs/Core/Retina.js +20 -18
- package/cjs/Core/Utils/Circle.js +14 -10
- package/cjs/Core/Utils/Constants.js +5 -4
- package/cjs/Core/Utils/EventListeners.js +267 -243
- package/cjs/Core/Utils/InteractionManager.js +6 -16
- package/cjs/Core/Utils/QuadTree.js +20 -26
- package/cjs/Core/Utils/Rectangle.js +4 -4
- package/cjs/Core/Utils/Vector.js +2 -2
- package/cjs/Core/Utils/Vector3d.js +17 -9
- package/cjs/Options/Classes/AnimatableColor.js +6 -5
- package/cjs/Options/Classes/AnimationOptions.js +8 -7
- package/cjs/Options/Classes/Background/Background.js +3 -3
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +4 -3
- package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +3 -3
- package/cjs/Options/Classes/ColorAnimation.js +9 -5
- package/cjs/Options/Classes/HslAnimation.js +4 -4
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/cjs/Options/Classes/Interactivity/Events/Events.js +15 -34
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +2 -2
- package/cjs/Options/Classes/Interactivity/Interactivity.js +5 -12
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/cjs/Options/Classes/ManualParticle.js +7 -8
- package/cjs/Options/Classes/Options.js +41 -61
- package/cjs/Options/Classes/OptionsColor.js +3 -2
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +3 -3
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -2
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +11 -6
- package/cjs/Options/Classes/Particles/Move/Move.js +31 -61
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +3 -3
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +11 -22
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +3 -3
- package/cjs/Options/Classes/Particles/Move/MoveTrail.js +4 -10
- package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +2 -2
- package/cjs/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +4 -4
- package/cjs/Options/Classes/Particles/Move/Spin.js +6 -4
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +4 -11
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +13 -9
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -11
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +32 -37
- package/cjs/Options/Classes/Particles/Shadow.js +3 -3
- package/cjs/Options/Classes/Particles/Shape/Shape.js +10 -11
- package/cjs/Options/Classes/Particles/Size/Size.js +13 -9
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +2 -11
- package/cjs/Options/Classes/Particles/Stroke.js +5 -5
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +2 -2
- package/cjs/Options/Classes/Responsive.js +2 -2
- package/cjs/Options/Classes/Theme/Theme.js +4 -4
- package/cjs/Options/Classes/ValueWithRandom.js +10 -23
- package/cjs/Utils/CanvasUtils.js +23 -60
- package/cjs/Utils/ColorUtils.js +31 -33
- package/cjs/Utils/EventDispatcher.js +7 -6
- package/cjs/Utils/HslColorManager.js +11 -13
- package/cjs/Utils/NumberUtils.js +44 -48
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/cjs/Utils/RgbColorManager.js +7 -9
- package/cjs/Utils/Utils.js +157 -77
- package/cjs/bundle.js +4 -97
- package/cjs/export-types.js +113 -0
- package/cjs/exports.js +105 -0
- package/cjs/index.js +8 -199
- package/cjs/init.js +16 -0
- package/cjs/package.json +1 -0
- package/esm/Core/Canvas.js +273 -243
- package/esm/Core/Container.js +97 -113
- package/esm/Core/Engine.js +271 -0
- package/esm/Core/Particle.js +165 -172
- package/esm/Core/Particles.js +153 -148
- package/esm/Core/Retina.js +17 -15
- package/esm/Core/Utils/Circle.js +12 -8
- package/esm/Core/Utils/Constants.js +4 -3
- package/esm/Core/Utils/EventListeners.js +259 -235
- package/esm/Core/Utils/InteractionManager.js +6 -16
- package/esm/Core/Utils/QuadTree.js +17 -23
- package/esm/Core/Utils/Rectangle.js +2 -2
- package/esm/Core/Utils/Vector.js +1 -1
- package/esm/Core/Utils/Vector3d.js +17 -9
- package/esm/Options/Classes/AnimatableColor.js +4 -3
- package/esm/Options/Classes/AnimationOptions.js +5 -4
- package/esm/Options/Classes/Background/Background.js +1 -1
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
- package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +1 -1
- package/esm/Options/Classes/ColorAnimation.js +5 -1
- package/esm/Options/Classes/HslAnimation.js +1 -1
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/esm/Options/Classes/Interactivity/Events/Events.js +9 -28
- package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +1 -1
- package/esm/Options/Classes/Interactivity/Interactivity.js +3 -10
- package/esm/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/esm/Options/Classes/ManualParticle.js +6 -7
- package/esm/Options/Classes/Options.js +28 -48
- package/esm/Options/Classes/OptionsColor.js +3 -2
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +1 -1
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +1 -1
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +8 -3
- package/esm/Options/Classes/Particles/Move/Move.js +20 -50
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +10 -21
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveTrail.js +3 -9
- package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +1 -1
- package/esm/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/esm/Options/Classes/Particles/Move/Path/MovePath.js +2 -2
- package/esm/Options/Classes/Particles/Move/Spin.js +5 -3
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -10
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +12 -8
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -10
- package/esm/Options/Classes/Particles/ParticlesOptions.js +18 -23
- package/esm/Options/Classes/Particles/Shadow.js +1 -1
- package/esm/Options/Classes/Particles/Shape/Shape.js +10 -11
- package/esm/Options/Classes/Particles/Size/Size.js +12 -8
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -10
- package/esm/Options/Classes/Particles/Stroke.js +2 -2
- package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +1 -1
- package/esm/Options/Classes/Responsive.js +1 -1
- package/esm/Options/Classes/Theme/Theme.js +2 -2
- package/esm/Options/Classes/ValueWithRandom.js +6 -19
- package/esm/Utils/CanvasUtils.js +19 -55
- package/esm/Utils/ColorUtils.js +18 -20
- package/esm/Utils/EventDispatcher.js +7 -6
- package/esm/Utils/HslColorManager.js +4 -6
- package/esm/Utils/NumberUtils.js +42 -46
- package/esm/Utils/OptionsUtils.js +1 -1
- package/esm/Utils/RgbColorManager.js +3 -5
- package/esm/Utils/Utils.js +135 -64
- package/esm/bundle.js +4 -97
- package/esm/export-types.js +97 -0
- package/esm/exports.js +89 -0
- package/esm/index.js +8 -199
- package/esm/init.js +12 -0
- package/esm/package.json +1 -0
- package/package.json +21 -4
- package/report.html +4 -4
- package/scripts/install.js +90 -33
- package/tsparticles.engine.js +1832 -2007
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -10
- package/types/Core/Canvas.d.ts +25 -21
- package/types/Core/Container.d.ts +21 -25
- package/types/Core/Engine.d.ts +71 -0
- package/types/Core/Interfaces/Colors.d.ts +2 -2
- package/types/Core/Interfaces/IBubbleParticleData.d.ts +1 -1
- package/types/Core/Interfaces/ICircleBouncer.d.ts +2 -2
- package/types/Core/Interfaces/IColorManager.d.ts +1 -1
- package/types/Core/Interfaces/IContainerInteractivity.d.ts +1 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -6
- package/types/Core/Interfaces/ICoordinates.d.ts +3 -3
- package/types/Core/Interfaces/IDimension.d.ts +2 -2
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +6 -6
- package/types/Core/Interfaces/IExternalInteractor.d.ts +7 -7
- package/types/Core/Interfaces/IInteractor.d.ts +8 -8
- package/types/Core/Interfaces/ILoadParams.d.ts +2 -2
- package/types/Core/Interfaces/IMouseData.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +5 -4
- package/types/Core/Interfaces/IParticle.d.ts +11 -11
- package/types/Core/Interfaces/IParticleHslAnimation.d.ts +1 -1
- package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +1 -1
- package/types/Core/Interfaces/IParticleRoll.d.ts +1 -1
- package/types/Core/Interfaces/IParticleUpdater.d.ts +7 -9
- package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -1
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +3 -3
- package/types/Core/Interfaces/IPlugin.d.ts +7 -6
- package/types/Core/Interfaces/IPositionFromSizeParams.d.ts +2 -2
- package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -1
- package/types/Core/Interfaces/IShapeValues.d.ts +2 -2
- package/types/Core/Interfaces/ITrailFillData.d.ts +1 -1
- package/types/Core/Particle.d.ts +27 -27
- package/types/Core/Particles.d.ts +24 -21
- package/types/Core/Retina.d.ts +2 -2
- package/types/Core/Utils/Circle.d.ts +2 -2
- package/types/Core/Utils/Constants.d.ts +4 -3
- package/types/Core/Utils/EventListeners.d.ts +21 -19
- package/types/Core/Utils/ExternalInteractorBase.d.ts +5 -5
- package/types/Core/Utils/InteractionManager.d.ts +5 -5
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +5 -5
- package/types/Core/Utils/Point.d.ts +2 -2
- package/types/Core/Utils/QuadTree.d.ts +8 -11
- package/types/Core/Utils/Range.d.ts +1 -1
- package/types/Core/Utils/Rectangle.d.ts +3 -3
- package/types/Core/Utils/Vector.d.ts +2 -2
- package/types/Core/Utils/Vector3d.d.ts +3 -2
- package/types/Enums/Modes/{SizeMode.d.ts → PixelMode.d.ts} +1 -1
- package/types/Options/Classes/AnimatableColor.d.ts +6 -6
- package/types/Options/Classes/AnimationOptions.d.ts +7 -7
- package/types/Options/Classes/Background/Background.d.ts +4 -4
- package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +4 -4
- package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +4 -4
- package/types/Options/Classes/ColorAnimation.d.ts +5 -4
- package/types/Options/Classes/FullScreen/FullScreen.d.ts +3 -3
- package/types/Options/Classes/HslAnimation.d.ts +4 -4
- package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +5 -5
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +6 -12
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +8 -14
- package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +6 -6
- package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +3 -3
- package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +3 -3
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +8 -10
- package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +5 -5
- package/types/Options/Classes/ManualParticle.d.ts +5 -5
- package/types/Options/Classes/Options.d.ts +19 -26
- package/types/Options/Classes/OptionsColor.d.ts +5 -5
- package/types/Options/Classes/Particles/Bounce/ParticlesBounce.d.ts +4 -4
- package/types/Options/Classes/Particles/Bounce/ParticlesBounceFactor.d.ts +1 -1
- package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +9 -7
- package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +3 -3
- package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +3 -3
- package/types/Options/Classes/Particles/Move/Move.d.ts +15 -26
- package/types/Options/Classes/Particles/Move/MoveAngle.d.ts +4 -4
- package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +5 -9
- package/types/Options/Classes/Particles/Move/MoveCenter.d.ts +5 -5
- package/types/Options/Classes/Particles/Move/MoveGravity.d.ts +4 -4
- package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +4 -7
- package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +4 -4
- package/types/Options/Classes/Particles/Move/OutModes.d.ts +5 -5
- package/types/Options/Classes/Particles/Move/Path/MovePath.d.ts +5 -5
- package/types/Options/Classes/Particles/Move/Spin.d.ts +5 -5
- package/types/Options/Classes/Particles/Number/ParticlesDensity.d.ts +3 -9
- package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +4 -6
- package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +7 -7
- package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +5 -7
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +19 -19
- package/types/Options/Classes/Particles/Shadow.d.ts +5 -5
- package/types/Options/Classes/Particles/Shape/Shape.d.ts +5 -5
- package/types/Options/Classes/Particles/Size/Size.d.ts +7 -7
- package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +5 -7
- package/types/Options/Classes/Particles/Stroke.d.ts +5 -5
- package/types/Options/Classes/Particles/ZIndex/ZIndex.d.ts +4 -4
- package/types/Options/Classes/Random.d.ts +3 -3
- package/types/Options/Classes/Responsive.d.ts +7 -7
- package/types/Options/Classes/Theme/Theme.d.ts +6 -6
- package/types/Options/Classes/Theme/ThemeDefault.d.ts +4 -4
- package/types/Options/Classes/ValueWithRandom.d.ts +7 -11
- package/types/Options/Interfaces/Background/IBackground.d.ts +1 -1
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +2 -2
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +1 -1
- package/types/Options/Interfaces/IAnimatable.d.ts +1 -1
- package/types/Options/Interfaces/IAnimatableColor.d.ts +3 -3
- package/types/Options/Interfaces/IAnimation.d.ts +4 -4
- package/types/Options/Interfaces/IColorAnimation.d.ts +2 -2
- package/types/Options/Interfaces/IHslAnimation.d.ts +1 -1
- package/types/Options/Interfaces/IManualParticle.d.ts +3 -3
- package/types/Options/Interfaces/IOptionLoader.d.ts +1 -1
- package/types/Options/Interfaces/IOptions.d.ts +12 -15
- package/types/Options/Interfaces/IOptionsColor.d.ts +1 -1
- package/types/Options/Interfaces/IResponsive.d.ts +5 -4
- package/types/Options/Interfaces/IValueWithRandom.d.ts +3 -3
- package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +2 -2
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +3 -6
- package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +5 -8
- package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +3 -3
- package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +3 -4
- package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +1 -2
- package/types/Options/Interfaces/Particles/Bounce/IParticlesBounce.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +6 -4
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +15 -15
- package/types/Options/Interfaces/Particles/IShadow.d.ts +2 -2
- package/types/Options/Interfaces/Particles/IStroke.d.ts +5 -4
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +12 -17
- package/types/Options/Interfaces/Particles/Move/IMoveAngle.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +2 -4
- package/types/Options/Interfaces/Particles/Move/IMoveCenter.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Move/IMoveGravity.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +1 -3
- package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Move/IOutModes.d.ts +1 -1
- package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Move/Path/IMovePath.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Number/IParticlesDensity.d.ts +0 -3
- package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +1 -2
- package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +2 -3
- package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +2 -3
- package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Size/ISize.d.ts +2 -3
- package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +2 -3
- package/types/Options/Interfaces/Particles/ZIndex/IZIndex.d.ts +1 -1
- package/types/Options/Interfaces/Theme/ITheme.d.ts +4 -3
- package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +1 -1
- package/types/Types/CustomEventArgs.d.ts +1 -1
- package/types/Types/CustomEventListener.d.ts +1 -1
- package/types/Types/ExportResult.d.ts +5 -0
- package/types/Types/ISourceOptions.d.ts +2 -2
- package/types/Types/ParticlesGroups.d.ts +1 -1
- package/types/Types/RangeValue.d.ts +1 -1
- package/types/Types/ShapeData.d.ts +2 -2
- package/types/Types/ShapeDrawerFunctions.d.ts +3 -3
- package/types/Utils/CanvasUtils.d.ts +11 -14
- package/types/Utils/ColorUtils.d.ts +6 -6
- package/types/Utils/EventDispatcher.d.ts +2 -2
- package/types/Utils/HslColorManager.d.ts +2 -2
- package/types/Utils/NumberUtils.d.ts +8 -8
- package/types/Utils/OptionsUtils.d.ts +6 -6
- package/types/Utils/RgbColorManager.d.ts +2 -2
- package/types/Utils/Utils.d.ts +32 -14
- package/types/bundle.d.ts +2 -91
- package/types/export-types.d.ts +107 -0
- package/types/exports.d.ts +89 -0
- package/types/index.d.ts +3 -204
- package/types/init.d.ts +2 -0
- package/umd/Core/Canvas.js +279 -249
- package/umd/Core/Container.js +105 -121
- package/umd/Core/Engine.js +285 -0
- package/umd/Core/Particle.js +174 -181
- package/umd/Core/Particles.js +155 -150
- package/umd/Core/Retina.js +21 -19
- package/umd/Core/Utils/Circle.js +15 -11
- package/umd/Core/Utils/Constants.js +5 -4
- package/umd/Core/Utils/EventListeners.js +268 -244
- package/umd/Core/Utils/InteractionManager.js +6 -16
- package/umd/Core/Utils/QuadTree.js +21 -27
- package/umd/Core/Utils/Rectangle.js +5 -5
- package/umd/Core/Utils/Vector.js +3 -3
- package/umd/Core/Utils/Vector3d.js +18 -10
- package/umd/Options/Classes/AnimatableColor.js +7 -6
- package/umd/Options/Classes/AnimationOptions.js +9 -8
- package/umd/Options/Classes/Background/Background.js +4 -4
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +5 -4
- package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +4 -4
- package/umd/Options/Classes/ColorAnimation.js +10 -6
- package/umd/Options/Classes/HslAnimation.js +5 -5
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +1 -25
- package/umd/Options/Classes/Interactivity/Events/Events.js +16 -35
- package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +3 -3
- package/umd/Options/Classes/Interactivity/Interactivity.js +6 -13
- package/umd/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/umd/Options/Classes/ManualParticle.js +8 -9
- package/umd/Options/Classes/Options.js +42 -62
- package/umd/Options/Classes/OptionsColor.js +4 -3
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +4 -4
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +3 -3
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +12 -7
- package/umd/Options/Classes/Particles/Move/Move.js +32 -62
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +12 -23
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
- package/umd/Options/Classes/Particles/Move/MoveTrail.js +5 -11
- package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +3 -3
- package/umd/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -5
- package/umd/Options/Classes/Particles/Move/Spin.js +7 -5
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +5 -12
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +14 -10
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +3 -12
- package/umd/Options/Classes/Particles/ParticlesOptions.js +33 -38
- package/umd/Options/Classes/Particles/Shadow.js +4 -4
- package/umd/Options/Classes/Particles/Shape/Shape.js +11 -12
- package/umd/Options/Classes/Particles/Size/Size.js +14 -10
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +3 -12
- package/umd/Options/Classes/Particles/Stroke.js +6 -6
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -3
- package/umd/Options/Classes/Responsive.js +3 -3
- package/umd/Options/Classes/Theme/Theme.js +5 -5
- package/umd/Options/Classes/ValueWithRandom.js +11 -24
- package/umd/Utils/CanvasUtils.js +24 -61
- package/umd/Utils/ColorUtils.js +32 -34
- package/umd/Utils/EventDispatcher.js +7 -6
- package/umd/Utils/HslColorManager.js +12 -14
- package/umd/Utils/NumberUtils.js +45 -49
- package/umd/Utils/OptionsUtils.js +3 -3
- package/umd/Utils/RgbColorManager.js +8 -10
- package/umd/Utils/Utils.js +158 -78
- package/umd/bundle.js +5 -98
- package/umd/export-types.js +123 -0
- package/umd/exports.js +115 -0
- package/umd/index.js +9 -200
- package/umd/init.js +26 -0
- package/browser/Core/Utils/FrameManager.js +0 -42
- package/browser/Core/Utils/Plugins.js +0 -112
- package/browser/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
- package/browser/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
- package/browser/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
- package/browser/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
- package/browser/engine.js +0 -175
- package/cjs/Core/Utils/FrameManager.js +0 -46
- package/cjs/Core/Utils/Plugins.js +0 -116
- package/cjs/Enums/Modes/SizeMode.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IImageShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -17
- package/cjs/Options/Interfaces/Particles/Shape/IStarShape.js +0 -2
- package/cjs/engine.js +0 -179
- package/esm/Core/Interfaces/IParticleOverride.js +0 -1
- package/esm/Core/Interfaces/IParticlesMover.js +0 -1
- package/esm/Core/Utils/FrameManager.js +0 -42
- package/esm/Core/Utils/Plugins.js +0 -112
- package/esm/Enums/Modes/SizeMode.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
- package/esm/engine.js +0 -175
- package/types/Core/Interfaces/IParticleOverride.d.ts +0 -6
- package/types/Core/Interfaces/IParticlesMover.d.ts +0 -7
- package/types/Core/Utils/FrameManager.d.ts +0 -6
- package/types/Core/Utils/Plugins.d.ts +0 -51
- package/types/Options/Interfaces/Particles/Shape/ICharacterShape.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Shape/IImageShape.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Shape/IPolygonShape.d.ts +0 -5
- package/types/Options/Interfaces/Particles/Shape/IShapeValues.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Shape/IStarShape.d.ts +0 -6
- package/types/engine.d.ts +0 -39
- package/umd/Core/Utils/FrameManager.js +0 -56
- package/umd/Core/Utils/Plugins.js +0 -126
- package/umd/Enums/Modes/SizeMode.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IImageShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -27
- package/umd/Options/Interfaces/Particles/Shape/IStarShape.js +0 -12
- package/umd/engine.js +0 -189
- /package/browser/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
- /package/browser/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
- /package/cjs/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
- /package/cjs/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
- /package/{browser/Enums/Modes/SizeMode.js → esm/Enums/Modes/PixelMode.js} +0 -0
- /package/{browser/Options/Interfaces/Particles/Shape/ICharacterShape.js → esm/Types/ExportResult.js} +0 -0
- /package/umd/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
- /package/umd/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Utils/Utils", "./Constants"], factory);
|
|
7
|
+
define(["require", "exports", "../../Utils/Utils.js", "./Constants.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EventListeners = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
14
|
+
const Constants_js_1 = require("./Constants.js");
|
|
15
15
|
function manageListener(element, event, handler, add, options) {
|
|
16
16
|
if (add) {
|
|
17
17
|
let addOptions = { passive: true };
|
|
18
|
-
if (
|
|
18
|
+
if ((0, Utils_js_1.isBoolean)(options)) {
|
|
19
19
|
addOptions.capture = options;
|
|
20
20
|
}
|
|
21
21
|
else if (options !== undefined) {
|
|
@@ -31,278 +31,302 @@
|
|
|
31
31
|
class EventListeners {
|
|
32
32
|
constructor(container) {
|
|
33
33
|
this.container = container;
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
this._doMouseTouchClick = (e) => {
|
|
35
|
+
const container = this.container, options = container.actualOptions;
|
|
36
|
+
if (this._canPush) {
|
|
37
|
+
const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
|
|
38
|
+
if (!mousePos) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
mouseInteractivity.clickPosition = { ...mousePos };
|
|
42
|
+
mouseInteractivity.clickTime = new Date().getTime();
|
|
43
|
+
const onClick = options.interactivity.events.onClick;
|
|
44
|
+
(0, Utils_js_1.executeOnSingleOrMultiple)(onClick.mode, (mode) => this.container.handleClickMode(mode));
|
|
45
|
+
}
|
|
46
|
+
if (e.type === "touchend") {
|
|
47
|
+
setTimeout(() => this._mouseTouchFinish(), 500);
|
|
48
|
+
}
|
|
49
49
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
|
|
61
|
-
if (!mousePos) {
|
|
50
|
+
this._handleThemeChange = (e) => {
|
|
51
|
+
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);
|
|
52
|
+
if (theme && theme.default.auto) {
|
|
53
|
+
container.loadTheme(themeName);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
this._handleVisibilityChange = () => {
|
|
57
|
+
const container = this.container, options = container.actualOptions;
|
|
58
|
+
this._mouseTouchFinish();
|
|
59
|
+
if (!options.pauseOnBlur) {
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(0, Utils_1.executeOnSingleOrMultiple)(onClick.mode, (mode) => this._handleClickMode(mode));
|
|
68
|
-
}
|
|
69
|
-
if (e.type === "touchend") {
|
|
70
|
-
setTimeout(() => this._mouseTouchFinish(), 500);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
_handleClickMode(mode) {
|
|
74
|
-
this.container.handleClickMode(mode);
|
|
75
|
-
}
|
|
76
|
-
_handleThemeChange(e) {
|
|
77
|
-
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);
|
|
78
|
-
if (theme && theme.default.auto) {
|
|
79
|
-
container.loadTheme(themeName);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
_handleVisibilityChange() {
|
|
83
|
-
const container = this.container, options = container.actualOptions;
|
|
84
|
-
this._mouseTouchFinish();
|
|
85
|
-
if (!options.pauseOnBlur) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
|
|
89
|
-
if (container.pageHidden) {
|
|
90
|
-
container.pause();
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
if (container.getAnimationStatus()) {
|
|
94
|
-
container.play(true);
|
|
62
|
+
if (document && document.hidden) {
|
|
63
|
+
container.pageHidden = true;
|
|
64
|
+
container.pause();
|
|
95
65
|
}
|
|
96
66
|
else {
|
|
97
|
-
container.
|
|
67
|
+
container.pageHidden = false;
|
|
68
|
+
if (container.getAnimationStatus()) {
|
|
69
|
+
container.play(true);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
container.draw(true);
|
|
73
|
+
}
|
|
98
74
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
const html = interactivityEl;
|
|
128
|
-
if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) {
|
|
129
|
-
manageListener(interactivityEl, Constants_1.mouseMoveEvent, handlers.mouseMove, add);
|
|
130
|
-
manageListener(interactivityEl, Constants_1.touchStartEvent, handlers.touchStart, add);
|
|
131
|
-
manageListener(interactivityEl, Constants_1.touchMoveEvent, handlers.touchMove, add);
|
|
75
|
+
};
|
|
76
|
+
this._handleWindowResize = async () => {
|
|
77
|
+
if (this._resizeTimeout) {
|
|
78
|
+
clearTimeout(this._resizeTimeout);
|
|
79
|
+
delete this._resizeTimeout;
|
|
80
|
+
}
|
|
81
|
+
this._resizeTimeout = setTimeout(async () => {
|
|
82
|
+
const canvas = this.container.canvas;
|
|
83
|
+
canvas && (await canvas.windowResize());
|
|
84
|
+
}, this.container.actualOptions.interactivity.events.resize.delay * 1000);
|
|
85
|
+
};
|
|
86
|
+
this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
|
|
87
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
88
|
+
const interactivityEl = container.interactivity.element;
|
|
89
|
+
if (!interactivityEl) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const html = interactivityEl, canvasEl = container.canvas.element;
|
|
93
|
+
if (canvasEl) {
|
|
94
|
+
canvasEl.style.pointerEvents = html === canvasEl ? "initial" : "none";
|
|
95
|
+
}
|
|
96
|
+
if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
manageListener(interactivityEl, Constants_js_1.mouseMoveEvent, handlers.mouseMove, add);
|
|
100
|
+
manageListener(interactivityEl, Constants_js_1.touchStartEvent, handlers.touchStart, add);
|
|
101
|
+
manageListener(interactivityEl, Constants_js_1.touchMoveEvent, handlers.touchMove, add);
|
|
132
102
|
if (!options.interactivity.events.onClick.enable) {
|
|
133
|
-
manageListener(interactivityEl,
|
|
103
|
+
manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEnd, add);
|
|
134
104
|
}
|
|
135
105
|
else {
|
|
136
|
-
manageListener(interactivityEl,
|
|
137
|
-
manageListener(interactivityEl,
|
|
138
|
-
manageListener(interactivityEl,
|
|
106
|
+
manageListener(interactivityEl, Constants_js_1.touchEndEvent, handlers.touchEndClick, add);
|
|
107
|
+
manageListener(interactivityEl, Constants_js_1.mouseUpEvent, handlers.mouseUp, add);
|
|
108
|
+
manageListener(interactivityEl, Constants_js_1.mouseDownEvent, handlers.mouseDown, add);
|
|
139
109
|
}
|
|
140
110
|
manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
|
|
141
|
-
manageListener(interactivityEl,
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
container.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
111
|
+
manageListener(interactivityEl, Constants_js_1.touchCancelEvent, handlers.touchCancel, add);
|
|
112
|
+
};
|
|
113
|
+
this._manageListeners = (add) => {
|
|
114
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
|
|
115
|
+
let mouseLeaveTmpEvent = Constants_js_1.mouseLeaveEvent;
|
|
116
|
+
if (detectType === "window") {
|
|
117
|
+
container.interactivity.element = window;
|
|
118
|
+
mouseLeaveTmpEvent = Constants_js_1.mouseOutEvent;
|
|
119
|
+
}
|
|
120
|
+
else if (detectType === "parent" && canvasEl) {
|
|
121
|
+
container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
container.interactivity.element = canvasEl;
|
|
125
|
+
}
|
|
126
|
+
this._manageMediaMatch(add);
|
|
127
|
+
this._manageResize(add);
|
|
128
|
+
this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
|
|
129
|
+
if (document) {
|
|
130
|
+
manageListener(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
this._manageMediaMatch = (add) => {
|
|
134
|
+
const handlers = this._handlers, mediaMatch = (0, Utils_js_1.safeMatchMedia)("(prefers-color-scheme: dark)");
|
|
135
|
+
if (!mediaMatch) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
139
|
+
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (mediaMatch.addListener === undefined) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
163
145
|
if (add) {
|
|
164
146
|
mediaMatch.addListener(handlers.oldThemeChange);
|
|
165
147
|
}
|
|
166
148
|
else {
|
|
167
149
|
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
168
150
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (typeof ResizeObserver === "undefined") {
|
|
177
|
-
manageListener(window, Constants_1.resizeEvent, handlers.resize, add);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (this.resizeObserver && !add) {
|
|
181
|
-
if (container.canvas.element) {
|
|
182
|
-
this.resizeObserver.unobserve(container.canvas.element);
|
|
151
|
+
};
|
|
152
|
+
this._manageResize = (add) => {
|
|
153
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
154
|
+
if (!options.interactivity.events.resize) {
|
|
155
|
+
return;
|
|
183
156
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
|
|
157
|
+
if (typeof ResizeObserver === "undefined") {
|
|
158
|
+
manageListener(window, Constants_js_1.resizeEvent, handlers.resize, add);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const canvasEl = container.canvas.element;
|
|
162
|
+
if (this._resizeObserver && !add) {
|
|
163
|
+
if (canvasEl) {
|
|
164
|
+
this._resizeObserver.unobserve(canvasEl);
|
|
192
165
|
}
|
|
193
|
-
this.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
166
|
+
this._resizeObserver.disconnect();
|
|
167
|
+
delete this._resizeObserver;
|
|
168
|
+
}
|
|
169
|
+
else if (!this._resizeObserver && add && canvasEl) {
|
|
170
|
+
this._resizeObserver = new ResizeObserver(async (entries) => {
|
|
171
|
+
const entry = entries.find((e) => e.target === canvasEl);
|
|
172
|
+
if (!entry) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
await this._handleWindowResize();
|
|
176
|
+
});
|
|
177
|
+
this._resizeObserver.observe(canvasEl);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
this._mouseDown = () => {
|
|
181
|
+
const { interactivity } = this.container;
|
|
182
|
+
if (!interactivity) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const { mouse } = interactivity;
|
|
208
186
|
mouse.clicking = true;
|
|
209
187
|
mouse.downPosition = mouse.position;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
for (const [, plugin] of container.plugins) {
|
|
221
|
-
if (!plugin.clickPositionValid) {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
handled = plugin.clickPositionValid(mousePosition);
|
|
225
|
-
if (handled) {
|
|
226
|
-
break;
|
|
188
|
+
};
|
|
189
|
+
this._mouseTouchClick = (e) => {
|
|
190
|
+
const container = this.container, options = container.actualOptions, { mouse } = container.interactivity;
|
|
191
|
+
mouse.inside = true;
|
|
192
|
+
let handled = false;
|
|
193
|
+
const mousePosition = mouse.position;
|
|
194
|
+
if (!mousePosition || !options.interactivity.events.onClick.enable) {
|
|
195
|
+
return;
|
|
227
196
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
mouse.clicking = false;
|
|
233
|
-
}
|
|
234
|
-
_mouseTouchFinish() {
|
|
235
|
-
const interactivity = this.container.interactivity;
|
|
236
|
-
if (!interactivity) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const mouse = interactivity.mouse;
|
|
240
|
-
delete mouse.position;
|
|
241
|
-
delete mouse.clickPosition;
|
|
242
|
-
delete mouse.downPosition;
|
|
243
|
-
interactivity.status = Constants_1.mouseLeaveEvent;
|
|
244
|
-
mouse.inside = false;
|
|
245
|
-
mouse.clicking = false;
|
|
246
|
-
}
|
|
247
|
-
_mouseTouchMove(e) {
|
|
248
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
249
|
-
const container = this.container, options = container.actualOptions;
|
|
250
|
-
if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
container.interactivity.mouse.inside = true;
|
|
254
|
-
let pos;
|
|
255
|
-
const canvas = container.canvas.element;
|
|
256
|
-
if (e.type.startsWith("pointer")) {
|
|
257
|
-
this.canPush = true;
|
|
258
|
-
const mouseEvent = e;
|
|
259
|
-
if (container.interactivity.element === window) {
|
|
260
|
-
if (canvas) {
|
|
261
|
-
const clientRect = canvas.getBoundingClientRect();
|
|
262
|
-
pos = {
|
|
263
|
-
x: mouseEvent.clientX - clientRect.left,
|
|
264
|
-
y: mouseEvent.clientY - clientRect.top,
|
|
265
|
-
};
|
|
197
|
+
for (const [, plugin] of container.plugins) {
|
|
198
|
+
if (!plugin.clickPositionValid) {
|
|
199
|
+
continue;
|
|
266
200
|
}
|
|
201
|
+
handled = plugin.clickPositionValid(mousePosition);
|
|
202
|
+
if (handled) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (!handled) {
|
|
207
|
+
this._doMouseTouchClick(e);
|
|
208
|
+
}
|
|
209
|
+
mouse.clicking = false;
|
|
210
|
+
};
|
|
211
|
+
this._mouseTouchFinish = () => {
|
|
212
|
+
const interactivity = this.container.interactivity;
|
|
213
|
+
if (!interactivity) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const mouse = interactivity.mouse;
|
|
217
|
+
delete mouse.position;
|
|
218
|
+
delete mouse.clickPosition;
|
|
219
|
+
delete mouse.downPosition;
|
|
220
|
+
interactivity.status = Constants_js_1.mouseLeaveEvent;
|
|
221
|
+
mouse.inside = false;
|
|
222
|
+
mouse.clicking = false;
|
|
223
|
+
};
|
|
224
|
+
this._mouseTouchMove = (e) => {
|
|
225
|
+
const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
|
|
226
|
+
if (!interactivity || !interactivity.element) {
|
|
227
|
+
return;
|
|
267
228
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
229
|
+
interactivity.mouse.inside = true;
|
|
230
|
+
let pos;
|
|
231
|
+
if (e.type.startsWith("pointer")) {
|
|
232
|
+
this._canPush = true;
|
|
233
|
+
const mouseEvent = e;
|
|
234
|
+
if (interactivity.element === window) {
|
|
235
|
+
if (canvasEl) {
|
|
236
|
+
const clientRect = canvasEl.getBoundingClientRect();
|
|
237
|
+
pos = {
|
|
238
|
+
x: mouseEvent.clientX - clientRect.left,
|
|
239
|
+
y: mouseEvent.clientY - clientRect.top,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (options.interactivity.detectsOn === "parent") {
|
|
244
|
+
const source = mouseEvent.target, target = mouseEvent.currentTarget;
|
|
245
|
+
if (source && target && canvasEl) {
|
|
246
|
+
const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
|
|
247
|
+
pos = {
|
|
248
|
+
x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
249
|
+
y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
pos = {
|
|
254
|
+
x: mouseEvent.offsetX ?? mouseEvent.clientX,
|
|
255
|
+
y: mouseEvent.offsetY ?? mouseEvent.clientY,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else if (mouseEvent.target === canvasEl) {
|
|
272
260
|
pos = {
|
|
273
|
-
x: mouseEvent.offsetX
|
|
274
|
-
y: mouseEvent.offsetY
|
|
261
|
+
x: mouseEvent.offsetX ?? mouseEvent.clientX,
|
|
262
|
+
y: mouseEvent.offsetY ?? mouseEvent.clientY,
|
|
275
263
|
};
|
|
276
264
|
}
|
|
277
|
-
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
this._canPush = e.type !== "touchmove";
|
|
268
|
+
if (canvasEl) {
|
|
269
|
+
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - 1], canvasRect = canvasEl.getBoundingClientRect();
|
|
278
270
|
pos = {
|
|
279
|
-
x:
|
|
280
|
-
y:
|
|
271
|
+
x: lastTouch.clientX - (canvasRect.left ?? 0),
|
|
272
|
+
y: lastTouch.clientY - (canvasRect.top ?? 0),
|
|
281
273
|
};
|
|
282
274
|
}
|
|
283
275
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
};
|
|
276
|
+
const pxRatio = container.retina.pixelRatio;
|
|
277
|
+
if (pos) {
|
|
278
|
+
pos.x *= pxRatio;
|
|
279
|
+
pos.y *= pxRatio;
|
|
289
280
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
281
|
+
interactivity.mouse.position = pos;
|
|
282
|
+
interactivity.status = Constants_js_1.mouseMoveEvent;
|
|
283
|
+
};
|
|
284
|
+
this._touchEnd = (e) => {
|
|
285
|
+
const evt = e, touches = Array.from(evt.changedTouches);
|
|
286
|
+
for (const touch of touches) {
|
|
287
|
+
this._touches.delete(touch.identifier);
|
|
288
|
+
}
|
|
289
|
+
this._mouseTouchFinish();
|
|
290
|
+
};
|
|
291
|
+
this._touchEndClick = (e) => {
|
|
292
|
+
const evt = e, touches = Array.from(evt.changedTouches);
|
|
293
|
+
for (const touch of touches) {
|
|
294
|
+
this._touches.delete(touch.identifier);
|
|
295
|
+
}
|
|
296
|
+
this._mouseTouchClick(e);
|
|
297
|
+
};
|
|
298
|
+
this._touchStart = (e) => {
|
|
299
|
+
const evt = e, touches = Array.from(evt.changedTouches);
|
|
300
|
+
for (const touch of touches) {
|
|
301
|
+
this._touches.set(touch.identifier, performance.now());
|
|
302
|
+
}
|
|
303
|
+
this._mouseTouchMove(e);
|
|
304
|
+
};
|
|
305
|
+
this._canPush = true;
|
|
306
|
+
this._touches = new Map();
|
|
307
|
+
this._handlers = {
|
|
308
|
+
mouseDown: () => this._mouseDown(),
|
|
309
|
+
mouseLeave: () => this._mouseTouchFinish(),
|
|
310
|
+
mouseMove: (e) => this._mouseTouchMove(e),
|
|
311
|
+
mouseUp: (e) => this._mouseTouchClick(e),
|
|
312
|
+
touchStart: (e) => this._touchStart(e),
|
|
313
|
+
touchMove: (e) => this._mouseTouchMove(e),
|
|
314
|
+
touchEnd: (e) => this._touchEnd(e),
|
|
315
|
+
touchCancel: (e) => this._touchEnd(e),
|
|
316
|
+
touchEndClick: (e) => this._touchEndClick(e),
|
|
317
|
+
visibilityChange: () => this._handleVisibilityChange(),
|
|
318
|
+
themeChange: (e) => this._handleThemeChange(e),
|
|
319
|
+
oldThemeChange: (e) => this._handleThemeChange(e),
|
|
320
|
+
resize: () => {
|
|
321
|
+
this._handleWindowResize();
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
addListeners() {
|
|
326
|
+
this._manageListeners(true);
|
|
327
|
+
}
|
|
328
|
+
removeListeners() {
|
|
329
|
+
this._manageListeners(false);
|
|
306
330
|
}
|
|
307
331
|
}
|
|
308
332
|
exports.EventListeners = EventListeners;
|
|
@@ -14,22 +14,18 @@
|
|
|
14
14
|
constructor(engine, container) {
|
|
15
15
|
this.container = container;
|
|
16
16
|
this._engine = engine;
|
|
17
|
-
this._interactors =
|
|
17
|
+
this._interactors = engine.getInteractors(this.container, true);
|
|
18
18
|
this._externalInteractors = [];
|
|
19
19
|
this._particleInteractors = [];
|
|
20
20
|
}
|
|
21
21
|
async externalInteract(delta) {
|
|
22
22
|
for (const interactor of this._externalInteractors) {
|
|
23
|
-
|
|
24
|
-
await interactor.interact(delta);
|
|
25
|
-
}
|
|
23
|
+
interactor.isEnabled() && (await interactor.interact(delta));
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
handleClickMode(mode) {
|
|
29
27
|
for (const interactor of this._externalInteractors) {
|
|
30
|
-
|
|
31
|
-
interactor.handleClickMode(mode);
|
|
32
|
-
}
|
|
28
|
+
interactor.handleClickMode && interactor.handleClickMode(mode);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
init() {
|
|
@@ -52,21 +48,15 @@
|
|
|
52
48
|
interactor.clear(particle, delta);
|
|
53
49
|
}
|
|
54
50
|
for (const interactor of this._particleInteractors) {
|
|
55
|
-
|
|
56
|
-
await interactor.interact(particle, delta);
|
|
57
|
-
}
|
|
51
|
+
interactor.isEnabled(particle) && (await interactor.interact(particle, delta));
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
async reset(particle) {
|
|
61
55
|
for (const interactor of this._externalInteractors) {
|
|
62
|
-
|
|
63
|
-
await interactor.reset(particle);
|
|
64
|
-
}
|
|
56
|
+
interactor.isEnabled() && interactor.reset(particle);
|
|
65
57
|
}
|
|
66
58
|
for (const interactor of this._particleInteractors) {
|
|
67
|
-
|
|
68
|
-
await interactor.reset(particle);
|
|
69
|
-
}
|
|
59
|
+
interactor.isEnabled(particle) && interactor.reset(particle);
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
62
|
}
|