@studiometa/js-toolkit 2.0.0-beta.12 → 2.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +72 -64
- package/Base/index.js +60 -54
- package/Base/managers/ChildrenManager.cjs +20 -11
- package/Base/managers/ChildrenManager.js +15 -8
- package/Base/managers/EventsManager.cjs +56 -48
- package/Base/managers/EventsManager.js +50 -44
- package/Base/managers/OptionsManager.cjs +38 -28
- package/Base/managers/OptionsManager.js +35 -27
- package/Base/managers/RefsManager.cjs +14 -6
- package/Base/managers/RefsManager.js +10 -4
- package/Base/managers/ServicesManager.cjs +27 -19
- package/Base/managers/ServicesManager.js +14 -8
- package/Base/utils.cjs +3 -0
- package/decorators/index.cjs +11 -8
- package/decorators/withBreakpointManager.cjs +5 -2
- package/decorators/withBreakpointObserver.cjs +20 -12
- package/decorators/withBreakpointObserver.js +17 -11
- package/decorators/withDrag.cjs +15 -7
- package/decorators/withDrag.js +12 -6
- package/decorators/withExtraConfig.cjs +11 -3
- package/decorators/withExtraConfig.js +9 -3
- package/decorators/withIntersectionObserver.cjs +23 -15
- package/decorators/withIntersectionObserver.js +21 -15
- package/decorators/withMountWhenInView.cjs +26 -18
- package/decorators/withMountWhenInView.js +24 -18
- package/decorators/withScrolledInView.cjs +43 -32
- package/decorators/withScrolledInView.js +39 -30
- package/decorators/withVue2.cjs +16 -9
- package/decorators/withVue2.js +14 -9
- package/helpers/createApp.cjs +3 -0
- package/helpers/importOnInteraction.cjs +5 -2
- package/helpers/importOnInteraction.js +1 -1
- package/helpers/importWhenIdle.cjs +6 -2
- package/helpers/importWhenIdle.js +3 -2
- package/helpers/importWhenVisible.cjs +5 -2
- package/helpers/importWhenVisible.js +1 -1
- package/helpers/index.cjs +7 -4
- package/helpers/utils.cjs +4 -1
- package/index.cjs +7 -4
- package/package.json +1 -2
- package/services/Service.cjs +11 -3
- package/services/Service.js +7 -1
- package/services/drag.cjs +70 -41
- package/services/drag.d.ts +1 -0
- package/services/drag.js +60 -33
- package/services/index.cjs +10 -7
- package/services/key.cjs +35 -23
- package/services/key.js +27 -17
- package/services/load.cjs +19 -8
- package/services/load.js +12 -3
- package/services/pointer.cjs +45 -33
- package/services/pointer.js +38 -28
- package/services/raf.cjs +24 -13
- package/services/raf.js +16 -7
- package/services/resize.cjs +24 -13
- package/services/resize.js +16 -7
- package/services/scroll.cjs +44 -33
- package/services/scroll.js +36 -27
- package/utils/collide/boundingRectToCircle.cjs +3 -0
- package/utils/collide/collideCircleCircle.cjs +3 -0
- package/utils/collide/collideCircleRect.cjs +3 -0
- package/utils/collide/collidePointCircle.cjs +3 -0
- package/utils/collide/collidePointRect.cjs +3 -0
- package/utils/collide/collideRectRect.cjs +3 -0
- package/utils/collide/index.cjs +9 -6
- package/utils/css/classes.cjs +3 -0
- package/utils/css/index.cjs +7 -4
- package/utils/css/matrix.cjs +5 -1
- package/utils/css/matrix.js +2 -1
- package/utils/css/styles.cjs +4 -1
- package/utils/css/transition.cjs +16 -8
- package/utils/css/transition.js +8 -2
- package/utils/debounce.cjs +3 -0
- package/utils/focusTrap.cjs +6 -3
- package/utils/history.cjs +4 -1
- package/utils/index.cjs +15 -12
- package/utils/keyCodes.cjs +3 -0
- package/utils/math/clamp.cjs +3 -0
- package/utils/math/clamp01.cjs +4 -1
- package/utils/math/damp.cjs +3 -0
- package/utils/math/ease.cjs +17 -14
- package/utils/math/index.cjs +11 -8
- package/utils/math/inertiaFinalValue.cjs +3 -0
- package/utils/math/lerp.cjs +3 -0
- package/utils/math/map.cjs +3 -0
- package/utils/math/round.cjs +3 -0
- package/utils/memoize.cjs +3 -0
- package/utils/nextFrame.cjs +3 -0
- package/utils/object/autoBind.cjs +4 -1
- package/utils/object/getAllProperties.cjs +3 -0
- package/utils/object/index.cjs +6 -3
- package/utils/object/isObject.cjs +3 -0
- package/utils/scrollTo.cjs +4 -1
- package/utils/string/index.cjs +13 -10
- package/utils/string/withLeadingCharacters.cjs +4 -1
- package/utils/string/withLeadingSlash.cjs +4 -1
- package/utils/string/withTrailingCharacters.cjs +4 -1
- package/utils/string/withTrailingSlash.cjs +4 -1
- package/utils/string/withoutLeadingCharacters.cjs +3 -0
- package/utils/string/withoutLeadingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutLeadingSlash.cjs +4 -1
- package/utils/string/withoutTrailingCharacters.cjs +3 -0
- package/utils/string/withoutTrailingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutTrailingSlash.cjs +4 -1
- package/utils/throttle.cjs +3 -0
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
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;
|
|
7
8
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -25,11 +26,17 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
25
26
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
27
|
};
|
|
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/withBreakpointObserver.js
|
|
28
35
|
var withBreakpointObserver_exports = {};
|
|
29
36
|
__export(withBreakpointObserver_exports, {
|
|
30
37
|
default: () => withBreakpointObserver
|
|
31
38
|
});
|
|
32
|
-
var import_resize = __toESM(require("../services/resize.
|
|
39
|
+
var import_resize = __toESM(require("../services/resize.cjs"), 1);
|
|
33
40
|
function testBreakpoints(instance, breakpoint = (0, import_resize.default)().props().breakpoint) {
|
|
34
41
|
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
35
42
|
const isInActiveBreakpoint = activeBreakpoints && activeBreakpoints.split(" ").includes(breakpoint);
|
|
@@ -64,16 +71,8 @@ function addToResize(key, instance) {
|
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
function withBreakpointObserver(BaseClass) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...BaseClass.config || {},
|
|
70
|
-
name: `${BaseClass?.config?.name ?? ""}WithBreakpointObserver`,
|
|
71
|
-
options: {
|
|
72
|
-
...BaseClass?.config?.options || {},
|
|
73
|
-
activeBreakpoints: String,
|
|
74
|
-
inactiveBreakpoints: String
|
|
75
|
-
}
|
|
76
|
-
};
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return _b = class extends BaseClass {
|
|
77
76
|
constructor(element) {
|
|
78
77
|
super(element);
|
|
79
78
|
const { remove, props } = (0, import_resize.default)();
|
|
@@ -109,6 +108,15 @@ function withBreakpointObserver(BaseClass) {
|
|
|
109
108
|
}
|
|
110
109
|
return this;
|
|
111
110
|
}
|
|
112
|
-
}
|
|
111
|
+
}, __publicField(_b, "config", {
|
|
112
|
+
...BaseClass.config,
|
|
113
|
+
name: `${BaseClass.config.name}WithBreakpointObserver`,
|
|
114
|
+
options: {
|
|
115
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
116
|
+
activeBreakpoints: String,
|
|
117
|
+
inactiveBreakpoints: String
|
|
118
|
+
}
|
|
119
|
+
}), _b;
|
|
113
120
|
}
|
|
114
121
|
module.exports = __toCommonJS(withBreakpointObserver_exports);
|
|
122
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
};
|
|
1
7
|
import useResize from "../services/resize.js";
|
|
2
8
|
function testBreakpoints(instance, breakpoint = useResize().props().breakpoint) {
|
|
3
9
|
const { activeBreakpoints, inactiveBreakpoints } = instance.$options;
|
|
@@ -33,16 +39,8 @@ function addToResize(key, instance) {
|
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
function withBreakpointObserver(BaseClass) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...BaseClass.config || {},
|
|
39
|
-
name: `${BaseClass?.config?.name ?? ""}WithBreakpointObserver`,
|
|
40
|
-
options: {
|
|
41
|
-
...BaseClass?.config?.options || {},
|
|
42
|
-
activeBreakpoints: String,
|
|
43
|
-
inactiveBreakpoints: String
|
|
44
|
-
}
|
|
45
|
-
};
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return _b = class extends BaseClass {
|
|
46
44
|
constructor(element) {
|
|
47
45
|
super(element);
|
|
48
46
|
const { remove, props } = useResize();
|
|
@@ -78,7 +76,15 @@ function withBreakpointObserver(BaseClass) {
|
|
|
78
76
|
}
|
|
79
77
|
return this;
|
|
80
78
|
}
|
|
81
|
-
}
|
|
79
|
+
}, __publicField(_b, "config", {
|
|
80
|
+
...BaseClass.config,
|
|
81
|
+
name: `${BaseClass.config.name}WithBreakpointObserver`,
|
|
82
|
+
options: {
|
|
83
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
84
|
+
activeBreakpoints: String,
|
|
85
|
+
inactiveBreakpoints: String
|
|
86
|
+
}
|
|
87
|
+
}), _b;
|
|
82
88
|
}
|
|
83
89
|
export {
|
|
84
90
|
withBreakpointObserver as default
|
package/decorators/withDrag.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
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;
|
|
7
8
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -25,17 +26,20 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
25
26
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
27
|
};
|
|
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/withDrag.js
|
|
28
35
|
var withDrag_exports = {};
|
|
29
36
|
__export(withDrag_exports, {
|
|
30
37
|
default: () => withDrag
|
|
31
38
|
});
|
|
32
|
-
var import_drag = __toESM(require("../services/drag.
|
|
39
|
+
var import_drag = __toESM(require("../services/drag.cjs"), 1);
|
|
33
40
|
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: `${BaseClass.config.name}WithDrag`,
|
|
37
|
-
emits: ["dragged"]
|
|
38
|
-
};
|
|
41
|
+
var _a;
|
|
42
|
+
return _a = class extends BaseClass {
|
|
39
43
|
constructor(el) {
|
|
40
44
|
super(el);
|
|
41
45
|
this.$on("mounted", () => {
|
|
@@ -47,6 +51,10 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
|
|
|
47
51
|
this.$services.unregister("dragged");
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
|
-
}
|
|
54
|
+
}, __publicField(_a, "config", {
|
|
55
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
56
|
+
emits: ["dragged"]
|
|
57
|
+
}), _a;
|
|
51
58
|
}
|
|
52
59
|
module.exports = __toCommonJS(withDrag_exports);
|
|
60
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/decorators/withDrag.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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
|
+
};
|
|
1
7
|
import useDrag from "../services/drag.js";
|
|
2
8
|
function withDrag(BaseClass, { target = (instance) => instance.$el, ...options } = {}) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
name: `${BaseClass.config.name}WithDrag`,
|
|
6
|
-
emits: ["dragged"]
|
|
7
|
-
};
|
|
9
|
+
var _a;
|
|
10
|
+
return _a = class extends BaseClass {
|
|
8
11
|
constructor(el) {
|
|
9
12
|
super(el);
|
|
10
13
|
this.$on("mounted", () => {
|
|
@@ -16,7 +19,10 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
|
|
|
16
19
|
this.$services.unregister("dragged");
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
|
-
}
|
|
22
|
+
}, __publicField(_a, "config", {
|
|
23
|
+
name: `${BaseClass.config.name}WithDrag`,
|
|
24
|
+
emits: ["dragged"]
|
|
25
|
+
}), _a;
|
|
20
26
|
}
|
|
21
27
|
export {
|
|
22
28
|
withDrag as default
|
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
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;
|
|
7
8
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -25,18 +26,25 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
25
26
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
27
|
};
|
|
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/withExtraConfig.js
|
|
28
35
|
var withExtraConfig_exports = {};
|
|
29
36
|
__export(withExtraConfig_exports, {
|
|
30
37
|
default: () => withExtraConfig
|
|
31
38
|
});
|
|
32
39
|
var import_deepmerge = __toESM(require("deepmerge"), 1);
|
|
33
40
|
function withExtraConfig(BaseClass, config, options = {}) {
|
|
41
|
+
var _a;
|
|
34
42
|
const newConfig = (0, import_deepmerge.default)(BaseClass.config, config, options);
|
|
35
43
|
if (newConfig.name === BaseClass.config.name) {
|
|
36
44
|
newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
|
|
37
45
|
}
|
|
38
|
-
return class extends BaseClass {
|
|
39
|
-
|
|
40
|
-
};
|
|
46
|
+
return _a = class extends BaseClass {
|
|
47
|
+
}, __publicField(_a, "config", newConfig), _a;
|
|
41
48
|
}
|
|
42
49
|
module.exports = __toCommonJS(withExtraConfig_exports);
|
|
50
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,12 +1,18 @@
|
|
|
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
|
+
};
|
|
1
7
|
import merge from "deepmerge";
|
|
2
8
|
function withExtraConfig(BaseClass, config, options = {}) {
|
|
9
|
+
var _a;
|
|
3
10
|
const newConfig = merge(BaseClass.config, config, options);
|
|
4
11
|
if (newConfig.name === BaseClass.config.name) {
|
|
5
12
|
newConfig.name = `${BaseClass.config.name}WithExtraConfig`;
|
|
6
13
|
}
|
|
7
|
-
return class extends BaseClass {
|
|
8
|
-
|
|
9
|
-
};
|
|
14
|
+
return _a = class extends BaseClass {
|
|
15
|
+
}, __publicField(_a, "config", newConfig), _a;
|
|
10
16
|
}
|
|
11
17
|
export {
|
|
12
18
|
withExtraConfig as default
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
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;
|
|
5
6
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
@@ -20,6 +21,12 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
20
21
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
22
|
};
|
|
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/withIntersectionObserver.js
|
|
23
30
|
var withIntersectionObserver_exports = {};
|
|
24
31
|
__export(withIntersectionObserver_exports, {
|
|
25
32
|
default: () => withIntersectionObserver
|
|
@@ -28,24 +35,16 @@ function createArrayOfNumber(length) {
|
|
|
28
35
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
29
36
|
}
|
|
30
37
|
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...BaseClass.config || {},
|
|
34
|
-
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
35
|
-
options: {
|
|
36
|
-
...BaseClass?.config?.options || {},
|
|
37
|
-
intersectionObserver: Object
|
|
38
|
-
},
|
|
39
|
-
emits: ["intersected"]
|
|
40
|
-
};
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return _b = class extends BaseClass {
|
|
41
40
|
constructor(element) {
|
|
42
41
|
super(element);
|
|
43
|
-
if (!this.intersected || typeof this.intersected !== "function") {
|
|
44
|
-
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
45
|
-
}
|
|
46
42
|
this.$observer = new IntersectionObserver((entries) => {
|
|
47
43
|
this.__callMethod("intersected", entries);
|
|
48
|
-
}, {
|
|
44
|
+
}, {
|
|
45
|
+
...defaultOptions,
|
|
46
|
+
...this.$options.intersectionObserver
|
|
47
|
+
});
|
|
49
48
|
this.$on("mounted", () => {
|
|
50
49
|
this.$observer.observe(this.$el);
|
|
51
50
|
});
|
|
@@ -54,6 +53,15 @@ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: creat
|
|
|
54
53
|
});
|
|
55
54
|
return this;
|
|
56
55
|
}
|
|
57
|
-
}
|
|
56
|
+
}, __publicField(_b, "config", {
|
|
57
|
+
...BaseClass.config,
|
|
58
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
59
|
+
options: {
|
|
60
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
61
|
+
intersectionObserver: Object
|
|
62
|
+
},
|
|
63
|
+
emits: ["intersected"]
|
|
64
|
+
}), _b;
|
|
58
65
|
}
|
|
59
66
|
module.exports = __toCommonJS(withIntersectionObserver_exports);
|
|
67
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,25 +1,23 @@
|
|
|
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
|
+
};
|
|
1
7
|
function createArrayOfNumber(length) {
|
|
2
8
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
3
9
|
}
|
|
4
10
|
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
...BaseClass.config || {},
|
|
8
|
-
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
9
|
-
options: {
|
|
10
|
-
...BaseClass?.config?.options || {},
|
|
11
|
-
intersectionObserver: Object
|
|
12
|
-
},
|
|
13
|
-
emits: ["intersected"]
|
|
14
|
-
};
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return _b = class extends BaseClass {
|
|
15
13
|
constructor(element) {
|
|
16
14
|
super(element);
|
|
17
|
-
if (!this.intersected || typeof this.intersected !== "function") {
|
|
18
|
-
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
19
|
-
}
|
|
20
15
|
this.$observer = new IntersectionObserver((entries) => {
|
|
21
16
|
this.__callMethod("intersected", entries);
|
|
22
|
-
}, {
|
|
17
|
+
}, {
|
|
18
|
+
...defaultOptions,
|
|
19
|
+
...this.$options.intersectionObserver
|
|
20
|
+
});
|
|
23
21
|
this.$on("mounted", () => {
|
|
24
22
|
this.$observer.observe(this.$el);
|
|
25
23
|
});
|
|
@@ -28,7 +26,15 @@ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: creat
|
|
|
28
26
|
});
|
|
29
27
|
return this;
|
|
30
28
|
}
|
|
31
|
-
}
|
|
29
|
+
}, __publicField(_b, "config", {
|
|
30
|
+
...BaseClass.config,
|
|
31
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
32
|
+
options: {
|
|
33
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
34
|
+
intersectionObserver: Object
|
|
35
|
+
},
|
|
36
|
+
emits: ["intersected"]
|
|
37
|
+
}), _b;
|
|
32
38
|
}
|
|
33
39
|
export {
|
|
34
40
|
withIntersectionObserver as default
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
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;
|
|
5
6
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
@@ -20,28 +21,27 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
20
21
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
22
|
};
|
|
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
|
|
23
30
|
var withMountWhenInView_exports = {};
|
|
24
31
|
__export(withMountWhenInView_exports, {
|
|
25
32
|
default: () => withMountWhenInView
|
|
26
33
|
});
|
|
27
34
|
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
...BaseClass.config || {},
|
|
31
|
-
name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
|
|
32
|
-
options: {
|
|
33
|
-
...BaseClass?.config?.options || {},
|
|
34
|
-
intersectionObserver: Object
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
#isVisible = false;
|
|
38
|
-
#observer;
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return _b = class extends BaseClass {
|
|
39
37
|
constructor(element) {
|
|
40
38
|
super(element);
|
|
41
|
-
this
|
|
39
|
+
__publicField(this, "__isVisible", false);
|
|
40
|
+
__publicField(this, "__observer");
|
|
41
|
+
this.__observer = new IntersectionObserver((entries) => {
|
|
42
42
|
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
43
|
-
if (this
|
|
44
|
-
this
|
|
43
|
+
if (this.__isVisible !== isVisible) {
|
|
44
|
+
this.__isVisible = isVisible;
|
|
45
45
|
if (isVisible) {
|
|
46
46
|
this.$mount();
|
|
47
47
|
} else {
|
|
@@ -49,18 +49,26 @@ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] })
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
52
|
-
this
|
|
52
|
+
this.__observer.observe(this.$el);
|
|
53
53
|
this.$on("terminated", () => {
|
|
54
|
-
this
|
|
54
|
+
this.__observer.disconnect();
|
|
55
55
|
});
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
58
|
$mount() {
|
|
59
|
-
if (this
|
|
59
|
+
if (this.__isVisible) {
|
|
60
60
|
super.$mount();
|
|
61
61
|
}
|
|
62
62
|
return this;
|
|
63
63
|
}
|
|
64
|
-
}
|
|
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;
|
|
65
72
|
}
|
|
66
73
|
module.exports = __toCommonJS(withMountWhenInView_exports);
|
|
74
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,21 +1,20 @@
|
|
|
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
|
+
};
|
|
1
7
|
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
...BaseClass.config || {},
|
|
5
|
-
name: `${BaseClass?.config?.name ?? ""}WithMountWhenInView`,
|
|
6
|
-
options: {
|
|
7
|
-
...BaseClass?.config?.options || {},
|
|
8
|
-
intersectionObserver: Object
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
#isVisible = false;
|
|
12
|
-
#observer;
|
|
8
|
+
var _a, _b;
|
|
9
|
+
return _b = class extends BaseClass {
|
|
13
10
|
constructor(element) {
|
|
14
11
|
super(element);
|
|
15
|
-
this
|
|
12
|
+
__publicField(this, "__isVisible", false);
|
|
13
|
+
__publicField(this, "__observer");
|
|
14
|
+
this.__observer = new IntersectionObserver((entries) => {
|
|
16
15
|
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
17
|
-
if (this
|
|
18
|
-
this
|
|
16
|
+
if (this.__isVisible !== isVisible) {
|
|
17
|
+
this.__isVisible = isVisible;
|
|
19
18
|
if (isVisible) {
|
|
20
19
|
this.$mount();
|
|
21
20
|
} else {
|
|
@@ -23,19 +22,26 @@ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] })
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
26
|
-
this
|
|
25
|
+
this.__observer.observe(this.$el);
|
|
27
26
|
this.$on("terminated", () => {
|
|
28
|
-
this
|
|
27
|
+
this.__observer.disconnect();
|
|
29
28
|
});
|
|
30
29
|
return this;
|
|
31
30
|
}
|
|
32
31
|
$mount() {
|
|
33
|
-
if (this
|
|
32
|
+
if (this.__isVisible) {
|
|
34
33
|
super.$mount();
|
|
35
34
|
}
|
|
36
35
|
return this;
|
|
37
36
|
}
|
|
38
|
-
}
|
|
37
|
+
}, __publicField(_b, "config", {
|
|
38
|
+
...BaseClass.config,
|
|
39
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
40
|
+
options: {
|
|
41
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
42
|
+
intersectionObserver: Object
|
|
43
|
+
}
|
|
44
|
+
}), _b;
|
|
39
45
|
}
|
|
40
46
|
export {
|
|
41
47
|
withMountWhenInView as default
|
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
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;
|
|
7
8
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
@@ -25,42 +26,48 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
25
26
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
27
|
};
|
|
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
|
|
28
35
|
var withScrolledInView_exports = {};
|
|
29
36
|
__export(withScrolledInView_exports, {
|
|
30
37
|
default: () => withScrolledInView
|
|
31
38
|
});
|
|
32
|
-
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.
|
|
33
|
-
var import_utils = require("../utils/index.
|
|
39
|
+
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
|
|
40
|
+
var import_utils = require("../utils/index.cjs");
|
|
34
41
|
function withScrolledInView(BaseClass, options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
}
|
|
64
71
|
mounted() {
|
|
65
72
|
this.__setProps();
|
|
66
73
|
}
|
|
@@ -105,6 +112,10 @@ function withScrolledInView(BaseClass, options) {
|
|
|
105
112
|
this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
|
|
106
113
|
this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
|
|
107
114
|
}
|
|
108
|
-
}
|
|
115
|
+
}, __publicField(_a, "config", {
|
|
116
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
117
|
+
emits: ["scrolledInView"]
|
|
118
|
+
}), _a;
|
|
109
119
|
}
|
|
110
120
|
module.exports = __toCommonJS(withScrolledInView_exports);
|
|
121
|
+
if (module.exports.default) module.exports = module.exports.default;
|