@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.
Files changed (498) hide show
  1. package/README.md +244 -188
  2. package/browser/Core/Canvas.js +273 -243
  3. package/browser/Core/Container.js +97 -113
  4. package/browser/Core/Engine.js +271 -0
  5. package/browser/Core/Particle.js +165 -172
  6. package/browser/Core/Particles.js +153 -148
  7. package/browser/Core/Retina.js +17 -15
  8. package/browser/Core/Utils/Circle.js +12 -8
  9. package/browser/Core/Utils/Constants.js +4 -3
  10. package/browser/Core/Utils/EventListeners.js +259 -235
  11. package/browser/Core/Utils/InteractionManager.js +6 -16
  12. package/browser/Core/Utils/QuadTree.js +17 -23
  13. package/browser/Core/Utils/Rectangle.js +2 -2
  14. package/browser/Core/Utils/Vector.js +1 -1
  15. package/browser/Core/Utils/Vector3d.js +17 -9
  16. package/browser/Options/Classes/AnimatableColor.js +4 -3
  17. package/browser/Options/Classes/AnimationOptions.js +5 -4
  18. package/browser/Options/Classes/Background/Background.js +1 -1
  19. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
  20. package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +1 -1
  21. package/browser/Options/Classes/ColorAnimation.js +5 -1
  22. package/browser/Options/Classes/HslAnimation.js +1 -1
  23. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  24. package/browser/Options/Classes/Interactivity/Events/Events.js +9 -28
  25. package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +1 -1
  26. package/browser/Options/Classes/Interactivity/Interactivity.js +3 -10
  27. package/browser/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  28. package/browser/Options/Classes/ManualParticle.js +6 -7
  29. package/browser/Options/Classes/Options.js +28 -48
  30. package/browser/Options/Classes/OptionsColor.js +3 -2
  31. package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +1 -1
  32. package/browser/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +1 -1
  33. package/browser/Options/Classes/Particles/Collisions/Collisions.js +8 -3
  34. package/browser/Options/Classes/Particles/Move/Move.js +20 -50
  35. package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  36. package/browser/Options/Classes/Particles/Move/MoveAttract.js +10 -21
  37. package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  38. package/browser/Options/Classes/Particles/Move/MoveTrail.js +3 -9
  39. package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +1 -1
  40. package/browser/Options/Classes/Particles/Move/OutModes.js +4 -5
  41. package/browser/Options/Classes/Particles/Move/Path/MovePath.js +2 -2
  42. package/browser/Options/Classes/Particles/Move/Spin.js +5 -3
  43. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  44. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -10
  45. package/browser/Options/Classes/Particles/Opacity/Opacity.js +12 -8
  46. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -10
  47. package/browser/Options/Classes/Particles/ParticlesOptions.js +18 -23
  48. package/browser/Options/Classes/Particles/Shadow.js +1 -1
  49. package/browser/Options/Classes/Particles/Shape/Shape.js +10 -11
  50. package/browser/Options/Classes/Particles/Size/Size.js +12 -8
  51. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -10
  52. package/browser/Options/Classes/Particles/Stroke.js +2 -2
  53. package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +1 -1
  54. package/browser/Options/Classes/Responsive.js +1 -1
  55. package/browser/Options/Classes/Theme/Theme.js +2 -2
  56. package/browser/Options/Classes/ValueWithRandom.js +6 -19
  57. package/browser/Utils/CanvasUtils.js +19 -55
  58. package/browser/Utils/ColorUtils.js +18 -20
  59. package/browser/Utils/EventDispatcher.js +7 -6
  60. package/browser/Utils/HslColorManager.js +4 -6
  61. package/browser/Utils/NumberUtils.js +42 -46
  62. package/browser/Utils/OptionsUtils.js +1 -1
  63. package/browser/Utils/RgbColorManager.js +3 -5
  64. package/browser/Utils/Utils.js +135 -64
  65. package/browser/bundle.js +4 -97
  66. package/browser/export-types.js +97 -0
  67. package/browser/exports.js +89 -0
  68. package/browser/index.js +8 -199
  69. package/browser/init.js +12 -0
  70. package/browser/package.json +1 -0
  71. package/cjs/Core/Canvas.js +278 -248
  72. package/cjs/Core/Container.js +104 -120
  73. package/cjs/Core/Engine.js +275 -0
  74. package/cjs/Core/Particle.js +173 -180
  75. package/cjs/Core/Particles.js +154 -149
  76. package/cjs/Core/Retina.js +20 -18
  77. package/cjs/Core/Utils/Circle.js +14 -10
  78. package/cjs/Core/Utils/Constants.js +5 -4
  79. package/cjs/Core/Utils/EventListeners.js +267 -243
  80. package/cjs/Core/Utils/InteractionManager.js +6 -16
  81. package/cjs/Core/Utils/QuadTree.js +20 -26
  82. package/cjs/Core/Utils/Rectangle.js +4 -4
  83. package/cjs/Core/Utils/Vector.js +2 -2
  84. package/cjs/Core/Utils/Vector3d.js +17 -9
  85. package/cjs/Options/Classes/AnimatableColor.js +6 -5
  86. package/cjs/Options/Classes/AnimationOptions.js +8 -7
  87. package/cjs/Options/Classes/Background/Background.js +3 -3
  88. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +4 -3
  89. package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +3 -3
  90. package/cjs/Options/Classes/ColorAnimation.js +9 -5
  91. package/cjs/Options/Classes/HslAnimation.js +4 -4
  92. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  93. package/cjs/Options/Classes/Interactivity/Events/Events.js +15 -34
  94. package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +2 -2
  95. package/cjs/Options/Classes/Interactivity/Interactivity.js +5 -12
  96. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  97. package/cjs/Options/Classes/ManualParticle.js +7 -8
  98. package/cjs/Options/Classes/Options.js +41 -61
  99. package/cjs/Options/Classes/OptionsColor.js +3 -2
  100. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +3 -3
  101. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -2
  102. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +11 -6
  103. package/cjs/Options/Classes/Particles/Move/Move.js +31 -61
  104. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +3 -3
  105. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +11 -22
  106. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +3 -3
  107. package/cjs/Options/Classes/Particles/Move/MoveTrail.js +4 -10
  108. package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +2 -2
  109. package/cjs/Options/Classes/Particles/Move/OutModes.js +4 -5
  110. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +4 -4
  111. package/cjs/Options/Classes/Particles/Move/Spin.js +6 -4
  112. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  113. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +4 -11
  114. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +13 -9
  115. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -11
  116. package/cjs/Options/Classes/Particles/ParticlesOptions.js +32 -37
  117. package/cjs/Options/Classes/Particles/Shadow.js +3 -3
  118. package/cjs/Options/Classes/Particles/Shape/Shape.js +10 -11
  119. package/cjs/Options/Classes/Particles/Size/Size.js +13 -9
  120. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +2 -11
  121. package/cjs/Options/Classes/Particles/Stroke.js +5 -5
  122. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +2 -2
  123. package/cjs/Options/Classes/Responsive.js +2 -2
  124. package/cjs/Options/Classes/Theme/Theme.js +4 -4
  125. package/cjs/Options/Classes/ValueWithRandom.js +10 -23
  126. package/cjs/Utils/CanvasUtils.js +23 -60
  127. package/cjs/Utils/ColorUtils.js +31 -33
  128. package/cjs/Utils/EventDispatcher.js +7 -6
  129. package/cjs/Utils/HslColorManager.js +11 -13
  130. package/cjs/Utils/NumberUtils.js +44 -48
  131. package/cjs/Utils/OptionsUtils.js +2 -2
  132. package/cjs/Utils/RgbColorManager.js +7 -9
  133. package/cjs/Utils/Utils.js +157 -77
  134. package/cjs/bundle.js +4 -97
  135. package/cjs/export-types.js +113 -0
  136. package/cjs/exports.js +105 -0
  137. package/cjs/index.js +8 -199
  138. package/cjs/init.js +16 -0
  139. package/cjs/package.json +1 -0
  140. package/esm/Core/Canvas.js +273 -243
  141. package/esm/Core/Container.js +97 -113
  142. package/esm/Core/Engine.js +271 -0
  143. package/esm/Core/Particle.js +165 -172
  144. package/esm/Core/Particles.js +153 -148
  145. package/esm/Core/Retina.js +17 -15
  146. package/esm/Core/Utils/Circle.js +12 -8
  147. package/esm/Core/Utils/Constants.js +4 -3
  148. package/esm/Core/Utils/EventListeners.js +259 -235
  149. package/esm/Core/Utils/InteractionManager.js +6 -16
  150. package/esm/Core/Utils/QuadTree.js +17 -23
  151. package/esm/Core/Utils/Rectangle.js +2 -2
  152. package/esm/Core/Utils/Vector.js +1 -1
  153. package/esm/Core/Utils/Vector3d.js +17 -9
  154. package/esm/Options/Classes/AnimatableColor.js +4 -3
  155. package/esm/Options/Classes/AnimationOptions.js +5 -4
  156. package/esm/Options/Classes/Background/Background.js +1 -1
  157. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
  158. package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +1 -1
  159. package/esm/Options/Classes/ColorAnimation.js +5 -1
  160. package/esm/Options/Classes/HslAnimation.js +1 -1
  161. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  162. package/esm/Options/Classes/Interactivity/Events/Events.js +9 -28
  163. package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +1 -1
  164. package/esm/Options/Classes/Interactivity/Interactivity.js +3 -10
  165. package/esm/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  166. package/esm/Options/Classes/ManualParticle.js +6 -7
  167. package/esm/Options/Classes/Options.js +28 -48
  168. package/esm/Options/Classes/OptionsColor.js +3 -2
  169. package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +1 -1
  170. package/esm/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +1 -1
  171. package/esm/Options/Classes/Particles/Collisions/Collisions.js +8 -3
  172. package/esm/Options/Classes/Particles/Move/Move.js +20 -50
  173. package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  174. package/esm/Options/Classes/Particles/Move/MoveAttract.js +10 -21
  175. package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  176. package/esm/Options/Classes/Particles/Move/MoveTrail.js +3 -9
  177. package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +1 -1
  178. package/esm/Options/Classes/Particles/Move/OutModes.js +4 -5
  179. package/esm/Options/Classes/Particles/Move/Path/MovePath.js +2 -2
  180. package/esm/Options/Classes/Particles/Move/Spin.js +5 -3
  181. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  182. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -10
  183. package/esm/Options/Classes/Particles/Opacity/Opacity.js +12 -8
  184. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -10
  185. package/esm/Options/Classes/Particles/ParticlesOptions.js +18 -23
  186. package/esm/Options/Classes/Particles/Shadow.js +1 -1
  187. package/esm/Options/Classes/Particles/Shape/Shape.js +10 -11
  188. package/esm/Options/Classes/Particles/Size/Size.js +12 -8
  189. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -10
  190. package/esm/Options/Classes/Particles/Stroke.js +2 -2
  191. package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +1 -1
  192. package/esm/Options/Classes/Responsive.js +1 -1
  193. package/esm/Options/Classes/Theme/Theme.js +2 -2
  194. package/esm/Options/Classes/ValueWithRandom.js +6 -19
  195. package/esm/Utils/CanvasUtils.js +19 -55
  196. package/esm/Utils/ColorUtils.js +18 -20
  197. package/esm/Utils/EventDispatcher.js +7 -6
  198. package/esm/Utils/HslColorManager.js +4 -6
  199. package/esm/Utils/NumberUtils.js +42 -46
  200. package/esm/Utils/OptionsUtils.js +1 -1
  201. package/esm/Utils/RgbColorManager.js +3 -5
  202. package/esm/Utils/Utils.js +135 -64
  203. package/esm/bundle.js +4 -97
  204. package/esm/export-types.js +97 -0
  205. package/esm/exports.js +89 -0
  206. package/esm/index.js +8 -199
  207. package/esm/init.js +12 -0
  208. package/esm/package.json +1 -0
  209. package/package.json +21 -4
  210. package/report.html +4 -4
  211. package/scripts/install.js +90 -33
  212. package/tsparticles.engine.js +1832 -2007
  213. package/tsparticles.engine.min.js +1 -1
  214. package/tsparticles.engine.min.js.LICENSE.txt +1 -10
  215. package/types/Core/Canvas.d.ts +25 -21
  216. package/types/Core/Container.d.ts +21 -25
  217. package/types/Core/Engine.d.ts +71 -0
  218. package/types/Core/Interfaces/Colors.d.ts +2 -2
  219. package/types/Core/Interfaces/IBubbleParticleData.d.ts +1 -1
  220. package/types/Core/Interfaces/ICircleBouncer.d.ts +2 -2
  221. package/types/Core/Interfaces/IColorManager.d.ts +1 -1
  222. package/types/Core/Interfaces/IContainerInteractivity.d.ts +1 -1
  223. package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -6
  224. package/types/Core/Interfaces/ICoordinates.d.ts +3 -3
  225. package/types/Core/Interfaces/IDimension.d.ts +2 -2
  226. package/types/Core/Interfaces/IDrawParticleParams.d.ts +6 -6
  227. package/types/Core/Interfaces/IExternalInteractor.d.ts +7 -7
  228. package/types/Core/Interfaces/IInteractor.d.ts +8 -8
  229. package/types/Core/Interfaces/ILoadParams.d.ts +2 -2
  230. package/types/Core/Interfaces/IMouseData.d.ts +1 -1
  231. package/types/Core/Interfaces/IMovePathGenerator.d.ts +5 -4
  232. package/types/Core/Interfaces/IParticle.d.ts +11 -11
  233. package/types/Core/Interfaces/IParticleHslAnimation.d.ts +1 -1
  234. package/types/Core/Interfaces/IParticleMover.d.ts +2 -2
  235. package/types/Core/Interfaces/IParticleRetinaProps.d.ts +1 -1
  236. package/types/Core/Interfaces/IParticleRoll.d.ts +1 -1
  237. package/types/Core/Interfaces/IParticleUpdater.d.ts +7 -9
  238. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -1
  239. package/types/Core/Interfaces/IParticlesInteractor.d.ts +3 -3
  240. package/types/Core/Interfaces/IPlugin.d.ts +7 -6
  241. package/types/Core/Interfaces/IPositionFromSizeParams.d.ts +2 -2
  242. package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -1
  243. package/types/Core/Interfaces/IShapeValues.d.ts +2 -2
  244. package/types/Core/Interfaces/ITrailFillData.d.ts +1 -1
  245. package/types/Core/Particle.d.ts +27 -27
  246. package/types/Core/Particles.d.ts +24 -21
  247. package/types/Core/Retina.d.ts +2 -2
  248. package/types/Core/Utils/Circle.d.ts +2 -2
  249. package/types/Core/Utils/Constants.d.ts +4 -3
  250. package/types/Core/Utils/EventListeners.d.ts +21 -19
  251. package/types/Core/Utils/ExternalInteractorBase.d.ts +5 -5
  252. package/types/Core/Utils/InteractionManager.d.ts +5 -5
  253. package/types/Core/Utils/ParticlesInteractorBase.d.ts +5 -5
  254. package/types/Core/Utils/Point.d.ts +2 -2
  255. package/types/Core/Utils/QuadTree.d.ts +8 -11
  256. package/types/Core/Utils/Range.d.ts +1 -1
  257. package/types/Core/Utils/Rectangle.d.ts +3 -3
  258. package/types/Core/Utils/Vector.d.ts +2 -2
  259. package/types/Core/Utils/Vector3d.d.ts +3 -2
  260. package/types/Enums/Modes/{SizeMode.d.ts → PixelMode.d.ts} +1 -1
  261. package/types/Options/Classes/AnimatableColor.d.ts +6 -6
  262. package/types/Options/Classes/AnimationOptions.d.ts +7 -7
  263. package/types/Options/Classes/Background/Background.d.ts +4 -4
  264. package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +4 -4
  265. package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +4 -4
  266. package/types/Options/Classes/ColorAnimation.d.ts +5 -4
  267. package/types/Options/Classes/FullScreen/FullScreen.d.ts +3 -3
  268. package/types/Options/Classes/HslAnimation.d.ts +4 -4
  269. package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +5 -5
  270. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +6 -12
  271. package/types/Options/Classes/Interactivity/Events/Events.d.ts +8 -14
  272. package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +6 -6
  273. package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +3 -3
  274. package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +3 -3
  275. package/types/Options/Classes/Interactivity/Interactivity.d.ts +8 -10
  276. package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +5 -5
  277. package/types/Options/Classes/ManualParticle.d.ts +5 -5
  278. package/types/Options/Classes/Options.d.ts +19 -26
  279. package/types/Options/Classes/OptionsColor.d.ts +5 -5
  280. package/types/Options/Classes/Particles/Bounce/ParticlesBounce.d.ts +4 -4
  281. package/types/Options/Classes/Particles/Bounce/ParticlesBounceFactor.d.ts +1 -1
  282. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +9 -7
  283. package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +3 -3
  284. package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +3 -3
  285. package/types/Options/Classes/Particles/Move/Move.d.ts +15 -26
  286. package/types/Options/Classes/Particles/Move/MoveAngle.d.ts +4 -4
  287. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +5 -9
  288. package/types/Options/Classes/Particles/Move/MoveCenter.d.ts +5 -5
  289. package/types/Options/Classes/Particles/Move/MoveGravity.d.ts +4 -4
  290. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +4 -7
  291. package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +4 -4
  292. package/types/Options/Classes/Particles/Move/OutModes.d.ts +5 -5
  293. package/types/Options/Classes/Particles/Move/Path/MovePath.d.ts +5 -5
  294. package/types/Options/Classes/Particles/Move/Spin.d.ts +5 -5
  295. package/types/Options/Classes/Particles/Number/ParticlesDensity.d.ts +3 -9
  296. package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +4 -6
  297. package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +7 -7
  298. package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +5 -7
  299. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +19 -19
  300. package/types/Options/Classes/Particles/Shadow.d.ts +5 -5
  301. package/types/Options/Classes/Particles/Shape/Shape.d.ts +5 -5
  302. package/types/Options/Classes/Particles/Size/Size.d.ts +7 -7
  303. package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +5 -7
  304. package/types/Options/Classes/Particles/Stroke.d.ts +5 -5
  305. package/types/Options/Classes/Particles/ZIndex/ZIndex.d.ts +4 -4
  306. package/types/Options/Classes/Random.d.ts +3 -3
  307. package/types/Options/Classes/Responsive.d.ts +7 -7
  308. package/types/Options/Classes/Theme/Theme.d.ts +6 -6
  309. package/types/Options/Classes/Theme/ThemeDefault.d.ts +4 -4
  310. package/types/Options/Classes/ValueWithRandom.d.ts +7 -11
  311. package/types/Options/Interfaces/Background/IBackground.d.ts +1 -1
  312. package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +2 -2
  313. package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +1 -1
  314. package/types/Options/Interfaces/IAnimatable.d.ts +1 -1
  315. package/types/Options/Interfaces/IAnimatableColor.d.ts +3 -3
  316. package/types/Options/Interfaces/IAnimation.d.ts +4 -4
  317. package/types/Options/Interfaces/IColorAnimation.d.ts +2 -2
  318. package/types/Options/Interfaces/IHslAnimation.d.ts +1 -1
  319. package/types/Options/Interfaces/IManualParticle.d.ts +3 -3
  320. package/types/Options/Interfaces/IOptionLoader.d.ts +1 -1
  321. package/types/Options/Interfaces/IOptions.d.ts +12 -15
  322. package/types/Options/Interfaces/IOptionsColor.d.ts +1 -1
  323. package/types/Options/Interfaces/IResponsive.d.ts +5 -4
  324. package/types/Options/Interfaces/IValueWithRandom.d.ts +3 -3
  325. package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +2 -2
  326. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +3 -6
  327. package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +5 -8
  328. package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +3 -3
  329. package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +3 -4
  330. package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +1 -2
  331. package/types/Options/Interfaces/Particles/Bounce/IParticlesBounce.d.ts +1 -1
  332. package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +6 -4
  333. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +15 -15
  334. package/types/Options/Interfaces/Particles/IShadow.d.ts +2 -2
  335. package/types/Options/Interfaces/Particles/IStroke.d.ts +5 -4
  336. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +12 -17
  337. package/types/Options/Interfaces/Particles/Move/IMoveAngle.d.ts +1 -1
  338. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +2 -4
  339. package/types/Options/Interfaces/Particles/Move/IMoveCenter.d.ts +1 -1
  340. package/types/Options/Interfaces/Particles/Move/IMoveGravity.d.ts +1 -1
  341. package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +1 -3
  342. package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +1 -1
  343. package/types/Options/Interfaces/Particles/Move/IOutModes.d.ts +1 -1
  344. package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
  345. package/types/Options/Interfaces/Particles/Move/Path/IMovePath.d.ts +2 -2
  346. package/types/Options/Interfaces/Particles/Number/IParticlesDensity.d.ts +0 -3
  347. package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +1 -2
  348. package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +2 -3
  349. package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +2 -3
  350. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -2
  351. package/types/Options/Interfaces/Particles/Size/ISize.d.ts +2 -3
  352. package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +2 -3
  353. package/types/Options/Interfaces/Particles/ZIndex/IZIndex.d.ts +1 -1
  354. package/types/Options/Interfaces/Theme/ITheme.d.ts +4 -3
  355. package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +1 -1
  356. package/types/Types/CustomEventArgs.d.ts +1 -1
  357. package/types/Types/CustomEventListener.d.ts +1 -1
  358. package/types/Types/ExportResult.d.ts +5 -0
  359. package/types/Types/ISourceOptions.d.ts +2 -2
  360. package/types/Types/ParticlesGroups.d.ts +1 -1
  361. package/types/Types/RangeValue.d.ts +1 -1
  362. package/types/Types/ShapeData.d.ts +2 -2
  363. package/types/Types/ShapeDrawerFunctions.d.ts +3 -3
  364. package/types/Utils/CanvasUtils.d.ts +11 -14
  365. package/types/Utils/ColorUtils.d.ts +6 -6
  366. package/types/Utils/EventDispatcher.d.ts +2 -2
  367. package/types/Utils/HslColorManager.d.ts +2 -2
  368. package/types/Utils/NumberUtils.d.ts +8 -8
  369. package/types/Utils/OptionsUtils.d.ts +6 -6
  370. package/types/Utils/RgbColorManager.d.ts +2 -2
  371. package/types/Utils/Utils.d.ts +32 -14
  372. package/types/bundle.d.ts +2 -91
  373. package/types/export-types.d.ts +107 -0
  374. package/types/exports.d.ts +89 -0
  375. package/types/index.d.ts +3 -204
  376. package/types/init.d.ts +2 -0
  377. package/umd/Core/Canvas.js +279 -249
  378. package/umd/Core/Container.js +105 -121
  379. package/umd/Core/Engine.js +285 -0
  380. package/umd/Core/Particle.js +174 -181
  381. package/umd/Core/Particles.js +155 -150
  382. package/umd/Core/Retina.js +21 -19
  383. package/umd/Core/Utils/Circle.js +15 -11
  384. package/umd/Core/Utils/Constants.js +5 -4
  385. package/umd/Core/Utils/EventListeners.js +268 -244
  386. package/umd/Core/Utils/InteractionManager.js +6 -16
  387. package/umd/Core/Utils/QuadTree.js +21 -27
  388. package/umd/Core/Utils/Rectangle.js +5 -5
  389. package/umd/Core/Utils/Vector.js +3 -3
  390. package/umd/Core/Utils/Vector3d.js +18 -10
  391. package/umd/Options/Classes/AnimatableColor.js +7 -6
  392. package/umd/Options/Classes/AnimationOptions.js +9 -8
  393. package/umd/Options/Classes/Background/Background.js +4 -4
  394. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +5 -4
  395. package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +4 -4
  396. package/umd/Options/Classes/ColorAnimation.js +10 -6
  397. package/umd/Options/Classes/HslAnimation.js +5 -5
  398. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +1 -25
  399. package/umd/Options/Classes/Interactivity/Events/Events.js +16 -35
  400. package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +3 -3
  401. package/umd/Options/Classes/Interactivity/Interactivity.js +6 -13
  402. package/umd/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  403. package/umd/Options/Classes/ManualParticle.js +8 -9
  404. package/umd/Options/Classes/Options.js +42 -62
  405. package/umd/Options/Classes/OptionsColor.js +4 -3
  406. package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +4 -4
  407. package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +3 -3
  408. package/umd/Options/Classes/Particles/Collisions/Collisions.js +12 -7
  409. package/umd/Options/Classes/Particles/Move/Move.js +32 -62
  410. package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
  411. package/umd/Options/Classes/Particles/Move/MoveAttract.js +12 -23
  412. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
  413. package/umd/Options/Classes/Particles/Move/MoveTrail.js +5 -11
  414. package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +3 -3
  415. package/umd/Options/Classes/Particles/Move/OutModes.js +4 -5
  416. package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -5
  417. package/umd/Options/Classes/Particles/Move/Spin.js +7 -5
  418. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  419. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +5 -12
  420. package/umd/Options/Classes/Particles/Opacity/Opacity.js +14 -10
  421. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +3 -12
  422. package/umd/Options/Classes/Particles/ParticlesOptions.js +33 -38
  423. package/umd/Options/Classes/Particles/Shadow.js +4 -4
  424. package/umd/Options/Classes/Particles/Shape/Shape.js +11 -12
  425. package/umd/Options/Classes/Particles/Size/Size.js +14 -10
  426. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +3 -12
  427. package/umd/Options/Classes/Particles/Stroke.js +6 -6
  428. package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -3
  429. package/umd/Options/Classes/Responsive.js +3 -3
  430. package/umd/Options/Classes/Theme/Theme.js +5 -5
  431. package/umd/Options/Classes/ValueWithRandom.js +11 -24
  432. package/umd/Utils/CanvasUtils.js +24 -61
  433. package/umd/Utils/ColorUtils.js +32 -34
  434. package/umd/Utils/EventDispatcher.js +7 -6
  435. package/umd/Utils/HslColorManager.js +12 -14
  436. package/umd/Utils/NumberUtils.js +45 -49
  437. package/umd/Utils/OptionsUtils.js +3 -3
  438. package/umd/Utils/RgbColorManager.js +8 -10
  439. package/umd/Utils/Utils.js +158 -78
  440. package/umd/bundle.js +5 -98
  441. package/umd/export-types.js +123 -0
  442. package/umd/exports.js +115 -0
  443. package/umd/index.js +9 -200
  444. package/umd/init.js +26 -0
  445. package/browser/Core/Utils/FrameManager.js +0 -42
  446. package/browser/Core/Utils/Plugins.js +0 -112
  447. package/browser/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
  448. package/browser/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
  449. package/browser/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  450. package/browser/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  451. package/browser/engine.js +0 -175
  452. package/cjs/Core/Utils/FrameManager.js +0 -46
  453. package/cjs/Core/Utils/Plugins.js +0 -116
  454. package/cjs/Enums/Modes/SizeMode.js +0 -2
  455. package/cjs/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -2
  456. package/cjs/Options/Interfaces/Particles/Shape/IImageShape.js +0 -2
  457. package/cjs/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -2
  458. package/cjs/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -17
  459. package/cjs/Options/Interfaces/Particles/Shape/IStarShape.js +0 -2
  460. package/cjs/engine.js +0 -179
  461. package/esm/Core/Interfaces/IParticleOverride.js +0 -1
  462. package/esm/Core/Interfaces/IParticlesMover.js +0 -1
  463. package/esm/Core/Utils/FrameManager.js +0 -42
  464. package/esm/Core/Utils/Plugins.js +0 -112
  465. package/esm/Enums/Modes/SizeMode.js +0 -1
  466. package/esm/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -1
  467. package/esm/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
  468. package/esm/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
  469. package/esm/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  470. package/esm/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  471. package/esm/engine.js +0 -175
  472. package/types/Core/Interfaces/IParticleOverride.d.ts +0 -6
  473. package/types/Core/Interfaces/IParticlesMover.d.ts +0 -7
  474. package/types/Core/Utils/FrameManager.d.ts +0 -6
  475. package/types/Core/Utils/Plugins.d.ts +0 -51
  476. package/types/Options/Interfaces/Particles/Shape/ICharacterShape.d.ts +0 -8
  477. package/types/Options/Interfaces/Particles/Shape/IImageShape.d.ts +0 -8
  478. package/types/Options/Interfaces/Particles/Shape/IPolygonShape.d.ts +0 -5
  479. package/types/Options/Interfaces/Particles/Shape/IShapeValues.d.ts +0 -1
  480. package/types/Options/Interfaces/Particles/Shape/IStarShape.d.ts +0 -6
  481. package/types/engine.d.ts +0 -39
  482. package/umd/Core/Utils/FrameManager.js +0 -56
  483. package/umd/Core/Utils/Plugins.js +0 -126
  484. package/umd/Enums/Modes/SizeMode.js +0 -12
  485. package/umd/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -12
  486. package/umd/Options/Interfaces/Particles/Shape/IImageShape.js +0 -12
  487. package/umd/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -12
  488. package/umd/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -27
  489. package/umd/Options/Interfaces/Particles/Shape/IStarShape.js +0 -12
  490. package/umd/engine.js +0 -189
  491. /package/browser/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
  492. /package/browser/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
  493. /package/cjs/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
  494. /package/cjs/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
  495. /package/{browser/Enums/Modes/SizeMode.js → esm/Enums/Modes/PixelMode.js} +0 -0
  496. /package/{browser/Options/Interfaces/Particles/Shape/ICharacterShape.js → esm/Types/ExportResult.js} +0 -0
  497. /package/umd/{Core/Interfaces/IParticleOverride.js → Enums/Modes/PixelMode.js} +0 -0
  498. /package/umd/{Core/Interfaces/IParticlesMover.js → Types/ExportResult.js} +0 -0
@@ -1,9 +1,9 @@
1
- import { executeOnSingleOrMultiple, safeMatchMedia } from "../../Utils/Utils";
2
- import { mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants";
1
+ import { executeOnSingleOrMultiple, isBoolean, safeMatchMedia } from "../../Utils/Utils.js";
2
+ import { mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants.js";
3
3
  function manageListener(element, event, handler, add, options) {
4
4
  if (add) {
5
5
  let addOptions = { passive: true };
6
- if (typeof options === "boolean") {
6
+ if (isBoolean(options)) {
7
7
  addOptions.capture = options;
8
8
  }
9
9
  else if (options !== undefined) {
@@ -19,101 +19,71 @@ function manageListener(element, event, handler, add, options) {
19
19
  export class EventListeners {
20
20
  constructor(container) {
21
21
  this.container = container;
22
- this.canPush = true;
23
- this.handlers = {
24
- mouseMove: (e) => this._mouseTouchMove(e),
25
- touchStart: (e) => this._mouseTouchMove(e),
26
- touchMove: (e) => this._mouseTouchMove(e),
27
- touchEnd: () => this._mouseTouchFinish(),
28
- mouseLeave: () => this._mouseTouchFinish(),
29
- touchCancel: () => this._mouseTouchFinish(),
30
- touchEndClick: (e) => this._mouseTouchClick(e),
31
- mouseUp: (e) => this._mouseTouchClick(e),
32
- mouseDown: () => this._mouseDown(),
33
- visibilityChange: () => this._handleVisibilityChange(),
34
- themeChange: (e) => this._handleThemeChange(e),
35
- oldThemeChange: (e) => this._handleThemeChange(e),
36
- resize: () => this._handleWindowResize(),
22
+ this._doMouseTouchClick = (e) => {
23
+ const container = this.container, options = container.actualOptions;
24
+ if (this._canPush) {
25
+ const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
26
+ if (!mousePos) {
27
+ return;
28
+ }
29
+ mouseInteractivity.clickPosition = { ...mousePos };
30
+ mouseInteractivity.clickTime = new Date().getTime();
31
+ const onClick = options.interactivity.events.onClick;
32
+ executeOnSingleOrMultiple(onClick.mode, (mode) => this.container.handleClickMode(mode));
33
+ }
34
+ if (e.type === "touchend") {
35
+ setTimeout(() => this._mouseTouchFinish(), 500);
36
+ }
37
37
  };
38
- }
39
- addListeners() {
40
- this._manageListeners(true);
41
- }
42
- removeListeners() {
43
- this._manageListeners(false);
44
- }
45
- _doMouseTouchClick(e) {
46
- const container = this.container, options = container.actualOptions;
47
- if (this.canPush) {
48
- const mouseInteractivity = container.interactivity.mouse, mousePos = mouseInteractivity.position;
49
- if (!mousePos) {
38
+ this._handleThemeChange = (e) => {
39
+ 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);
40
+ if (theme && theme.default.auto) {
41
+ container.loadTheme(themeName);
42
+ }
43
+ };
44
+ this._handleVisibilityChange = () => {
45
+ const container = this.container, options = container.actualOptions;
46
+ this._mouseTouchFinish();
47
+ if (!options.pauseOnBlur) {
50
48
  return;
51
49
  }
52
- mouseInteractivity.clickPosition = Object.assign({}, mousePos);
53
- mouseInteractivity.clickTime = new Date().getTime();
54
- const onClick = options.interactivity.events.onClick;
55
- executeOnSingleOrMultiple(onClick.mode, (mode) => this._handleClickMode(mode));
56
- }
57
- if (e.type === "touchend") {
58
- setTimeout(() => this._mouseTouchFinish(), 500);
59
- }
60
- }
61
- _handleClickMode(mode) {
62
- this.container.handleClickMode(mode);
63
- }
64
- _handleThemeChange(e) {
65
- 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);
66
- if (theme && theme.default.auto) {
67
- container.loadTheme(themeName);
68
- }
69
- }
70
- _handleVisibilityChange() {
71
- const container = this.container, options = container.actualOptions;
72
- this._mouseTouchFinish();
73
- if (!options.pauseOnBlur) {
74
- return;
75
- }
76
- container.pageHidden = (document === null || document === void 0 ? void 0 : document.hidden) || false;
77
- if (container.pageHidden) {
78
- container.pause();
79
- }
80
- else {
81
- if (container.getAnimationStatus()) {
82
- container.play(true);
50
+ if (document && document.hidden) {
51
+ container.pageHidden = true;
52
+ container.pause();
83
53
  }
84
54
  else {
85
- container.draw(true);
55
+ container.pageHidden = false;
56
+ if (container.getAnimationStatus()) {
57
+ container.play(true);
58
+ }
59
+ else {
60
+ container.draw(true);
61
+ }
62
+ }
63
+ };
64
+ this._handleWindowResize = async () => {
65
+ if (this._resizeTimeout) {
66
+ clearTimeout(this._resizeTimeout);
67
+ delete this._resizeTimeout;
68
+ }
69
+ this._resizeTimeout = setTimeout(async () => {
70
+ const canvas = this.container.canvas;
71
+ canvas && (await canvas.windowResize());
72
+ }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
73
+ };
74
+ this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
75
+ const handlers = this._handlers, container = this.container, options = container.actualOptions;
76
+ const interactivityEl = container.interactivity.element;
77
+ if (!interactivityEl) {
78
+ return;
79
+ }
80
+ const html = interactivityEl, canvasEl = container.canvas.element;
81
+ if (canvasEl) {
82
+ canvasEl.style.pointerEvents = html === canvasEl ? "initial" : "none";
83
+ }
84
+ if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
85
+ return;
86
86
  }
87
- }
88
- }
89
- _handleWindowResize() {
90
- if (this.resizeTimeout) {
91
- clearTimeout(this.resizeTimeout);
92
- delete this.resizeTimeout;
93
- }
94
- this.resizeTimeout = setTimeout(async () => { var _a; return (_a = this.container.canvas) === null || _a === void 0 ? void 0 : _a.windowResize(); }, this.container.actualOptions.interactivity.events.resize.delay * 1000);
95
- }
96
- _manageInteractivityEvents(add) {
97
- var _a;
98
- const handlers = this.handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn;
99
- let mouseLeaveTmpEvent = mouseLeaveEvent;
100
- if (detectType === "window") {
101
- container.interactivity.element = window;
102
- mouseLeaveTmpEvent = mouseOutEvent;
103
- }
104
- else if (detectType === "parent" && container.canvas.element) {
105
- const canvasEl = container.canvas.element;
106
- container.interactivity.element = (_a = canvasEl.parentElement) !== null && _a !== void 0 ? _a : canvasEl.parentNode;
107
- }
108
- else {
109
- container.interactivity.element = container.canvas.element;
110
- }
111
- const interactivityEl = container.interactivity.element;
112
- if (!interactivityEl) {
113
- return;
114
- }
115
- const html = interactivityEl;
116
- if (options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable) {
117
87
  manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
118
88
  manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
119
89
  manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
@@ -127,169 +97,223 @@ export class EventListeners {
127
97
  }
128
98
  manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
129
99
  manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
130
- }
131
- if (container.canvas.element) {
132
- container.canvas.element.style.pointerEvents = html === container.canvas.element ? "initial" : "none";
133
- }
134
- }
135
- _manageListeners(add) {
136
- this._manageMediaEvents(add);
137
- this._manageInteractivityEvents(add);
138
- this._manageResizeEvent(add);
139
- this._manageVisibilityEvent(add);
140
- }
141
- _manageMediaEvents(add) {
142
- const handlers = this.handlers, mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
143
- if (!mediaMatch) {
144
- return;
145
- }
146
- if (mediaMatch.addEventListener !== undefined) {
147
- manageListener(mediaMatch, "change", handlers.themeChange, add);
148
- return;
149
- }
150
- if (mediaMatch.addListener !== undefined) {
100
+ };
101
+ this._manageListeners = (add) => {
102
+ const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
103
+ let mouseLeaveTmpEvent = mouseLeaveEvent;
104
+ if (detectType === "window") {
105
+ container.interactivity.element = window;
106
+ mouseLeaveTmpEvent = mouseOutEvent;
107
+ }
108
+ else if (detectType === "parent" && canvasEl) {
109
+ container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
110
+ }
111
+ else {
112
+ container.interactivity.element = canvasEl;
113
+ }
114
+ this._manageMediaMatch(add);
115
+ this._manageResize(add);
116
+ this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
117
+ if (document) {
118
+ manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
119
+ }
120
+ };
121
+ this._manageMediaMatch = (add) => {
122
+ const handlers = this._handlers, mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
123
+ if (!mediaMatch) {
124
+ return;
125
+ }
126
+ if (mediaMatch.addEventListener !== undefined) {
127
+ manageListener(mediaMatch, "change", handlers.themeChange, add);
128
+ return;
129
+ }
130
+ if (mediaMatch.addListener === undefined) {
131
+ return;
132
+ }
151
133
  if (add) {
152
134
  mediaMatch.addListener(handlers.oldThemeChange);
153
135
  }
154
136
  else {
155
137
  mediaMatch.removeListener(handlers.oldThemeChange);
156
138
  }
157
- }
158
- }
159
- _manageResizeEvent(add) {
160
- const handlers = this.handlers, container = this.container, options = container.actualOptions;
161
- if (!options.interactivity.events.resize) {
162
- return;
163
- }
164
- if (typeof ResizeObserver === "undefined") {
165
- manageListener(window, resizeEvent, handlers.resize, add);
166
- return;
167
- }
168
- if (this.resizeObserver && !add) {
169
- if (container.canvas.element) {
170
- this.resizeObserver.unobserve(container.canvas.element);
139
+ };
140
+ this._manageResize = (add) => {
141
+ const handlers = this._handlers, container = this.container, options = container.actualOptions;
142
+ if (!options.interactivity.events.resize) {
143
+ return;
171
144
  }
172
- this.resizeObserver.disconnect();
173
- delete this.resizeObserver;
174
- }
175
- else if (!this.resizeObserver && add && container.canvas.element) {
176
- this.resizeObserver = new ResizeObserver((entries) => {
177
- const entry = entries.find((e) => e.target === container.canvas.element);
178
- if (!entry) {
179
- return;
145
+ if (typeof ResizeObserver === "undefined") {
146
+ manageListener(window, resizeEvent, handlers.resize, add);
147
+ return;
148
+ }
149
+ const canvasEl = container.canvas.element;
150
+ if (this._resizeObserver && !add) {
151
+ if (canvasEl) {
152
+ this._resizeObserver.unobserve(canvasEl);
180
153
  }
181
- this._handleWindowResize();
182
- });
183
- this.resizeObserver.observe(container.canvas.element);
184
- }
185
- }
186
- _manageVisibilityEvent(add) {
187
- if (!document) {
188
- return;
189
- }
190
- manageListener(document, visibilityChangeEvent, this.handlers.visibilityChange, add);
191
- }
192
- _mouseDown() {
193
- const interactivity = this.container.interactivity;
194
- if (interactivity) {
195
- const mouse = interactivity.mouse;
154
+ this._resizeObserver.disconnect();
155
+ delete this._resizeObserver;
156
+ }
157
+ else if (!this._resizeObserver && add && canvasEl) {
158
+ this._resizeObserver = new ResizeObserver(async (entries) => {
159
+ const entry = entries.find((e) => e.target === canvasEl);
160
+ if (!entry) {
161
+ return;
162
+ }
163
+ await this._handleWindowResize();
164
+ });
165
+ this._resizeObserver.observe(canvasEl);
166
+ }
167
+ };
168
+ this._mouseDown = () => {
169
+ const { interactivity } = this.container;
170
+ if (!interactivity) {
171
+ return;
172
+ }
173
+ const { mouse } = interactivity;
196
174
  mouse.clicking = true;
197
175
  mouse.downPosition = mouse.position;
198
- }
199
- }
200
- _mouseTouchClick(e) {
201
- const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse;
202
- mouse.inside = true;
203
- let handled = false;
204
- const mousePosition = mouse.position;
205
- if (!mousePosition || !options.interactivity.events.onClick.enable) {
206
- return;
207
- }
208
- for (const [, plugin] of container.plugins) {
209
- if (!plugin.clickPositionValid) {
210
- continue;
211
- }
212
- handled = plugin.clickPositionValid(mousePosition);
213
- if (handled) {
214
- break;
176
+ };
177
+ this._mouseTouchClick = (e) => {
178
+ const container = this.container, options = container.actualOptions, { mouse } = container.interactivity;
179
+ mouse.inside = true;
180
+ let handled = false;
181
+ const mousePosition = mouse.position;
182
+ if (!mousePosition || !options.interactivity.events.onClick.enable) {
183
+ return;
215
184
  }
216
- }
217
- if (!handled) {
218
- this._doMouseTouchClick(e);
219
- }
220
- mouse.clicking = false;
221
- }
222
- _mouseTouchFinish() {
223
- const interactivity = this.container.interactivity;
224
- if (!interactivity) {
225
- return;
226
- }
227
- const mouse = interactivity.mouse;
228
- delete mouse.position;
229
- delete mouse.clickPosition;
230
- delete mouse.downPosition;
231
- interactivity.status = mouseLeaveEvent;
232
- mouse.inside = false;
233
- mouse.clicking = false;
234
- }
235
- _mouseTouchMove(e) {
236
- var _a, _b, _c, _d, _e, _f, _g;
237
- const container = this.container, options = container.actualOptions;
238
- if (!((_a = container.interactivity) === null || _a === void 0 ? void 0 : _a.element)) {
239
- return;
240
- }
241
- container.interactivity.mouse.inside = true;
242
- let pos;
243
- const canvas = container.canvas.element;
244
- if (e.type.startsWith("pointer")) {
245
- this.canPush = true;
246
- const mouseEvent = e;
247
- if (container.interactivity.element === window) {
248
- if (canvas) {
249
- const clientRect = canvas.getBoundingClientRect();
250
- pos = {
251
- x: mouseEvent.clientX - clientRect.left,
252
- y: mouseEvent.clientY - clientRect.top,
253
- };
185
+ for (const [, plugin] of container.plugins) {
186
+ if (!plugin.clickPositionValid) {
187
+ continue;
254
188
  }
189
+ handled = plugin.clickPositionValid(mousePosition);
190
+ if (handled) {
191
+ break;
192
+ }
193
+ }
194
+ if (!handled) {
195
+ this._doMouseTouchClick(e);
196
+ }
197
+ mouse.clicking = false;
198
+ };
199
+ this._mouseTouchFinish = () => {
200
+ const interactivity = this.container.interactivity;
201
+ if (!interactivity) {
202
+ return;
203
+ }
204
+ const mouse = interactivity.mouse;
205
+ delete mouse.position;
206
+ delete mouse.clickPosition;
207
+ delete mouse.downPosition;
208
+ interactivity.status = mouseLeaveEvent;
209
+ mouse.inside = false;
210
+ mouse.clicking = false;
211
+ };
212
+ this._mouseTouchMove = (e) => {
213
+ const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
214
+ if (!interactivity || !interactivity.element) {
215
+ return;
255
216
  }
256
- else if (options.interactivity.detectsOn === "parent") {
257
- const source = mouseEvent.target, target = mouseEvent.currentTarget, canvasEl = container.canvas.element;
258
- if (source && target && canvasEl) {
259
- const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
217
+ interactivity.mouse.inside = true;
218
+ let pos;
219
+ if (e.type.startsWith("pointer")) {
220
+ this._canPush = true;
221
+ const mouseEvent = e;
222
+ if (interactivity.element === window) {
223
+ if (canvasEl) {
224
+ const clientRect = canvasEl.getBoundingClientRect();
225
+ pos = {
226
+ x: mouseEvent.clientX - clientRect.left,
227
+ y: mouseEvent.clientY - clientRect.top,
228
+ };
229
+ }
230
+ }
231
+ else if (options.interactivity.detectsOn === "parent") {
232
+ const source = mouseEvent.target, target = mouseEvent.currentTarget;
233
+ if (source && target && canvasEl) {
234
+ const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
235
+ pos = {
236
+ x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
237
+ y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top),
238
+ };
239
+ }
240
+ else {
241
+ pos = {
242
+ x: mouseEvent.offsetX ?? mouseEvent.clientX,
243
+ y: mouseEvent.offsetY ?? mouseEvent.clientY,
244
+ };
245
+ }
246
+ }
247
+ else if (mouseEvent.target === canvasEl) {
260
248
  pos = {
261
- x: mouseEvent.offsetX + 2 * sourceRect.left - (targetRect.left + canvasRect.left),
262
- y: mouseEvent.offsetY + 2 * sourceRect.top - (targetRect.top + canvasRect.top),
249
+ x: mouseEvent.offsetX ?? mouseEvent.clientX,
250
+ y: mouseEvent.offsetY ?? mouseEvent.clientY,
263
251
  };
264
252
  }
265
- else {
253
+ }
254
+ else {
255
+ this._canPush = e.type !== "touchmove";
256
+ if (canvasEl) {
257
+ const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - 1], canvasRect = canvasEl.getBoundingClientRect();
266
258
  pos = {
267
- x: (_b = mouseEvent.offsetX) !== null && _b !== void 0 ? _b : mouseEvent.clientX,
268
- y: (_c = mouseEvent.offsetY) !== null && _c !== void 0 ? _c : mouseEvent.clientY,
259
+ x: lastTouch.clientX - (canvasRect.left ?? 0),
260
+ y: lastTouch.clientY - (canvasRect.top ?? 0),
269
261
  };
270
262
  }
271
263
  }
272
- else if (mouseEvent.target === container.canvas.element) {
273
- pos = {
274
- x: (_d = mouseEvent.offsetX) !== null && _d !== void 0 ? _d : mouseEvent.clientX,
275
- y: (_e = mouseEvent.offsetY) !== null && _e !== void 0 ? _e : mouseEvent.clientY,
276
- };
264
+ const pxRatio = container.retina.pixelRatio;
265
+ if (pos) {
266
+ pos.x *= pxRatio;
267
+ pos.y *= pxRatio;
277
268
  }
278
- }
279
- else {
280
- this.canPush = e.type !== "touchmove";
281
- const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - 1], canvasRect = canvas === null || canvas === void 0 ? void 0 : canvas.getBoundingClientRect();
282
- pos = {
283
- x: lastTouch.clientX - ((_f = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.left) !== null && _f !== void 0 ? _f : 0),
284
- y: lastTouch.clientY - ((_g = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.top) !== null && _g !== void 0 ? _g : 0),
285
- };
286
- }
287
- const pxRatio = container.retina.pixelRatio;
288
- if (pos) {
289
- pos.x *= pxRatio;
290
- pos.y *= pxRatio;
291
- }
292
- container.interactivity.mouse.position = pos;
293
- container.interactivity.status = mouseMoveEvent;
269
+ interactivity.mouse.position = pos;
270
+ interactivity.status = mouseMoveEvent;
271
+ };
272
+ this._touchEnd = (e) => {
273
+ const evt = e, touches = Array.from(evt.changedTouches);
274
+ for (const touch of touches) {
275
+ this._touches.delete(touch.identifier);
276
+ }
277
+ this._mouseTouchFinish();
278
+ };
279
+ this._touchEndClick = (e) => {
280
+ const evt = e, touches = Array.from(evt.changedTouches);
281
+ for (const touch of touches) {
282
+ this._touches.delete(touch.identifier);
283
+ }
284
+ this._mouseTouchClick(e);
285
+ };
286
+ this._touchStart = (e) => {
287
+ const evt = e, touches = Array.from(evt.changedTouches);
288
+ for (const touch of touches) {
289
+ this._touches.set(touch.identifier, performance.now());
290
+ }
291
+ this._mouseTouchMove(e);
292
+ };
293
+ this._canPush = true;
294
+ this._touches = new Map();
295
+ this._handlers = {
296
+ mouseDown: () => this._mouseDown(),
297
+ mouseLeave: () => this._mouseTouchFinish(),
298
+ mouseMove: (e) => this._mouseTouchMove(e),
299
+ mouseUp: (e) => this._mouseTouchClick(e),
300
+ touchStart: (e) => this._touchStart(e),
301
+ touchMove: (e) => this._mouseTouchMove(e),
302
+ touchEnd: (e) => this._touchEnd(e),
303
+ touchCancel: (e) => this._touchEnd(e),
304
+ touchEndClick: (e) => this._touchEndClick(e),
305
+ visibilityChange: () => this._handleVisibilityChange(),
306
+ themeChange: (e) => this._handleThemeChange(e),
307
+ oldThemeChange: (e) => this._handleThemeChange(e),
308
+ resize: () => {
309
+ this._handleWindowResize();
310
+ },
311
+ };
312
+ }
313
+ addListeners() {
314
+ this._manageListeners(true);
315
+ }
316
+ removeListeners() {
317
+ this._manageListeners(false);
294
318
  }
295
319
  }
@@ -2,22 +2,18 @@ export class InteractionManager {
2
2
  constructor(engine, container) {
3
3
  this.container = container;
4
4
  this._engine = engine;
5
- this._interactors = this._engine.plugins.getInteractors(this.container, true);
5
+ this._interactors = engine.getInteractors(this.container, true);
6
6
  this._externalInteractors = [];
7
7
  this._particleInteractors = [];
8
8
  }
9
9
  async externalInteract(delta) {
10
10
  for (const interactor of this._externalInteractors) {
11
- if (interactor.isEnabled()) {
12
- await interactor.interact(delta);
13
- }
11
+ interactor.isEnabled() && (await interactor.interact(delta));
14
12
  }
15
13
  }
16
14
  handleClickMode(mode) {
17
15
  for (const interactor of this._externalInteractors) {
18
- if (interactor.handleClickMode) {
19
- interactor.handleClickMode(mode);
20
- }
16
+ interactor.handleClickMode && interactor.handleClickMode(mode);
21
17
  }
22
18
  }
23
19
  init() {
@@ -40,21 +36,15 @@ export class InteractionManager {
40
36
  interactor.clear(particle, delta);
41
37
  }
42
38
  for (const interactor of this._particleInteractors) {
43
- if (interactor.isEnabled(particle)) {
44
- await interactor.interact(particle, delta);
45
- }
39
+ interactor.isEnabled(particle) && (await interactor.interact(particle, delta));
46
40
  }
47
41
  }
48
42
  async reset(particle) {
49
43
  for (const interactor of this._externalInteractors) {
50
- if (interactor.isEnabled()) {
51
- await interactor.reset(particle);
52
- }
44
+ interactor.isEnabled() && interactor.reset(particle);
53
45
  }
54
46
  for (const interactor of this._particleInteractors) {
55
- if (interactor.isEnabled(particle)) {
56
- await interactor.reset(particle);
57
- }
47
+ interactor.isEnabled(particle) && interactor.reset(particle);
58
48
  }
59
49
  }
60
50
  }