@studiometa/js-toolkit 2.12.0 → 3.0.0-alpha.2

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 (346) hide show
  1. package/Base/Base.d.ts +2 -2
  2. package/Base/Base.js +8 -45
  3. package/Base/Base.js.map +2 -2
  4. package/Base/features.d.ts +10 -2
  5. package/Base/features.js +23 -1
  6. package/Base/features.js.map +2 -2
  7. package/Base/managers/AbstractManager.d.ts +3 -3
  8. package/Base/managers/ActionManager.d.ts +4 -0
  9. package/Base/managers/ActionManager.js +10 -0
  10. package/Base/managers/ActionManager.js.map +7 -0
  11. package/Base/managers/ChildrenManager.d.ts +1 -1
  12. package/Base/managers/ChildrenManager.js +3 -3
  13. package/Base/managers/ChildrenManager.js.map +2 -2
  14. package/Base/managers/ServicesManager.d.ts +2 -4
  15. package/Base/managers/ServicesManager.js +2 -3
  16. package/Base/managers/ServicesManager.js.map +2 -2
  17. package/Base/utils.js +1 -1
  18. package/Base/utils.js.map +2 -2
  19. package/decorators/index.d.ts +0 -1
  20. package/decorators/index.js +0 -1
  21. package/decorators/index.js.map +2 -2
  22. package/decorators/withBreakpointObserver.js +1 -1
  23. package/decorators/withBreakpointObserver.js.map +2 -2
  24. package/decorators/withIntersectionObserver.js +3 -5
  25. package/decorators/withIntersectionObserver.js.map +2 -2
  26. package/decorators/withMountOnMediaQuery.js +1 -1
  27. package/decorators/withMountOnMediaQuery.js.map +2 -2
  28. package/decorators/withMountWhenInView.js +1 -1
  29. package/decorators/withMountWhenInView.js.map +2 -2
  30. package/decorators/withScrolledInView/utils.d.ts +12 -1
  31. package/decorators/withScrolledInView/utils.js.map +2 -2
  32. package/decorators/withScrolledInView/withScrolledInView.js +7 -62
  33. package/decorators/withScrolledInView/withScrolledInView.js.map +2 -2
  34. package/helpers/createApp.d.ts +2 -1
  35. package/helpers/createApp.js.map +2 -2
  36. package/package.json +2 -10
  37. package/services/index.d.ts +1 -1
  38. package/services/index.js.map +2 -2
  39. package/services/pointer.d.ts +1 -1
  40. package/services/pointer.js +3 -3
  41. package/services/pointer.js.map +2 -2
  42. package/services/raf.js +2 -4
  43. package/services/raf.js.map +2 -2
  44. package/services/resize.d.ts +7 -6
  45. package/services/resize.js +19 -26
  46. package/services/resize.js.map +2 -2
  47. package/services/scroll.js +8 -8
  48. package/services/scroll.js.map +2 -2
  49. package/utils/SmartQueue.d.ts +1 -1
  50. package/utils/SmartQueue.js +1 -1
  51. package/utils/SmartQueue.js.map +2 -2
  52. package/utils/css/animate.d.ts +33 -15
  53. package/utils/css/animate.js +67 -26
  54. package/utils/css/animate.js.map +2 -2
  55. package/utils/css/getOffsetSizes.js +2 -2
  56. package/utils/css/getOffsetSizes.js.map +1 -1
  57. package/utils/css/index.d.ts +2 -1
  58. package/utils/css/index.js +4 -4
  59. package/utils/css/index.js.map +2 -2
  60. package/utils/css/matrix.d.ts +1 -1
  61. package/utils/css/matrix.js.map +2 -2
  62. package/utils/css/transform.d.ts +1 -1
  63. package/utils/css/transform.js +1 -1
  64. package/utils/css/transform.js.map +2 -2
  65. package/utils/css/utils.d.ts +1 -1
  66. package/utils/css/utils.js +1 -1
  67. package/utils/css/utils.js.map +2 -2
  68. package/utils/index.d.ts +5 -4
  69. package/utils/index.js +16 -16
  70. package/utils/index.js.map +2 -2
  71. package/utils/is.d.ts +12 -0
  72. package/utils/is.js +17 -0
  73. package/utils/is.js.map +2 -2
  74. package/utils/math/createRange.d.ts +4 -0
  75. package/utils/math/createRange.js +13 -0
  76. package/utils/math/createRange.js.map +7 -0
  77. package/utils/math/ease.d.ts +1 -0
  78. package/utils/math/ease.js +2 -0
  79. package/utils/math/ease.js.map +2 -2
  80. package/utils/math/index.d.ts +5 -3
  81. package/utils/math/index.js +7 -3
  82. package/utils/math/index.js.map +2 -2
  83. package/utils/math/mean.d.ts +1 -0
  84. package/utils/math/mean.js +17 -0
  85. package/utils/math/mean.js.map +7 -0
  86. package/utils/nextFrame.d.ts +4 -22
  87. package/utils/nextFrame.js +3 -10
  88. package/utils/nextFrame.js.map +2 -2
  89. package/utils/nextMicrotask.d.ts +4 -1
  90. package/utils/nextMicrotask.js +3 -3
  91. package/utils/nextMicrotask.js.map +2 -2
  92. package/utils/nextTick.d.ts +4 -1
  93. package/utils/nextTick.js +3 -3
  94. package/utils/nextTick.js.map +2 -2
  95. package/utils/random.d.ts +15 -0
  96. package/utils/random.js +15 -0
  97. package/utils/random.js.map +7 -0
  98. package/utils/scrollTo.d.ts +30 -6
  99. package/utils/scrollTo.js +97 -43
  100. package/utils/scrollTo.js.map +2 -2
  101. package/utils/{focusTrap.d.ts → trapFocus.d.ts} +2 -10
  102. package/utils/{focusTrap.js → trapFocus.js} +5 -9
  103. package/utils/trapFocus.js.map +7 -0
  104. package/utils/tween.d.ts +59 -10
  105. package/utils/tween.js +24 -18
  106. package/utils/tween.js.map +2 -2
  107. package/Base/Base.cjs +0 -420
  108. package/Base/Base.cjs.map +0 -7
  109. package/Base/features.cjs +0 -27
  110. package/Base/features.cjs.map +0 -7
  111. package/Base/index.cjs +0 -21
  112. package/Base/index.cjs.map +0 -7
  113. package/Base/managers/AbstractManager.cjs +0 -78
  114. package/Base/managers/AbstractManager.cjs.map +0 -7
  115. package/Base/managers/ChildrenManager.cjs +0 -156
  116. package/Base/managers/ChildrenManager.cjs.map +0 -7
  117. package/Base/managers/EventsManager.cjs +0 -305
  118. package/Base/managers/EventsManager.cjs.map +0 -7
  119. package/Base/managers/OptionsManager.cjs +0 -198
  120. package/Base/managers/OptionsManager.cjs.map +0 -7
  121. package/Base/managers/RefsManager.cjs +0 -118
  122. package/Base/managers/RefsManager.cjs.map +0 -7
  123. package/Base/managers/ResponsiveOptionsManager.cjs +0 -79
  124. package/Base/managers/ResponsiveOptionsManager.cjs.map +0 -7
  125. package/Base/managers/ServicesManager.cjs +0 -161
  126. package/Base/managers/ServicesManager.cjs.map +0 -7
  127. package/Base/managers/index.cjs +0 -39
  128. package/Base/managers/index.cjs.map +0 -7
  129. package/Base/types.cjs +0 -19
  130. package/Base/types.cjs.map +0 -7
  131. package/Base/utils.cjs +0 -95
  132. package/Base/utils.cjs.map +0 -7
  133. package/decorators/index.cjs +0 -33
  134. package/decorators/index.cjs.map +0 -7
  135. package/decorators/withBreakpointManager.cjs +0 -102
  136. package/decorators/withBreakpointManager.cjs.map +0 -7
  137. package/decorators/withBreakpointObserver.cjs +0 -128
  138. package/decorators/withBreakpointObserver.cjs.map +0 -7
  139. package/decorators/withDrag.cjs +0 -56
  140. package/decorators/withDrag.cjs.map +0 -7
  141. package/decorators/withExtraConfig.cjs +0 -50
  142. package/decorators/withExtraConfig.cjs.map +0 -7
  143. package/decorators/withFreezedOptions.cjs +0 -50
  144. package/decorators/withFreezedOptions.cjs.map +0 -7
  145. package/decorators/withIntersectionObserver.cjs +0 -71
  146. package/decorators/withIntersectionObserver.cjs.map +0 -7
  147. package/decorators/withMountOnMediaQuery.cjs +0 -86
  148. package/decorators/withMountOnMediaQuery.cjs.map +0 -7
  149. package/decorators/withMountWhenInView.cjs +0 -92
  150. package/decorators/withMountWhenInView.cjs.map +0 -7
  151. package/decorators/withMountWhenPrefersMotion.cjs +0 -30
  152. package/decorators/withMountWhenPrefersMotion.cjs.map +0 -7
  153. package/decorators/withRelativePointer.cjs +0 -56
  154. package/decorators/withRelativePointer.cjs.map +0 -7
  155. package/decorators/withResponsiveOptions.cjs +0 -41
  156. package/decorators/withResponsiveOptions.cjs.map +0 -7
  157. package/decorators/withScrolledInView/index.cjs +0 -22
  158. package/decorators/withScrolledInView/index.cjs.map +0 -7
  159. package/decorators/withScrolledInView/types.cjs +0 -19
  160. package/decorators/withScrolledInView/types.cjs.map +0 -7
  161. package/decorators/withScrolledInView/utils.cjs +0 -99
  162. package/decorators/withScrolledInView/utils.cjs.map +0 -7
  163. package/decorators/withScrolledInView/withScrolledInView.cjs +0 -249
  164. package/decorators/withScrolledInView/withScrolledInView.cjs.map +0 -7
  165. package/decorators/withVue2.cjs +0 -68
  166. package/decorators/withVue2.cjs.map +0 -7
  167. package/decorators/withVue2.d.ts +0 -16
  168. package/decorators/withVue2.js +0 -46
  169. package/decorators/withVue2.js.map +0 -7
  170. package/helpers/createApp.cjs +0 -58
  171. package/helpers/createApp.cjs.map +0 -7
  172. package/helpers/getClosestParent.cjs +0 -45
  173. package/helpers/getClosestParent.cjs.map +0 -7
  174. package/helpers/getDirectChildren.cjs +0 -47
  175. package/helpers/getDirectChildren.cjs.map +0 -7
  176. package/helpers/getInstanceFromElement.cjs +0 -32
  177. package/helpers/getInstanceFromElement.cjs.map +0 -7
  178. package/helpers/importOnInteraction.cjs +0 -48
  179. package/helpers/importOnInteraction.cjs.map +0 -7
  180. package/helpers/importOnMediaQuery.cjs +0 -44
  181. package/helpers/importOnMediaQuery.cjs.map +0 -7
  182. package/helpers/importWhenIdle.cjs +0 -46
  183. package/helpers/importWhenIdle.cjs.map +0 -7
  184. package/helpers/importWhenPrefersMotion.cjs +0 -40
  185. package/helpers/importWhenPrefersMotion.cjs.map +0 -7
  186. package/helpers/importWhenVisible.cjs +0 -44
  187. package/helpers/importWhenVisible.cjs.map +0 -7
  188. package/helpers/index.cjs +0 -53
  189. package/helpers/index.cjs.map +0 -7
  190. package/helpers/utils.cjs +0 -37
  191. package/helpers/utils.cjs.map +0 -7
  192. package/index.cjs +0 -31
  193. package/index.cjs.map +0 -7
  194. package/services/drag.cjs +0 -231
  195. package/services/drag.cjs.map +0 -7
  196. package/services/index.cjs +0 -51
  197. package/services/index.cjs.map +0 -7
  198. package/services/key.cjs +0 -97
  199. package/services/key.cjs.map +0 -7
  200. package/services/load.cjs +0 -60
  201. package/services/load.cjs.map +0 -7
  202. package/services/pointer.cjs +0 -145
  203. package/services/pointer.cjs.map +0 -7
  204. package/services/raf.cjs +0 -80
  205. package/services/raf.cjs.map +0 -7
  206. package/services/resize.cjs +0 -107
  207. package/services/resize.cjs.map +0 -7
  208. package/services/scroll.cjs +0 -119
  209. package/services/scroll.cjs.map +0 -7
  210. package/services/service.cjs +0 -69
  211. package/services/service.cjs.map +0 -7
  212. package/utils/Queue.cjs +0 -93
  213. package/utils/Queue.cjs.map +0 -7
  214. package/utils/SmartQueue.cjs +0 -73
  215. package/utils/SmartQueue.cjs.map +0 -7
  216. package/utils/collide/boundingRectToCircle.cjs +0 -36
  217. package/utils/collide/boundingRectToCircle.cjs.map +0 -7
  218. package/utils/collide/collideCircleCircle.cjs +0 -35
  219. package/utils/collide/collideCircleCircle.cjs.map +0 -7
  220. package/utils/collide/collideCircleRect.cjs +0 -47
  221. package/utils/collide/collideCircleRect.cjs.map +0 -7
  222. package/utils/collide/collidePointCircle.cjs +0 -32
  223. package/utils/collide/collidePointCircle.cjs.map +0 -7
  224. package/utils/collide/collidePointRect.cjs +0 -32
  225. package/utils/collide/collidePointRect.cjs.map +0 -7
  226. package/utils/collide/collideRectRect.cjs +0 -32
  227. package/utils/collide/collideRectRect.cjs.map +0 -7
  228. package/utils/collide/index.cjs +0 -47
  229. package/utils/collide/index.cjs.map +0 -7
  230. package/utils/css/animate.cjs +0 -202
  231. package/utils/css/animate.cjs.map +0 -7
  232. package/utils/css/classes.cjs +0 -51
  233. package/utils/css/classes.cjs.map +0 -7
  234. package/utils/css/getOffsetSizes.cjs +0 -48
  235. package/utils/css/getOffsetSizes.cjs.map +0 -7
  236. package/utils/css/index.cjs +0 -52
  237. package/utils/css/index.cjs.map +0 -7
  238. package/utils/css/matrix.cjs +0 -30
  239. package/utils/css/matrix.cjs.map +0 -7
  240. package/utils/css/styles.cjs +0 -45
  241. package/utils/css/styles.cjs.map +0 -7
  242. package/utils/css/transform.cjs +0 -91
  243. package/utils/css/transform.cjs.map +0 -7
  244. package/utils/css/transition.cjs +0 -145
  245. package/utils/css/transition.cjs.map +0 -7
  246. package/utils/css/utils.cjs +0 -32
  247. package/utils/css/utils.cjs.map +0 -7
  248. package/utils/debounce.cjs +0 -35
  249. package/utils/debounce.cjs.map +0 -7
  250. package/utils/dom/ancestors.cjs +0 -37
  251. package/utils/dom/ancestors.cjs.map +0 -7
  252. package/utils/dom/index.cjs +0 -21
  253. package/utils/dom/index.cjs.map +0 -7
  254. package/utils/focusTrap.cjs +0 -93
  255. package/utils/focusTrap.cjs.map +0 -7
  256. package/utils/focusTrap.js.map +0 -7
  257. package/utils/getComponentResolver.cjs +0 -38
  258. package/utils/getComponentResolver.cjs.map +0 -7
  259. package/utils/has.cjs +0 -29
  260. package/utils/has.cjs.map +0 -7
  261. package/utils/history.cjs +0 -92
  262. package/utils/history.cjs.map +0 -7
  263. package/utils/index.cjs +0 -76
  264. package/utils/index.cjs.map +0 -7
  265. package/utils/is.cjs +0 -41
  266. package/utils/is.cjs.map +0 -7
  267. package/utils/keyCodes.cjs +0 -36
  268. package/utils/keyCodes.cjs.map +0 -7
  269. package/utils/math/clamp.cjs +0 -29
  270. package/utils/math/clamp.cjs.map +0 -7
  271. package/utils/math/clamp01.cjs +0 -40
  272. package/utils/math/clamp01.cjs.map +0 -7
  273. package/utils/math/createEases.cjs +0 -33
  274. package/utils/math/createEases.cjs.map +0 -7
  275. package/utils/math/damp.cjs +0 -29
  276. package/utils/math/damp.cjs.map +0 -7
  277. package/utils/math/ease.cjs +0 -82
  278. package/utils/math/ease.cjs.map +0 -7
  279. package/utils/math/index.cjs +0 -54
  280. package/utils/math/index.cjs.map +0 -7
  281. package/utils/math/inertiaFinalValue.cjs +0 -47
  282. package/utils/math/inertiaFinalValue.cjs.map +0 -7
  283. package/utils/math/lerp.cjs +0 -29
  284. package/utils/math/lerp.cjs.map +0 -7
  285. package/utils/math/map.cjs +0 -29
  286. package/utils/math/map.cjs.map +0 -7
  287. package/utils/math/round.cjs +0 -29
  288. package/utils/math/round.cjs.map +0 -7
  289. package/utils/memoize.cjs +0 -48
  290. package/utils/memoize.cjs.map +0 -7
  291. package/utils/nextFrame.cjs +0 -41
  292. package/utils/nextFrame.cjs.map +0 -7
  293. package/utils/nextMicrotask.cjs +0 -30
  294. package/utils/nextMicrotask.cjs.map +0 -7
  295. package/utils/nextTick.cjs +0 -31
  296. package/utils/nextTick.cjs.map +0 -7
  297. package/utils/noop.cjs +0 -32
  298. package/utils/noop.cjs.map +0 -7
  299. package/utils/object/autoBind.cjs +0 -60
  300. package/utils/object/autoBind.cjs.map +0 -7
  301. package/utils/object/autoBind.d.ts +0 -14
  302. package/utils/object/autoBind.js +0 -28
  303. package/utils/object/autoBind.js.map +0 -7
  304. package/utils/object/getAllProperties.cjs +0 -39
  305. package/utils/object/getAllProperties.cjs.map +0 -7
  306. package/utils/object/index.cjs +0 -39
  307. package/utils/object/index.cjs.map +0 -7
  308. package/utils/object/index.d.ts +0 -2
  309. package/utils/object/index.js +0 -7
  310. package/utils/object/index.js.map +0 -7
  311. package/utils/scheduler.cjs +0 -75
  312. package/utils/scheduler.cjs.map +0 -7
  313. package/utils/scrollTo.cjs +0 -88
  314. package/utils/scrollTo.cjs.map +0 -7
  315. package/utils/string/endsWith.cjs +0 -35
  316. package/utils/string/endsWith.cjs.map +0 -7
  317. package/utils/string/index.cjs +0 -58
  318. package/utils/string/index.cjs.map +0 -7
  319. package/utils/string/startsWith.cjs +0 -35
  320. package/utils/string/startsWith.cjs.map +0 -7
  321. package/utils/string/withLeadingCharacters.cjs +0 -40
  322. package/utils/string/withLeadingCharacters.cjs.map +0 -7
  323. package/utils/string/withLeadingSlash.cjs +0 -40
  324. package/utils/string/withLeadingSlash.cjs.map +0 -7
  325. package/utils/string/withTrailingCharacters.cjs +0 -40
  326. package/utils/string/withTrailingCharacters.cjs.map +0 -7
  327. package/utils/string/withTrailingSlash.cjs +0 -40
  328. package/utils/string/withTrailingSlash.cjs.map +0 -7
  329. package/utils/string/withoutLeadingCharacters.cjs +0 -29
  330. package/utils/string/withoutLeadingCharacters.cjs.map +0 -7
  331. package/utils/string/withoutLeadingCharactersRecursive.cjs +0 -45
  332. package/utils/string/withoutLeadingCharactersRecursive.cjs.map +0 -7
  333. package/utils/string/withoutLeadingSlash.cjs +0 -40
  334. package/utils/string/withoutLeadingSlash.cjs.map +0 -7
  335. package/utils/string/withoutTrailingCharacters.cjs +0 -29
  336. package/utils/string/withoutTrailingCharacters.cjs.map +0 -7
  337. package/utils/string/withoutTrailingCharactersRecursive.cjs +0 -45
  338. package/utils/string/withoutTrailingCharactersRecursive.cjs.map +0 -7
  339. package/utils/string/withoutTrailingSlash.cjs +0 -40
  340. package/utils/string/withoutTrailingSlash.cjs.map +0 -7
  341. package/utils/throttle.cjs +0 -37
  342. package/utils/throttle.cjs.map +0 -7
  343. package/utils/tween.cjs +0 -122
  344. package/utils/tween.cjs.map +0 -7
  345. package/utils/wait.cjs +0 -31
  346. package/utils/wait.cjs.map +0 -7
@@ -1,36 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/boundingRectToCircle.ts
20
- var boundingRectToCircle_exports = {};
21
- __export(boundingRectToCircle_exports, {
22
- default: () => boundingRectToCircle
23
- });
24
- module.exports = __toCommonJS(boundingRectToCircle_exports);
25
- function boundingRectToCircle({ x, y, width, height }, force = false) {
26
- if (width !== height && !force) {
27
- throw new Error("Initial DOMElement is not a square. Please use the force mode.");
28
- }
29
- return {
30
- x: x + width / 2,
31
- y: y + height / 2,
32
- radius: (width + height) / 4
33
- };
34
- }
35
- if (module.exports.default) module.exports = module.exports.default;
36
- //# sourceMappingURL=boundingRectToCircle.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/boundingRectToCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Convert clientRect to a formatted circle object\n *\n * @param {Partial<DOMRect>} domRect DOMRect of a square DOMElement\n * @param {boolean} force Force usage of non-square DOMElements\n * @returns {Circle} Circle object that can be used in collides functions\n */\nexport default function boundingRectToCircle({ x, y, width, height }, force = false) {\n if (width !== height && !force) {\n throw new Error('Initial DOMElement is not a square. Please use the force mode.');\n }\n return {\n x: x + width / 2,\n y: y + height / 2,\n radius: (width + height) / 4,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,qBAAsC,EAAE,GAAG,GAAG,OAAO,OAAO,GAAG,QAAQ,OAAO;AACnF,MAAI,UAAU,UAAU,CAAC,OAAO;AAC9B,UAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AACA,SAAO;AAAA,IACL,GAAG,IAAI,QAAQ;AAAA,IACf,GAAG,IAAI,SAAS;AAAA,IAChB,SAAS,QAAQ,UAAU;AAAA,EAC7B;AACF;",
6
- "names": []
7
- }
@@ -1,35 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/collideCircleCircle.ts
20
- var collideCircleCircle_exports = {};
21
- __export(collideCircleCircle_exports, {
22
- default: () => collideCircleCircle
23
- });
24
- module.exports = __toCommonJS(collideCircleCircle_exports);
25
- function collideCircleCircle(circle1, circle2) {
26
- const distX = circle1.x - circle2.x;
27
- const distY = circle1.y - circle2.y;
28
- const distance = Math.sqrt(distX * distX + distY * distY);
29
- if (distance <= circle1.radius + circle2.radius) {
30
- return true;
31
- }
32
- return false;
33
- }
34
- if (module.exports.default) module.exports = module.exports.default;
35
- //# sourceMappingURL=collideCircleCircle.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/collideCircleCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with another.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-circle.php\n *\n * @param {Circle} circle1 Circle 1\n * @param {Circle} circle2 Circle 2\n * @returns {boolean} Are the sides of one circle touching the other ?\n */\nexport default function collideCircleCircle(circle1, circle2) {\n // get distance between the circle's centers\n // use the Pythagorean Theorem to compute the distance\n const distX = circle1.x - circle2.x;\n const distY = circle1.y - circle2.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the sum of the circle's\n // radii, the circles are touching!\n if (distance <= circle1.radius + circle2.radius) {\n return true;\n }\n return false;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAee,SAAR,oBAAqC,SAAS,SAAS;AAG5D,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAIxD,MAAI,YAAY,QAAQ,SAAS,QAAQ,QAAQ;AAC/C,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,47 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/collideCircleRect.ts
20
- var collideCircleRect_exports = {};
21
- __export(collideCircleRect_exports, {
22
- default: () => collideCircleRect
23
- });
24
- module.exports = __toCommonJS(collideCircleRect_exports);
25
- function collideCircleRect(circle, rect) {
26
- let testX = circle.x;
27
- let testY = circle.y;
28
- if (circle.x < rect.x) {
29
- testX = rect.x;
30
- } else if (circle.x > rect.x + rect.width) {
31
- testX = rect.x + rect.width;
32
- }
33
- if (circle.y < rect.y) {
34
- testY = rect.y;
35
- } else if (circle.y > rect.y + rect.height) {
36
- testY = rect.y + rect.height;
37
- }
38
- const distX = circle.x - testX;
39
- const distY = circle.y - testY;
40
- const distance = Math.sqrt(distX * distX + distY * distY);
41
- if (distance <= circle.radius) {
42
- return true;
43
- }
44
- return false;
45
- }
46
- if (module.exports.default) module.exports = module.exports.default;
47
- //# sourceMappingURL=collideCircleRect.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/collideCircleRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-rect.php\n *\n * @param {Circle} circle Circle\n * @param {Rect} rect Rectangle\n * @returns {boolean} Are the sides of the circle touching the rectangle ?\n */\nexport default function collideCircleRect(circle, rect) {\n // temporary variables to set edges for testing\n let testX = circle.x;\n let testY = circle.y;\n\n // which edge is closest?\n if (circle.x < rect.x) {\n testX = rect.x; // test left edge\n } else if (circle.x > rect.x + rect.width) {\n testX = rect.x + rect.width; // right edge\n }\n\n if (circle.y < rect.y) {\n testY = rect.y; // top edge\n } else if (circle.y > rect.y + rect.height) {\n testY = rect.y + rect.height; // bottom edge\n }\n\n // get distance from closest edges\n const distX = circle.x - testX;\n const distY = circle.y - testY;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the radius, collision!\n if (distance <= circle.radius) {\n return true;\n }\n return false;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBe,SAAR,kBAAmC,QAAQ,MAAM;AAEtD,MAAI,QAAQ,OAAO;AACnB,MAAI,QAAQ,OAAO;AAGnB,MAAI,OAAO,IAAI,KAAK,GAAG;AACrB,YAAQ,KAAK;AAAA,EACf,WAAW,OAAO,IAAI,KAAK,IAAI,KAAK,OAAO;AACzC,YAAQ,KAAK,IAAI,KAAK;AAAA,EACxB;AAEA,MAAI,OAAO,IAAI,KAAK,GAAG;AACrB,YAAQ,KAAK;AAAA,EACf,WAAW,OAAO,IAAI,KAAK,IAAI,KAAK,QAAQ;AAC1C,YAAQ,KAAK,IAAI,KAAK;AAAA,EACxB;AAGA,QAAM,QAAQ,OAAO,IAAI;AACzB,QAAM,QAAQ,OAAO,IAAI;AACzB,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAGxD,MAAI,YAAY,OAAO,QAAQ;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/collidePointCircle.ts
20
- var collidePointCircle_exports = {};
21
- __export(collidePointCircle_exports, {
22
- default: () => collidePointCircle
23
- });
24
- module.exports = __toCommonJS(collidePointCircle_exports);
25
- function collidePointCircle(point, circle) {
26
- const distX = point.x - circle.x;
27
- const distY = point.y - circle.y;
28
- const distance = Math.sqrt(distX * distX + distY * distY);
29
- return distance <= circle.radius;
30
- }
31
- if (module.exports.default) module.exports = module.exports.default;
32
- //# sourceMappingURL=collidePointCircle.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/collidePointCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a point is inside a circle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-circle.php\n *\n * @param {Point} point Point\n * @param {Circle} circle Circle\n * @returns {boolean} Is the point inside the circle's bounds ?\n */\nexport default function collidePointCircle(point, circle) {\n // get distance between the point and circle's center\n // using the Pythagorean Theorem\n const distX = point.x - circle.x;\n const distY = point.y - circle.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the circle's\n // radius the point is inside!\n return distance <= circle.radius;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBe,SAAR,mBAAoC,OAAO,QAAQ;AAGxD,QAAM,QAAQ,MAAM,IAAI,OAAO;AAC/B,QAAM,QAAQ,MAAM,IAAI,OAAO;AAC/B,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAIxD,SAAO,YAAY,OAAO;AAC5B;",
6
- "names": []
7
- }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/collidePointRect.ts
20
- var collidePointRect_exports = {};
21
- __export(collidePointRect_exports, {
22
- default: () => collidePointRect
23
- });
24
- module.exports = __toCommonJS(collidePointRect_exports);
25
- function collidePointRect(point, rect) {
26
- return point.x >= rect.x && // right of the left edge AND
27
- point.x <= rect.x + rect.width && // left of the right edge AND
28
- point.y >= rect.y && // below the top AND
29
- point.y <= rect.y + rect.height;
30
- }
31
- if (module.exports.default) module.exports = module.exports.default;
32
- //# sourceMappingURL=collidePointRect.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/collidePointRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a point collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-rect.php\n *\n * @param {Point} point Point\n * @param {Rect} rect Rectangle\n * @returns {boolean} Is the point inside the rectangle's bounds ?\n */\nexport default function collidePointRect(point, rect) {\n return (\n point.x >= rect.x && // right of the left edge AND\n point.x <= rect.x + rect.width && // left of the right edge AND\n point.y >= rect.y && // below the top AND\n point.y <= rect.y + rect.height // above the bottom\n );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBe,SAAR,iBAAkC,OAAO,MAAM;AACpD,SACE,MAAM,KAAK,KAAK;AAAA,EAChB,MAAM,KAAK,KAAK,IAAI,KAAK;AAAA,EACzB,MAAM,KAAK,KAAK;AAAA,EAChB,MAAM,KAAK,KAAK,IAAI,KAAK;AAE7B;",
6
- "names": []
7
- }
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/collide/collideRectRect.ts
20
- var collideRectRect_exports = {};
21
- __export(collideRectRect_exports, {
22
- default: () => collideRectRect
23
- });
24
- module.exports = __toCommonJS(collideRectRect_exports);
25
- function collideRectRect(rect1, rect2) {
26
- return rect1.x + rect1.width >= rect2.x && // rect1 right edge past rect2 left AND
27
- rect1.x <= rect2.x + rect2.width && // rect1 left edge past rect2 right AND
28
- rect1.y + rect1.height >= rect2.y && // rect1 top edge past rect2 bottom AND
29
- rect1.y <= rect2.y + rect2.height;
30
- }
31
- if (module.exports.default) module.exports = module.exports.default;
32
- //# sourceMappingURL=collideRectRect.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/collideRectRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a rectangle collides with another rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/rect-rect.php\n *\n * @param {Rect} rect1 Rectangle 1\n * @param {Rect} rect2 Rectangle 2\n * @returns {boolean} Are the sides of one rectangle touching the other ?\n */\nexport default function collideRectRect(rect1, rect2) {\n return (\n rect1.x + rect1.width >= rect2.x && // rect1 right edge past rect2 left AND\n rect1.x <= rect2.x + rect2.width && // rect1 left edge past rect2 right AND\n rect1.y + rect1.height >= rect2.y && // rect1 top edge past rect2 bottom AND\n rect1.y <= rect2.y + rect2.height // rect1 bottom edge past rect2 top\n );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBe,SAAR,gBAAiC,OAAO,OAAO;AACpD,SACE,MAAM,IAAI,MAAM,SAAS,MAAM;AAAA,EAC/B,MAAM,KAAK,MAAM,IAAI,MAAM;AAAA,EAC3B,MAAM,IAAI,MAAM,UAAU,MAAM;AAAA,EAChC,MAAM,KAAK,MAAM,IAAI,MAAM;AAE/B;",
6
- "names": []
7
- }
@@ -1,47 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/collide/index.ts
30
- var collide_exports = {};
31
- __export(collide_exports, {
32
- boundingRectToCircle: () => import_boundingRectToCircle.default,
33
- collideCircleCircle: () => import_collideCircleCircle.default,
34
- collideCircleRect: () => import_collideCircleRect.default,
35
- collidePointCircle: () => import_collidePointCircle.default,
36
- collidePointRect: () => import_collidePointRect.default,
37
- collideRectRect: () => import_collideRectRect.default
38
- });
39
- module.exports = __toCommonJS(collide_exports);
40
- var import_boundingRectToCircle = __toESM(require("./boundingRectToCircle.cjs"), 1);
41
- var import_collideCircleCircle = __toESM(require("./collideCircleCircle.cjs"), 1);
42
- var import_collideCircleRect = __toESM(require("./collideCircleRect.cjs"), 1);
43
- var import_collidePointCircle = __toESM(require("./collidePointCircle.cjs"), 1);
44
- var import_collidePointRect = __toESM(require("./collidePointRect.cjs"), 1);
45
- var import_collideRectRect = __toESM(require("./collideRectRect.cjs"), 1);
46
- if (module.exports.default) module.exports = module.exports.default;
47
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/collide/index.ts"],
4
- "sourcesContent": ["/**\n * Inspired by http://www.jeffreythompson.org/collision-detection/\n */\nexport { default as boundingRectToCircle } from './boundingRectToCircle.js';\nexport { default as collideCircleCircle } from './collideCircleCircle.js';\nexport { default as collideCircleRect } from './collideCircleRect.js';\nexport { default as collidePointCircle } from './collidePointCircle.js';\nexport { default as collidePointRect } from './collidePointRect.js';\nexport { default as collideRectRect } from './collideRectRect.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kCAAgD;AAChD,iCAA+C;AAC/C,+BAA6C;AAC7C,gCAA8C;AAC9C,8BAA4C;AAC5C,6BAA2C;",
6
- "names": []
7
- }
@@ -1,202 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // packages/js-toolkit/utils/css/animate.ts
30
- var animate_exports = {};
31
- __export(animate_exports, {
32
- animate: () => animate
33
- });
34
- module.exports = __toCommonJS(animate_exports);
35
- var import_math = require("../math/index.cjs");
36
- var import_is = require("../is.cjs");
37
- var import_transform = __toESM(require("./transform.cjs"), 1);
38
- var import_scheduler = require("../scheduler.cjs");
39
- var import_tween = require("../tween.cjs");
40
- var import_utils = require("./utils.cjs");
41
- var import_string = require("../string/index.cjs");
42
- var id = 0;
43
- var running = /* @__PURE__ */ new WeakMap();
44
- var CSSUnitConverter = {
45
- "%": (value, getSizeRef) => value * getSizeRef() / 100,
46
- vh: (value) => value * window.innerHeight / 100,
47
- vw: (value) => value * window.innerWidth / 100,
48
- vmin: (value) => value * Math.min(window.innerWidth, window.innerHeight) / 100,
49
- vmax: (value) => value * Math.max(window.innerWidth, window.innerHeight) / 100
50
- };
51
- function getAnimationStepValue(val, getSizeRef) {
52
- if ((0, import_is.isNumber)(val)) {
53
- return val;
54
- }
55
- if (!val[1] || !CSSUnitConverter[val[1]]) {
56
- return val[0];
57
- }
58
- return CSSUnitConverter[val[1]](val[0], getSizeRef);
59
- }
60
- var generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(
61
- getAnimationStepValue(
62
- fromValue ?? 0,
63
- /* istanbul ignore next */
64
- () => element[sizeRef]
65
- ),
66
- getAnimationStepValue(toValue ?? 0, () => element[sizeRef]),
67
- progress
68
- );
69
- var widthBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetWidth");
70
- var heightBasedTranslateRenderStrategy = generateTranslateRenderStrategy("offsetHeight");
71
- var generateLerpRenderStrategy = (defaultValue) => (element, fromValue, toValue, progress) => (0, import_math.lerp)(fromValue ?? defaultValue, toValue ?? defaultValue, progress);
72
- var scaleRenderStrategy = generateLerpRenderStrategy(1);
73
- var degreesRenderStrategy = generateLerpRenderStrategy(0);
74
- var transformRenderStrategies = {
75
- x: widthBasedTranslateRenderStrategy,
76
- y: heightBasedTranslateRenderStrategy,
77
- z: widthBasedTranslateRenderStrategy,
78
- scale: scaleRenderStrategy,
79
- scaleX: scaleRenderStrategy,
80
- scaleY: scaleRenderStrategy,
81
- scaleZ: scaleRenderStrategy,
82
- skew: degreesRenderStrategy,
83
- skewX: degreesRenderStrategy,
84
- skewY: degreesRenderStrategy,
85
- rotate: degreesRenderStrategy,
86
- rotateX: degreesRenderStrategy,
87
- rotateY: degreesRenderStrategy,
88
- rotateZ: degreesRenderStrategy
89
- };
90
- function render(element, from, to, progress) {
91
- const stepProgress = to.easing((0, import_math.map)(progress, from.offset, to.offset, 0, 1));
92
- import_scheduler.domScheduler.read(() => {
93
- let opacity = false;
94
- if ((0, import_is.isDefined)(from.opacity) || (0, import_is.isDefined)(to.opacity)) {
95
- opacity = (0, import_math.map)(stepProgress, 0, 1, from.opacity ?? 1, to.opacity ?? 1);
96
- } else if (element.style.opacity) {
97
- opacity = "";
98
- }
99
- let transformOrigin = false;
100
- if ((0, import_is.isDefined)(to.transformOrigin)) {
101
- transformOrigin = to.transformOrigin;
102
- } else if (element.style.transformOrigin) {
103
- transformOrigin = "";
104
- }
105
- let customProperties = false;
106
- if ((0, import_is.isDefined)(from.vars) && (0, import_is.isDefined)(to.vars)) {
107
- customProperties = from.vars.map((customPropertyName) => {
108
- const customPropertyValue = (0, import_math.lerp)(
109
- from[customPropertyName],
110
- to[customPropertyName],
111
- stepProgress
112
- );
113
- return [customPropertyName, customPropertyValue];
114
- });
115
- }
116
- const props = Object.fromEntries(
117
- import_transform.TRANSFORM_PROPS.filter((name) => (0, import_is.isDefined)(from[name]) || (0, import_is.isDefined)(to[name])).map((name) => [
118
- name,
119
- transformRenderStrategies[name](element, from[name], to[name], stepProgress)
120
- ])
121
- );
122
- import_scheduler.domScheduler.write(() => {
123
- if (opacity !== false) {
124
- element.style.opacity = opacity;
125
- }
126
- if (transformOrigin !== false) {
127
- element.style.transformOrigin = transformOrigin;
128
- }
129
- if (customProperties !== false) {
130
- for (const customProperty of customProperties) {
131
- element.style.setProperty(customProperty[0], customProperty[1].toString());
132
- }
133
- }
134
- (0, import_transform.default)(element, props);
135
- });
136
- });
137
- }
138
- function singleAnimate(element, keyframes, options = {}) {
139
- const keyframesCount = keyframes.length - 1;
140
- const normalizedKeyframes = keyframes.map(
141
- (keyframe, index) => ({
142
- ...keyframe,
143
- offset: keyframe.offset ?? index / keyframesCount,
144
- easing: (0, import_tween.normalizeEase)(keyframe.easing),
145
- vars: Object.keys(keyframe).filter((key2) => (0, import_string.startsWith)(key2, "--"))
146
- })
147
- );
148
- if (!running.has(element)) {
149
- running.set(element, /* @__PURE__ */ new Map());
150
- }
151
- const key = `animate-${id}`;
152
- id += 1;
153
- function callback(progress) {
154
- let toIndex = 0;
155
- while (normalizedKeyframes[toIndex] && normalizedKeyframes[toIndex].offset <= progress && normalizedKeyframes[toIndex].offset !== 1) {
156
- toIndex += 1;
157
- }
158
- render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex], progress);
159
- }
160
- const controls = (0, import_tween.tween)(callback, {
161
- ...options,
162
- onStart() {
163
- if ((0, import_is.isFunction)(options.onStart)) {
164
- options.onStart();
165
- }
166
- const runningKeys = running.get(element);
167
- for (const [runningKey, runningPause] of runningKeys.entries()) {
168
- runningPause();
169
- runningKeys.delete(runningKey);
170
- }
171
- runningKeys.set(key, controls.pause);
172
- running.set(element, runningKeys);
173
- }
174
- });
175
- return controls;
176
- }
177
- function animate(elementOrElements, keyframes, options = {}) {
178
- const controls = (0, import_utils.eachElements)(
179
- elementOrElements,
180
- (element) => singleAnimate(element, keyframes, options)
181
- );
182
- const delegate = (key) => (
183
- // eslint-disable-next-line consistent-return
184
- (...args) => {
185
- if (key === "progress" && args.length === 0) {
186
- return controls[0][key]();
187
- }
188
- for (const control of controls) {
189
- control[key](...args);
190
- }
191
- }
192
- );
193
- return {
194
- start: delegate("start"),
195
- pause: delegate("pause"),
196
- finish: delegate("finish"),
197
- play: delegate("play"),
198
- progress: delegate("progress")
199
- };
200
- }
201
- if (module.exports.default) module.exports = module.exports.default;
202
- //# sourceMappingURL=animate.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/css/animate.ts"],
4
- "sourcesContent": ["import { lerp, map } from '../math/index.js';\nimport { isDefined, isFunction, isNumber } from '../is.js';\nimport transform, { TRANSFORM_PROPS } from './transform.js';\nimport { domScheduler as scheduler } from '../scheduler.js';\nimport { tween, normalizeEase } from '../tween.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\nimport { startsWith } from '../string/index.js';\nimport type { TransformProps } from './transform.js';\nimport type { EasingFunction } from '../math/index.js';\nimport type { BezierCurve, TweenOptions } from '../tween.js';\n\nexport type CSSCustomPropertyName = `--${string}`;\n\nexport type Keyframe = TransformProps & {\n opacity?: number;\n transformOrigin?: string;\n easing?: EasingFunction | BezierCurve;\n offset?: number;\n [key: CSSCustomPropertyName]: number;\n};\n\nexport type NormalizedKeyframe = Keyframe & {\n easing: EasingFunction;\n offset: number;\n vars: string[];\n};\n\nexport type Animate = {\n start: () => void;\n pause: () => void;\n play: () => void;\n finish: () => void;\n progress: (value?: number) => number;\n};\n\nlet id = 0;\nconst running = new WeakMap();\n\nconst CSSUnitConverter = {\n '%': (value, getSizeRef) => (value * getSizeRef()) / 100,\n vh: (value) => (value * window.innerHeight) / 100,\n vw: (value) => (value * window.innerWidth) / 100,\n vmin: (value) => (value * Math.min(window.innerWidth, window.innerHeight)) / 100,\n vmax: (value) => (value * Math.max(window.innerWidth, window.innerHeight)) / 100,\n};\n\n/**\n * Get the value from a step property.\n */\nfunction getAnimationStepValue(val: number | [number, string], getSizeRef: () => number): number {\n if (isNumber(val)) {\n return val;\n }\n\n if (!val[1] || !CSSUnitConverter[val[1]]) {\n return val[0];\n }\n\n return CSSUnitConverter[val[1]](val[0], getSizeRef);\n}\n\nconst generateTranslateRenderStrategy = (sizeRef) => (element, fromValue, toValue, progress) =>\n lerp(\n getAnimationStepValue(\n fromValue ?? 0,\n /* istanbul ignore next */\n () => element[sizeRef],\n ),\n getAnimationStepValue(toValue ?? 0, () => element[sizeRef]),\n progress,\n );\nconst widthBasedTranslateRenderStrategy = generateTranslateRenderStrategy('offsetWidth');\nconst heightBasedTranslateRenderStrategy = generateTranslateRenderStrategy('offsetHeight');\n\nconst generateLerpRenderStrategy = (defaultValue) => (element, fromValue, toValue, progress) =>\n lerp(fromValue ?? defaultValue, toValue ?? defaultValue, progress);\nconst scaleRenderStrategy = generateLerpRenderStrategy(1);\nconst degreesRenderStrategy = generateLerpRenderStrategy(0);\n\nconst transformRenderStrategies = {\n x: widthBasedTranslateRenderStrategy,\n y: heightBasedTranslateRenderStrategy,\n z: widthBasedTranslateRenderStrategy,\n scale: scaleRenderStrategy,\n scaleX: scaleRenderStrategy,\n scaleY: scaleRenderStrategy,\n scaleZ: scaleRenderStrategy,\n skew: degreesRenderStrategy,\n skewX: degreesRenderStrategy,\n skewY: degreesRenderStrategy,\n rotate: degreesRenderStrategy,\n rotateX: degreesRenderStrategy,\n rotateY: degreesRenderStrategy,\n rotateZ: degreesRenderStrategy,\n};\n\n/**\n * Render an element style based on 2 keyframes and a progress value.\n */\nfunction render(\n element: HTMLElement,\n from: NormalizedKeyframe,\n to: NormalizedKeyframe,\n progress: number,\n) {\n const stepProgress = to.easing(map(progress, from.offset, to.offset, 0, 1));\n\n scheduler.read(() => {\n let opacity: false | number | string = false;\n if (isDefined(from.opacity) || isDefined(to.opacity)) {\n opacity = map(stepProgress, 0, 1, from.opacity ?? 1, to.opacity ?? 1);\n } else if (element.style.opacity) {\n opacity = '';\n }\n\n let transformOrigin: false | string = false;\n if (isDefined(to.transformOrigin)) {\n transformOrigin = to.transformOrigin;\n } else if (element.style.transformOrigin) {\n transformOrigin = '';\n }\n\n let customProperties: false | [string, number][] = false;\n if (isDefined(from.vars) && isDefined(to.vars)) {\n customProperties = from.vars.map((customPropertyName) => {\n const customPropertyValue = lerp(\n from[customPropertyName],\n to[customPropertyName],\n stepProgress,\n );\n return [customPropertyName, customPropertyValue];\n });\n }\n\n const props = Object.fromEntries(\n TRANSFORM_PROPS.filter((name) => isDefined(from[name]) || isDefined(to[name])).map((name) => [\n name,\n transformRenderStrategies[name](element, from[name], to[name], stepProgress),\n ]),\n );\n scheduler.write(() => {\n if (opacity !== false) {\n // @ts-ignore\n element.style.opacity = opacity;\n }\n if (transformOrigin !== false) {\n element.style.transformOrigin = transformOrigin;\n }\n if (customProperties !== false) {\n for (const customProperty of customProperties) {\n element.style.setProperty(customProperty[0], customProperty[1].toString());\n }\n }\n transform(element, props);\n });\n });\n}\n\n/**\n * Animate an element.\n */\nfunction singleAnimate(\n element: HTMLElement,\n keyframes: Keyframe[],\n options: TweenOptions = {},\n): Animate {\n const keyframesCount = keyframes.length - 1;\n const normalizedKeyframes = keyframes.map(\n (keyframe, index): NormalizedKeyframe => ({\n ...keyframe,\n offset: keyframe.offset ?? index / keyframesCount,\n easing: normalizeEase(keyframe.easing),\n vars: Object.keys(keyframe).filter((key) => startsWith(key, '--')),\n }),\n );\n\n if (!running.has(element)) {\n running.set(element, new Map());\n }\n\n const key = `animate-${id}`;\n id += 1;\n\n /**\n * Set the progress value.\n */\n function callback(progress: number) {\n let toIndex = 0;\n while (\n normalizedKeyframes[toIndex] &&\n normalizedKeyframes[toIndex].offset <= progress &&\n normalizedKeyframes[toIndex].offset !== 1\n ) {\n toIndex += 1;\n }\n\n render(element, normalizedKeyframes[toIndex - 1], normalizedKeyframes[toIndex], progress);\n }\n\n const controls = tween(callback, {\n ...options,\n onStart() {\n if (isFunction(options.onStart)) {\n options.onStart();\n }\n // Stop running instances\n const runningKeys = running.get(element);\n for (const [runningKey, runningPause] of runningKeys.entries()) {\n runningPause();\n runningKeys.delete(runningKey);\n }\n runningKeys.set(key, controls.pause);\n running.set(element, runningKeys);\n },\n });\n\n return controls;\n}\n\n/**\n * Animate one or more elements.\n */\nexport function animate(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n keyframes: Keyframe[],\n options: TweenOptions = {},\n): Animate {\n const controls = eachElements(elementOrElements, (element) =>\n singleAnimate(element, keyframes, options),\n );\n\n const delegate =\n (key) =>\n // eslint-disable-next-line consistent-return\n (...args) => {\n if (key === 'progress' && args.length === 0) {\n return controls[0][key]();\n }\n\n for (const control of controls) {\n control[key](...args);\n }\n };\n\n return {\n start: delegate('start'),\n pause: delegate('pause'),\n finish: delegate('finish'),\n play: delegate('play'),\n progress: delegate('progress'),\n };\n}\n"],
5
- "mappings": "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",
6
- "names": ["scheduler", "transform", "key"]
7
- }
@@ -1,51 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/js-toolkit/utils/css/classes.ts
20
- var classes_exports = {};
21
- __export(classes_exports, {
22
- add: () => add,
23
- remove: () => remove,
24
- toggle: () => toggle
25
- });
26
- module.exports = __toCommonJS(classes_exports);
27
- var import_is = require("../is.cjs");
28
- var import_utils = require("./utils.cjs");
29
- function setClasses(element, classNames, method, forceToggle) {
30
- if (!element || !classNames) {
31
- return;
32
- }
33
- const normalizedClassNames = (0, import_is.isArray)(classNames) ? classNames : classNames.split(" ").filter((className) => className);
34
- if (method !== "toggle") {
35
- (0, import_utils.eachElements)(element, (el) => el.classList[method](...normalizedClassNames));
36
- } else {
37
- for (const className of normalizedClassNames)
38
- (0, import_utils.eachElements)(element, (el) => el.classList[method](className, forceToggle));
39
- }
40
- }
41
- function add(element, classNames) {
42
- setClasses(element, classNames, "add");
43
- }
44
- function remove(element, classNames) {
45
- setClasses(element, classNames, "remove");
46
- }
47
- function toggle(element, classNames, force) {
48
- setClasses(element, classNames, "toggle", force);
49
- }
50
- if (module.exports.default) module.exports = module.exports.default;
51
- //# sourceMappingURL=classes.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../packages/js-toolkit/utils/css/classes.ts"],
4
- "sourcesContent": ["import { isArray } from '../is.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\n/**\n * Manage a list of classes as string on an element.\n */\nfunction setClasses(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n method: 'add' | 'remove' | 'toggle',\n forceToggle?: boolean,\n) {\n if (!element || !classNames) {\n return;\n }\n\n const normalizedClassNames = isArray(classNames)\n ? classNames\n : classNames.split(' ').filter((className) => className);\n\n if (method !== 'toggle') {\n eachElements(element, (el) => el.classList[method](...normalizedClassNames));\n } else {\n for (const className of normalizedClassNames)\n eachElements(element, (el) => el.classList[method](className, forceToggle));\n }\n}\n\n/**\n * Add class names to an element.\n */\nexport function add(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'add');\n}\n\n/**\n * Remove class names from an element.\n */\nexport function remove(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'remove');\n}\n\n/**\n * Toggle class names from an element.\n */\nexport function toggle(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n force?: boolean,\n) {\n setClasses(element, classNames, 'toggle', force);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAwB;AAExB,mBAA6B;AAK7B,SAAS,WACP,SACA,YACA,QACA,aACA;AACA,MAAI,CAAC,WAAW,CAAC,YAAY;AAC3B;AAAA,EACF;AAEA,QAAM,2BAAuB,mBAAQ,UAAU,IAC3C,aACA,WAAW,MAAM,GAAG,EAAE,OAAO,CAAC,cAAc,SAAS;AAEzD,MAAI,WAAW,UAAU;AACvB,mCAAa,SAAS,CAAC,OAAO,GAAG,UAAU,MAAM,EAAE,GAAG,oBAAoB,CAAC;AAAA,EAC7E,OAAO;AACL,eAAW,aAAa;AACtB,qCAAa,SAAS,CAAC,OAAO,GAAG,UAAU,MAAM,EAAE,WAAW,WAAW,CAAC;AAAA,EAC9E;AACF;AAKO,SAAS,IACd,SACA,YACA;AACA,aAAW,SAAS,YAAY,KAAK;AACvC;AAKO,SAAS,OACd,SACA,YACA;AACA,aAAW,SAAS,YAAY,QAAQ;AAC1C;AAKO,SAAS,OACd,SACA,YACA,OACA;AACA,aAAW,SAAS,YAAY,UAAU,KAAK;AACjD;",
6
- "names": []
7
- }