@studiometa/js-toolkit 2.0.0-beta.11 → 2.0.0-beta.15

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 (159) hide show
  1. package/Base/index.cjs +295 -0
  2. package/Base/index.js +114 -194
  3. package/Base/managers/ChildrenManager.cjs +131 -0
  4. package/Base/managers/ChildrenManager.js +38 -57
  5. package/Base/managers/EventsManager.cjs +190 -0
  6. package/Base/managers/EventsManager.js +72 -112
  7. package/Base/managers/OptionsManager.cjs +177 -0
  8. package/Base/managers/OptionsManager.js +54 -88
  9. package/Base/managers/RefsManager.cjs +104 -0
  10. package/Base/managers/RefsManager.js +28 -38
  11. package/Base/managers/ServicesManager.cjs +138 -0
  12. package/Base/managers/ServicesManager.js +39 -67
  13. package/Base/utils.cjs +46 -0
  14. package/Base/utils.js +12 -11
  15. package/decorators/index.cjs +50 -0
  16. package/decorators/index.js +18 -8
  17. package/decorators/withBreakpointManager.cjs +92 -0
  18. package/decorators/withBreakpointManager.js +18 -39
  19. package/decorators/withBreakpointObserver.cjs +122 -0
  20. package/decorators/withBreakpointObserver.js +44 -86
  21. package/decorators/withDrag.cjs +60 -0
  22. package/decorators/withDrag.js +24 -26
  23. package/decorators/withExtraConfig.cjs +50 -0
  24. package/decorators/withExtraConfig.js +17 -12
  25. package/decorators/withIntersectionObserver.cjs +67 -0
  26. package/decorators/withIntersectionObserver.js +29 -32
  27. package/decorators/withMountWhenInView.cjs +74 -0
  28. package/decorators/withMountWhenInView.js +31 -52
  29. package/decorators/withScrolledInView.cjs +121 -0
  30. package/decorators/withScrolledInView.js +35 -39
  31. package/decorators/withVue2.cjs +65 -0
  32. package/decorators/withVue2.js +26 -32
  33. package/helpers/createApp.cjs +57 -0
  34. package/helpers/createApp.js +12 -12
  35. package/helpers/importOnInteraction.cjs +57 -0
  36. package/helpers/importOnInteraction.js +17 -18
  37. package/helpers/importWhenIdle.cjs +54 -0
  38. package/helpers/importWhenIdle.js +14 -17
  39. package/helpers/importWhenVisible.cjs +55 -0
  40. package/helpers/importWhenVisible.js +16 -18
  41. package/helpers/index.cjs +42 -0
  42. package/helpers/index.js +10 -4
  43. package/helpers/utils.cjs +40 -0
  44. package/helpers/utils.js +7 -6
  45. package/index.cjs +39 -0
  46. package/index.js +7 -4
  47. package/package.json +14 -4
  48. package/services/Service.cjs +81 -0
  49. package/services/Service.js +19 -32
  50. package/services/drag.cjs +200 -0
  51. package/services/drag.js +42 -66
  52. package/services/index.cjs +48 -0
  53. package/services/index.js +16 -7
  54. package/services/key.cjs +111 -0
  55. package/services/key.js +28 -36
  56. package/services/load.cjs +79 -0
  57. package/services/load.js +17 -19
  58. package/services/pointer.cjs +169 -0
  59. package/services/pointer.js +43 -60
  60. package/services/raf.cjs +90 -0
  61. package/services/raf.js +20 -28
  62. package/services/resize.cjs +115 -0
  63. package/services/resize.js +33 -42
  64. package/services/scroll.cjs +138 -0
  65. package/services/scroll.js +26 -35
  66. package/utils/collide/boundingRectToCircle.cjs +39 -0
  67. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  68. package/utils/collide/boundingRectToCircle.js +7 -10
  69. package/utils/collide/collideCircleCircle.cjs +39 -0
  70. package/utils/collide/collideCircleCircle.js +8 -7
  71. package/utils/collide/collideCircleRect.cjs +51 -0
  72. package/utils/collide/collideCircleRect.js +10 -12
  73. package/utils/collide/collidePointCircle.cjs +36 -0
  74. package/utils/collide/collidePointCircle.js +8 -5
  75. package/utils/collide/collidePointRect.cjs +33 -0
  76. package/utils/collide/collidePointRect.js +5 -2
  77. package/utils/collide/collideRectRect.cjs +33 -0
  78. package/utils/collide/collideRectRect.js +5 -2
  79. package/utils/collide/index.cjs +46 -0
  80. package/utils/collide/index.js +14 -6
  81. package/utils/css/classes.cjs +49 -0
  82. package/utils/css/classes.js +13 -12
  83. package/utils/css/index.cjs +42 -0
  84. package/utils/css/index.js +10 -6
  85. package/utils/css/matrix.cjs +35 -0
  86. package/utils/css/matrix.js +7 -5
  87. package/utils/css/styles.cjs +52 -0
  88. package/utils/css/styles.js +13 -12
  89. package/utils/css/transition.cjs +127 -0
  90. package/utils/css/transition.js +68 -117
  91. package/utils/debounce.cjs +39 -0
  92. package/utils/debounce.js +7 -9
  93. package/utils/focusTrap.cjs +89 -0
  94. package/utils/focusTrap.js +30 -21
  95. package/utils/history.cjs +96 -0
  96. package/utils/history.js +28 -57
  97. package/utils/index.cjs +58 -0
  98. package/utils/index.d.ts +1 -0
  99. package/utils/index.js +30 -11
  100. package/utils/keyCodes.cjs +40 -0
  101. package/utils/keyCodes.js +5 -2
  102. package/utils/math/clamp.cjs +33 -0
  103. package/utils/math/clamp.js +5 -2
  104. package/utils/math/clamp01.cjs +39 -0
  105. package/utils/math/clamp01.js +6 -3
  106. package/utils/math/damp.cjs +33 -0
  107. package/utils/math/damp.js +5 -4
  108. package/utils/math/ease.cjs +93 -0
  109. package/utils/math/ease.js +50 -25
  110. package/utils/math/index.cjs +49 -0
  111. package/utils/math/index.js +17 -8
  112. package/utils/math/inertiaFinalValue.cjs +42 -0
  113. package/utils/math/inertiaFinalValue.js +8 -10
  114. package/utils/math/lerp.cjs +33 -0
  115. package/utils/math/lerp.js +5 -2
  116. package/utils/math/map.cjs +33 -0
  117. package/utils/math/map.js +5 -2
  118. package/utils/math/round.cjs +33 -0
  119. package/utils/math/round.js +5 -3
  120. package/utils/memoize.cjs +48 -0
  121. package/utils/memoize.js +10 -19
  122. package/utils/nextFrame.cjs +45 -0
  123. package/utils/nextFrame.js +14 -9
  124. package/utils/object/autoBind.cjs +56 -0
  125. package/utils/object/autoBind.js +12 -22
  126. package/utils/object/getAllProperties.cjs +42 -0
  127. package/utils/object/getAllProperties.js +10 -13
  128. package/utils/object/index.cjs +40 -0
  129. package/utils/object/index.js +8 -3
  130. package/utils/object/isObject.cjs +33 -0
  131. package/utils/object/isObject.js +6 -3
  132. package/utils/scrollTo.cjs +87 -0
  133. package/utils/scrollTo.js +20 -40
  134. package/utils/string/index.cjs +54 -0
  135. package/utils/string/index.js +22 -10
  136. package/utils/string/withLeadingCharacters.cjs +39 -0
  137. package/utils/string/withLeadingCharacters.js +7 -4
  138. package/utils/string/withLeadingSlash.cjs +39 -0
  139. package/utils/string/withLeadingSlash.js +7 -4
  140. package/utils/string/withTrailingCharacters.cjs +39 -0
  141. package/utils/string/withTrailingCharacters.js +7 -4
  142. package/utils/string/withTrailingSlash.cjs +39 -0
  143. package/utils/string/withTrailingSlash.js +7 -4
  144. package/utils/string/withoutLeadingCharacters.cjs +33 -0
  145. package/utils/string/withoutLeadingCharacters.js +6 -3
  146. package/utils/string/withoutLeadingCharactersRecursive.cjs +44 -0
  147. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  148. package/utils/string/withoutLeadingSlash.cjs +39 -0
  149. package/utils/string/withoutLeadingSlash.js +7 -4
  150. package/utils/string/withoutTrailingCharacters.cjs +33 -0
  151. package/utils/string/withoutTrailingCharacters.js +6 -3
  152. package/utils/string/withoutTrailingCharactersRecursive.cjs +44 -0
  153. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  154. package/utils/string/withoutTrailingSlash.cjs +39 -0
  155. package/utils/string/withoutTrailingSlash.js +7 -4
  156. package/utils/throttle.cjs +41 -0
  157. package/utils/throttle.js +9 -9
  158. package/index.modern.js +0 -1
  159. package/index.umd.js +0 -1
@@ -0,0 +1,74 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __reExport = (target, module2, copyDefault, desc) => {
12
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
+ for (let key of __getOwnPropNames(module2))
14
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
16
+ }
17
+ return target;
18
+ };
19
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
+ return (module2, temp) => {
21
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
+ };
23
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
24
+ var __publicField = (obj, key, value) => {
25
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ return value;
27
+ };
28
+
29
+ // packages/js-toolkit/decorators/withMountWhenInView.js
30
+ var withMountWhenInView_exports = {};
31
+ __export(withMountWhenInView_exports, {
32
+ default: () => withMountWhenInView
33
+ });
34
+ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
35
+ var _a, _b;
36
+ return _b = class extends BaseClass {
37
+ constructor(element) {
38
+ super(element);
39
+ __publicField(this, "__isVisible", false);
40
+ __publicField(this, "__observer");
41
+ this.__observer = new IntersectionObserver((entries) => {
42
+ const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
43
+ if (this.__isVisible !== isVisible) {
44
+ this.__isVisible = isVisible;
45
+ if (isVisible) {
46
+ this.$mount();
47
+ } else {
48
+ setTimeout(() => this.$destroy());
49
+ }
50
+ }
51
+ }, { ...defaultOptions, ...this.$options.intersectionObserver });
52
+ this.__observer.observe(this.$el);
53
+ this.$on("terminated", () => {
54
+ this.__observer.disconnect();
55
+ });
56
+ return this;
57
+ }
58
+ $mount() {
59
+ if (this.__isVisible) {
60
+ super.$mount();
61
+ }
62
+ return this;
63
+ }
64
+ }, __publicField(_b, "config", {
65
+ ...BaseClass.config,
66
+ name: `${BaseClass.config.name}WithMountWhenInView`,
67
+ options: {
68
+ ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
69
+ intersectionObserver: Object
70
+ }
71
+ }), _b;
72
+ }
73
+ module.exports = __toCommonJS(withMountWhenInView_exports);
74
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,69 +1,48 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
3
- import _classPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10
-
11
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
12
-
13
- export default function withMountWhenInView(BaseClass) {
14
- var _class, _isVisible, _observer, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config2;
15
-
16
- var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
17
- threshold: [0, 1]
18
- };
19
- return _temp = (_isVisible = new WeakMap(), _observer = new WeakMap(), _class = class extends BaseClass {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
8
+ var _a, _b;
9
+ return _b = class extends BaseClass {
20
10
  constructor(element) {
21
11
  super(element);
22
-
23
- _classPrivateFieldInitSpec(this, _isVisible, {
24
- writable: true,
25
- value: false
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _observer, {
29
- writable: true,
30
- value: void 0
31
- });
32
-
33
- _classPrivateFieldSet(this, _observer, new IntersectionObserver(entries => {
34
- var isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
35
-
36
- if (_classPrivateFieldGet(this, _isVisible) !== isVisible) {
37
- _classPrivateFieldSet(this, _isVisible, isVisible);
38
-
12
+ __publicField(this, "__isVisible", false);
13
+ __publicField(this, "__observer");
14
+ this.__observer = new IntersectionObserver((entries) => {
15
+ const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
16
+ if (this.__isVisible !== isVisible) {
17
+ this.__isVisible = isVisible;
39
18
  if (isVisible) {
40
19
  this.$mount();
41
20
  } else {
42
21
  setTimeout(() => this.$destroy());
43
22
  }
44
23
  }
45
- }, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver)));
46
-
47
- _classPrivateFieldGet(this, _observer).observe(this.$el);
48
-
49
- this.$on('terminated', () => {
50
- _classPrivateFieldGet(this, _observer).disconnect();
24
+ }, { ...defaultOptions, ...this.$options.intersectionObserver });
25
+ this.__observer.observe(this.$el);
26
+ this.$on("terminated", () => {
27
+ this.__observer.disconnect();
51
28
  });
52
29
  return this;
53
30
  }
54
-
55
31
  $mount() {
56
- if (_classPrivateFieldGet(this, _isVisible)) {
32
+ if (this.__isVisible) {
57
33
  super.$mount();
58
34
  }
59
-
60
35
  return this;
61
36
  }
62
-
63
- }), _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
64
- name: "".concat((_BaseClass$config$nam = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config = BaseClass.config) === null || _BaseClass$config === void 0 ? void 0 : _BaseClass$config.name) !== null && _BaseClass$config$nam !== void 0 ? _BaseClass$config$nam : '', "WithMountWhenInView"),
65
- options: _objectSpread(_objectSpread({}, (BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.options) || {}), {}, {
37
+ }, __publicField(_b, "config", {
38
+ ...BaseClass.config,
39
+ name: `${BaseClass.config.name}WithMountWhenInView`,
40
+ options: {
41
+ ...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
66
42
  intersectionObserver: Object
67
- })
68
- })), _temp;
69
- }
43
+ }
44
+ }), _b;
45
+ }
46
+ export {
47
+ withMountWhenInView as default
48
+ };
@@ -0,0 +1,121 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __reExport = (target, module2, copyDefault, desc) => {
14
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
15
+ for (let key of __getOwnPropNames(module2))
16
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
17
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
18
+ }
19
+ return target;
20
+ };
21
+ var __toESM = (module2, isNodeMode) => {
22
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
23
+ };
24
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
25
+ return (module2, temp) => {
26
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
27
+ };
28
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
29
+ var __publicField = (obj, key, value) => {
30
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+ return value;
32
+ };
33
+
34
+ // packages/js-toolkit/decorators/withScrolledInView.js
35
+ var withScrolledInView_exports = {};
36
+ __export(withScrolledInView_exports, {
37
+ default: () => withScrolledInView
38
+ });
39
+ var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
40
+ var import_utils = require("../utils/index.cjs");
41
+ function withScrolledInView(BaseClass, options) {
42
+ var _a;
43
+ return _a = class extends (0, import_withMountWhenInView.default)(BaseClass, options) {
44
+ constructor() {
45
+ super(...arguments);
46
+ __publicField(this, "__props", {
47
+ start: {
48
+ x: 0,
49
+ y: 0
50
+ },
51
+ end: {
52
+ x: 0,
53
+ y: 0
54
+ },
55
+ current: {
56
+ x: 0,
57
+ y: 0
58
+ },
59
+ progress: {
60
+ x: 0,
61
+ y: 0
62
+ },
63
+ dampedProgress: {
64
+ x: 0,
65
+ y: 0
66
+ }
67
+ });
68
+ __publicField(this, "dampFactor", 0.1);
69
+ __publicField(this, "dampPrecision", 1e-3);
70
+ }
71
+ mounted() {
72
+ this.__setProps();
73
+ }
74
+ resized() {
75
+ this.__setProps();
76
+ }
77
+ scrolled(props) {
78
+ if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
79
+ this.$services.enable("ticked");
80
+ }
81
+ }
82
+ ticked() {
83
+ this.__props.current.x = (0, import_utils.clamp)(window.pageXOffset, this.__props.start.x, this.__props.end.x);
84
+ this.__props.progress.x = (0, import_utils.clamp01)((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
85
+ this.__props.dampedProgress.x = (0, import_utils.damp)(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
86
+ this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
87
+ this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
88
+ this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
89
+ if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
90
+ this.$services.disable("ticked");
91
+ }
92
+ this.__callMethod("scrolledInView", this.__props);
93
+ }
94
+ __setProps() {
95
+ const sizes = this.$el.getBoundingClientRect();
96
+ const yEnd = sizes.top + window.pageYOffset + sizes.height;
97
+ const yStart = yEnd - window.innerHeight - sizes.height;
98
+ const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
99
+ const yProgress = (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
100
+ const xEnd = sizes.left + window.pageXOffset + sizes.width;
101
+ const xStart = xEnd - window.innerWidth - sizes.width;
102
+ const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
103
+ const xProgress = (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
104
+ this.__props.start.x = xStart;
105
+ this.__props.start.y = yStart;
106
+ this.__props.end.x = xEnd;
107
+ this.__props.end.y = yEnd;
108
+ this.__props.current.x = xCurrent;
109
+ this.__props.current.y = yCurrent;
110
+ this.__props.progress.x = xProgress;
111
+ this.__props.progress.y = yProgress;
112
+ this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
113
+ this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
114
+ }
115
+ }, __publicField(_a, "config", {
116
+ name: `${BaseClass.config.name}WithMountWhenInView`,
117
+ emits: ["scrolledInView"]
118
+ }), _a;
119
+ }
120
+ module.exports = __toCommonJS(withScrolledInView_exports);
121
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,14 +1,17 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import withMountWhenInView from './withMountWhenInView.js';
3
- import { damp, clamp, clamp01 } from '../utils/index.js';
4
- export default function withScrolledInView(BaseClass, options) {
5
- var _class, _temp;
6
-
7
- return _temp = _class = class extends withMountWhenInView(BaseClass, options) {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import withMountWhenInView from "./withMountWhenInView.js";
8
+ import { damp, clamp, clamp01 } from "../utils/index.js";
9
+ function withScrolledInView(BaseClass, options) {
10
+ var _a;
11
+ return _a = class extends withMountWhenInView(BaseClass, options) {
8
12
  constructor() {
9
13
  super(...arguments);
10
-
11
- _defineProperty(this, "__props", {
14
+ __publicField(this, "__props", {
12
15
  start: {
13
16
  x: 0,
14
17
  y: 0
@@ -30,26 +33,20 @@ export default function withScrolledInView(BaseClass, options) {
30
33
  y: 0
31
34
  }
32
35
  });
33
-
34
- _defineProperty(this, "dampFactor", 0.1);
35
-
36
- _defineProperty(this, "dampPrecision", 0.001);
36
+ __publicField(this, "dampFactor", 0.1);
37
+ __publicField(this, "dampPrecision", 1e-3);
37
38
  }
38
-
39
39
  mounted() {
40
40
  this.__setProps();
41
41
  }
42
-
43
42
  resized() {
44
43
  this.__setProps();
45
44
  }
46
-
47
45
  scrolled(props) {
48
- if (!this.$services.has('ticked') && props.changed.y || props.changed.x) {
49
- this.$services.enable('ticked');
46
+ if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
47
+ this.$services.enable("ticked");
50
48
  }
51
49
  }
52
-
53
50
  ticked() {
54
51
  this.__props.current.x = clamp(window.pageXOffset, this.__props.start.x, this.__props.end.x);
55
52
  this.__props.progress.x = clamp01((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
@@ -57,24 +54,21 @@ export default function withScrolledInView(BaseClass, options) {
57
54
  this.__props.current.y = clamp(window.pageYOffset, this.__props.start.y, this.__props.end.y);
58
55
  this.__props.progress.y = clamp01((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
59
56
  this.__props.dampedProgress.y = damp(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
60
-
61
57
  if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
62
- this.$services.disable('ticked');
58
+ this.$services.disable("ticked");
63
59
  }
64
-
65
- this.__callMethod('scrolledInView', this.__props);
60
+ this.__callMethod("scrolledInView", this.__props);
66
61
  }
67
-
68
62
  __setProps() {
69
- var sizes = this.$el.getBoundingClientRect();
70
- var yEnd = sizes.top + window.pageYOffset + sizes.height;
71
- var yStart = yEnd - window.innerHeight - sizes.height;
72
- var yCurrent = clamp(window.pageYOffset, yStart, yEnd);
73
- var yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
74
- var xEnd = sizes.left + window.pageXOffset + sizes.width;
75
- var xStart = xEnd - window.innerWidth - sizes.width;
76
- var xCurrent = clamp(window.pageXOffset, xStart, xEnd);
77
- var xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
63
+ const sizes = this.$el.getBoundingClientRect();
64
+ const yEnd = sizes.top + window.pageYOffset + sizes.height;
65
+ const yStart = yEnd - window.innerHeight - sizes.height;
66
+ const yCurrent = clamp(window.pageYOffset, yStart, yEnd);
67
+ const yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
68
+ const xEnd = sizes.left + window.pageXOffset + sizes.width;
69
+ const xStart = xEnd - window.innerWidth - sizes.width;
70
+ const xCurrent = clamp(window.pageXOffset, xStart, xEnd);
71
+ const xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
78
72
  this.__props.start.x = xStart;
79
73
  this.__props.start.y = yStart;
80
74
  this.__props.end.x = xEnd;
@@ -86,9 +80,11 @@ export default function withScrolledInView(BaseClass, options) {
86
80
  this.__props.dampedProgress.x = damp(xProgress, this.__props.dampedProgress.x);
87
81
  this.__props.dampedProgress.y = damp(yProgress, this.__props.dampedProgress.y);
88
82
  }
89
-
90
- }, _defineProperty(_class, "config", {
91
- name: "".concat(BaseClass.config.name, "WithMountWhenInView"),
92
- emits: ['scrolledInView']
93
- }), _temp;
94
- }
83
+ }, __publicField(_a, "config", {
84
+ name: `${BaseClass.config.name}WithMountWhenInView`,
85
+ emits: ["scrolledInView"]
86
+ }), _a;
87
+ }
88
+ export {
89
+ withScrolledInView as default
90
+ };
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __reExport = (target, module2, copyDefault, desc) => {
12
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
+ for (let key of __getOwnPropNames(module2))
14
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
16
+ }
17
+ return target;
18
+ };
19
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
+ return (module2, temp) => {
21
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
+ };
23
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
24
+ var __publicField = (obj, key, value) => {
25
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
26
+ return value;
27
+ };
28
+
29
+ // packages/js-toolkit/decorators/withVue2.js
30
+ var withVue2_exports = {};
31
+ __export(withVue2_exports, {
32
+ default: () => withVue2_default
33
+ });
34
+ var withVue2_default = (BaseClass, Vue) => {
35
+ var _a, _b, _c;
36
+ return _c = class extends BaseClass {
37
+ constructor(element) {
38
+ super(element);
39
+ __publicField(this, "$vue");
40
+ const { vueConfig } = this.constructor;
41
+ if (!vueConfig) {
42
+ throw new Error("[withVue] You must define a `vueConfig` object.");
43
+ }
44
+ if (typeof vueConfig.render !== "function") {
45
+ throw new Error("[withVue] You must define a `render` function in vueConfig.");
46
+ }
47
+ this.$vue = new Vue(vueConfig);
48
+ this.$on("mounted", () => {
49
+ if (!(this.$refs.vue instanceof HTMLElement)) {
50
+ throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
51
+ }
52
+ this.$vue.$mount(this.$refs.vue);
53
+ });
54
+ this.$on("destroyed", () => {
55
+ this.$vue.$destroy();
56
+ });
57
+ }
58
+ }, __publicField(_c, "config", {
59
+ ...BaseClass.config,
60
+ name: `${BaseClass.config.name}WithVue`,
61
+ refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
62
+ }), __publicField(_c, "vueConfig"), _c;
63
+ };
64
+ module.exports = __toCommonJS(withVue2_exports);
65
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,45 +1,39 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- export default ((BaseClass, Vue) => {
8
- var _class, _temp, _BaseClass$config$nam, _BaseClass$config, _BaseClass$config$ref, _BaseClass$config2;
9
-
10
- return _temp = _class = class WithVue2 extends BaseClass {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ var withVue2_default = (BaseClass, Vue) => {
8
+ var _a, _b, _c;
9
+ return _c = class extends BaseClass {
11
10
  constructor(element) {
12
11
  super(element);
13
-
14
- _defineProperty(this, "$vue", void 0);
15
-
16
- var {
17
- vueConfig
18
- } = this.constructor;
19
-
12
+ __publicField(this, "$vue");
13
+ const { vueConfig } = this.constructor;
20
14
  if (!vueConfig) {
21
- throw new Error('[withVue] You must define a `vueConfig` object.');
15
+ throw new Error("[withVue] You must define a `vueConfig` object.");
22
16
  }
23
-
24
- if (typeof vueConfig.render !== 'function') {
25
- throw new Error('[withVue] You must define a `render` function in vueConfig.');
17
+ if (typeof vueConfig.render !== "function") {
18
+ throw new Error("[withVue] You must define a `render` function in vueConfig.");
26
19
  }
27
-
28
20
  this.$vue = new Vue(vueConfig);
29
- this.$on('mounted', () => {
21
+ this.$on("mounted", () => {
30
22
  if (!(this.$refs.vue instanceof HTMLElement)) {
31
- throw new Error('[withVue] The `vue` refs must be a single HTMLElement.');
23
+ throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
32
24
  }
33
-
34
25
  this.$vue.$mount(this.$refs.vue);
35
26
  });
36
- this.$on('destroyed', () => {
27
+ this.$on("destroyed", () => {
37
28
  this.$vue.$destroy();
38
29
  });
39
30
  }
40
-
41
- }, _defineProperty(_class, "config", _objectSpread(_objectSpread({}, BaseClass.config || {}), {}, {
42
- name: "".concat((_BaseClass$config$nam = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config = BaseClass.config) === null || _BaseClass$config === void 0 ? void 0 : _BaseClass$config.name) !== null && _BaseClass$config$nam !== void 0 ? _BaseClass$config$nam : '', "WithVue"),
43
- refs: [...((_BaseClass$config$ref = BaseClass === null || BaseClass === void 0 ? void 0 : (_BaseClass$config2 = BaseClass.config) === null || _BaseClass$config2 === void 0 ? void 0 : _BaseClass$config2.refs) !== null && _BaseClass$config$ref !== void 0 ? _BaseClass$config$ref : []), 'vue']
44
- })), _defineProperty(_class, "vueConfig", void 0), _temp;
45
- });
31
+ }, __publicField(_c, "config", {
32
+ ...BaseClass.config,
33
+ name: `${BaseClass.config.name}WithVue`,
34
+ refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
35
+ }), __publicField(_c, "vueConfig"), _c;
36
+ };
37
+ export {
38
+ withVue2_default as default
39
+ };
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // packages/js-toolkit/helpers/createApp.js
25
+ var createApp_exports = {};
26
+ __export(createApp_exports, {
27
+ default: () => createApp
28
+ });
29
+ function createApp(App, rootElement) {
30
+ let isLoaded = document.readyState === "complete";
31
+ let app;
32
+ if (!isLoaded) {
33
+ document.addEventListener("readystatechange", () => {
34
+ if (document.readyState === "complete") {
35
+ app = new App(rootElement).$mount();
36
+ isLoaded = true;
37
+ }
38
+ });
39
+ } else {
40
+ app = new App(rootElement).$mount();
41
+ }
42
+ const promise = new Promise((resolve) => {
43
+ document.addEventListener("readystatechange", () => {
44
+ if (document.readyState === "complete") {
45
+ setTimeout(() => resolve(app), 0);
46
+ }
47
+ });
48
+ });
49
+ return function useApp() {
50
+ if (isLoaded) {
51
+ return Promise.resolve(app);
52
+ }
53
+ return promise;
54
+ };
55
+ }
56
+ module.exports = __toCommonJS(createApp_exports);
57
+ if (module.exports.default) module.exports = module.exports.default;
@@ -1,10 +1,9 @@
1
- export default function createApp(App, rootElement) {
2
- var isLoaded = document.readyState === 'complete';
3
- var app;
4
-
1
+ function createApp(App, rootElement) {
2
+ let isLoaded = document.readyState === "complete";
3
+ let app;
5
4
  if (!isLoaded) {
6
- document.addEventListener('readystatechange', () => {
7
- if (document.readyState === 'complete') {
5
+ document.addEventListener("readystatechange", () => {
6
+ if (document.readyState === "complete") {
8
7
  app = new App(rootElement).$mount();
9
8
  isLoaded = true;
10
9
  }
@@ -12,10 +11,9 @@ export default function createApp(App, rootElement) {
12
11
  } else {
13
12
  app = new App(rootElement).$mount();
14
13
  }
15
-
16
- var promise = new Promise(resolve => {
17
- document.addEventListener('readystatechange', () => {
18
- if (document.readyState === 'complete') {
14
+ const promise = new Promise((resolve) => {
15
+ document.addEventListener("readystatechange", () => {
16
+ if (document.readyState === "complete") {
19
17
  setTimeout(() => resolve(app), 0);
20
18
  }
21
19
  });
@@ -24,7 +22,9 @@ export default function createApp(App, rootElement) {
24
22
  if (isLoaded) {
25
23
  return Promise.resolve(app);
26
24
  }
27
-
28
25
  return promise;
29
26
  };
30
- }
27
+ }
28
+ export {
29
+ createApp as default
30
+ };