@studiometa/js-toolkit 2.0.0-beta.7 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Base/index.cjs +285 -0
- package/Base/index.d.ts +13 -4
- package/Base/index.js +114 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +9 -1
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +174 -0
- package/Base/managers/OptionsManager.d.ts +9 -5
- package/Base/managers/OptionsManager.js +60 -90
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +30 -35
- package/Base/managers/ServicesManager.cjs +131 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +9 -9
- package/decorators/index.js +20 -9
- package/decorators/withBreakpointManager.cjs +85 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +115 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +36 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +14 -0
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.d.ts +2 -1
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +60 -0
- package/decorators/withVue2.js +26 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +2 -2
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +35 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +213 -0
- package/services/drag.d.ts +1 -0
- package/services/drag.js +64 -68
- package/services/index.cjs +41 -0
- package/services/index.d.ts +7 -8
- package/services/index.js +16 -8
- package/services/key.cjs +104 -0
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +10 -9
- package/utils/css/classes.js +18 -14
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +13 -5
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +6 -18
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +89 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +14 -35
- package/utils/index.js +32 -17
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +4 -3
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/decorators/withIntersectionObserver.js
|
|
25
|
+
var withIntersectionObserver_exports = {};
|
|
26
|
+
__export(withIntersectionObserver_exports, {
|
|
27
|
+
default: () => withIntersectionObserver
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(withIntersectionObserver_exports);
|
|
30
|
+
function createArrayOfNumber(length) {
|
|
31
|
+
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
32
|
+
}
|
|
33
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
return _b = class extends BaseClass {
|
|
36
|
+
constructor(element) {
|
|
37
|
+
super(element);
|
|
38
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
39
|
+
this.__callMethod("intersected", entries);
|
|
40
|
+
}, {
|
|
41
|
+
...defaultOptions,
|
|
42
|
+
...this.$options.intersectionObserver
|
|
43
|
+
});
|
|
44
|
+
this.$on("mounted", () => {
|
|
45
|
+
this.$observer.observe(this.$el);
|
|
46
|
+
});
|
|
47
|
+
this.$on("destroyed", () => {
|
|
48
|
+
this.$observer.unobserve(this.$el);
|
|
49
|
+
});
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}, __publicField(_b, "config", {
|
|
53
|
+
...BaseClass.config,
|
|
54
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
55
|
+
options: {
|
|
56
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
57
|
+
intersectionObserver: Object
|
|
58
|
+
},
|
|
59
|
+
emits: ["intersected"]
|
|
60
|
+
}), _b;
|
|
61
|
+
}
|
|
62
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
7
|
function createArrayOfNumber(length) {
|
|
8
8
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
15
|
-
threshold: createArrayOfNumber(100)
|
|
16
|
-
};
|
|
17
|
-
return _temp = _class = class extends BaseClass {
|
|
10
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return _b = class extends BaseClass {
|
|
18
13
|
constructor(element) {
|
|
19
14
|
super(element);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, _objectSpread(_objectSpread({}, defaultOptions), this.$options.intersectionObserver || {}));
|
|
28
|
-
this.$on('mounted', () => {
|
|
15
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
16
|
+
this.__callMethod("intersected", entries);
|
|
17
|
+
}, {
|
|
18
|
+
...defaultOptions,
|
|
19
|
+
...this.$options.intersectionObserver
|
|
20
|
+
});
|
|
21
|
+
this.$on("mounted", () => {
|
|
29
22
|
this.$observer.observe(this.$el);
|
|
30
23
|
});
|
|
31
|
-
this.$on(
|
|
24
|
+
this.$on("destroyed", () => {
|
|
32
25
|
this.$observer.unobserve(this.$el);
|
|
33
26
|
});
|
|
34
27
|
return this;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
name:
|
|
39
|
-
options:
|
|
29
|
+
}, __publicField(_b, "config", {
|
|
30
|
+
...BaseClass.config,
|
|
31
|
+
name: `${BaseClass.config.name}WithIntersectionObserver`,
|
|
32
|
+
options: {
|
|
33
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
40
34
|
intersectionObserver: Object
|
|
41
|
-
}
|
|
42
|
-
emits: [
|
|
43
|
-
})
|
|
44
|
-
}
|
|
35
|
+
},
|
|
36
|
+
emits: ["intersected"]
|
|
37
|
+
}), _b;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
withIntersectionObserver as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/decorators/withMountWhenInView.js
|
|
25
|
+
var withMountWhenInView_exports = {};
|
|
26
|
+
__export(withMountWhenInView_exports, {
|
|
27
|
+
default: () => withMountWhenInView
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(withMountWhenInView_exports);
|
|
30
|
+
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
return _b = class extends BaseClass {
|
|
33
|
+
constructor(element) {
|
|
34
|
+
super(element);
|
|
35
|
+
__publicField(this, "__isVisible", false);
|
|
36
|
+
__publicField(this, "__observer");
|
|
37
|
+
this.__observer = new IntersectionObserver((entries) => {
|
|
38
|
+
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
39
|
+
if (this.__isVisible !== isVisible) {
|
|
40
|
+
this.__isVisible = isVisible;
|
|
41
|
+
if (isVisible) {
|
|
42
|
+
this.$mount();
|
|
43
|
+
} else {
|
|
44
|
+
setTimeout(() => this.$destroy());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
48
|
+
this.__observer.observe(this.$el);
|
|
49
|
+
this.$on("terminated", () => {
|
|
50
|
+
this.__observer.disconnect();
|
|
51
|
+
});
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
$mount() {
|
|
55
|
+
if (this.__isVisible) {
|
|
56
|
+
super.$mount();
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
}, __publicField(_b, "config", {
|
|
61
|
+
...BaseClass.config,
|
|
62
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
63
|
+
options: {
|
|
64
|
+
...((_a = BaseClass.config) == null ? void 0 : _a.options) || {},
|
|
65
|
+
intersectionObserver: Object
|
|
66
|
+
}
|
|
67
|
+
}), _b;
|
|
68
|
+
}
|
|
69
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,69 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
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 (
|
|
32
|
+
if (this.__isVisible) {
|
|
57
33
|
super.$mount();
|
|
58
34
|
}
|
|
59
|
-
|
|
60
35
|
return this;
|
|
61
36
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
name:
|
|
65
|
-
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
|
-
})
|
|
69
|
-
}
|
|
43
|
+
}
|
|
44
|
+
}), _b;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
withMountWhenInView as default
|
|
48
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// packages/js-toolkit/decorators/withScrolledInView.js
|
|
28
|
+
var withScrolledInView_exports = {};
|
|
29
|
+
__export(withScrolledInView_exports, {
|
|
30
|
+
default: () => withScrolledInView
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(withScrolledInView_exports);
|
|
33
|
+
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
|
|
34
|
+
var import_utils = require("../utils/index.cjs");
|
|
35
|
+
function withScrolledInView(BaseClass, options) {
|
|
36
|
+
var _a;
|
|
37
|
+
return _a = class extends (0, import_withMountWhenInView.default)(BaseClass, options) {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
__publicField(this, "__props", {
|
|
41
|
+
start: {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0
|
|
44
|
+
},
|
|
45
|
+
end: {
|
|
46
|
+
x: 0,
|
|
47
|
+
y: 0
|
|
48
|
+
},
|
|
49
|
+
current: {
|
|
50
|
+
x: 0,
|
|
51
|
+
y: 0
|
|
52
|
+
},
|
|
53
|
+
progress: {
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0
|
|
56
|
+
},
|
|
57
|
+
dampedProgress: {
|
|
58
|
+
x: 0,
|
|
59
|
+
y: 0
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
__publicField(this, "dampFactor", 0.1);
|
|
63
|
+
__publicField(this, "dampPrecision", 1e-3);
|
|
64
|
+
}
|
|
65
|
+
mounted() {
|
|
66
|
+
this.__setProps();
|
|
67
|
+
}
|
|
68
|
+
resized() {
|
|
69
|
+
this.__setProps();
|
|
70
|
+
}
|
|
71
|
+
scrolled(props) {
|
|
72
|
+
if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
|
|
73
|
+
this.$services.enable("ticked");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
ticked() {
|
|
77
|
+
this.__props.current.x = (0, import_utils.clamp)(window.pageXOffset, this.__props.start.x, this.__props.end.x);
|
|
78
|
+
this.__props.progress.x = (0, import_utils.clamp01)((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
|
|
79
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
|
|
80
|
+
this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
81
|
+
this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
82
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
83
|
+
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
84
|
+
this.$services.disable("ticked");
|
|
85
|
+
}
|
|
86
|
+
this.__callMethod("scrolledInView", this.__props);
|
|
87
|
+
}
|
|
88
|
+
__setProps() {
|
|
89
|
+
const sizes = this.$el.getBoundingClientRect();
|
|
90
|
+
const yEnd = sizes.top + window.pageYOffset + sizes.height;
|
|
91
|
+
const yStart = yEnd - window.innerHeight - sizes.height;
|
|
92
|
+
const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
|
|
93
|
+
const yProgress = (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
|
|
94
|
+
const xEnd = sizes.left + window.pageXOffset + sizes.width;
|
|
95
|
+
const xStart = xEnd - window.innerWidth - sizes.width;
|
|
96
|
+
const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
|
|
97
|
+
const xProgress = (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
|
|
98
|
+
this.__props.start.x = xStart;
|
|
99
|
+
this.__props.start.y = yStart;
|
|
100
|
+
this.__props.end.x = xEnd;
|
|
101
|
+
this.__props.end.y = yEnd;
|
|
102
|
+
this.__props.current.x = xCurrent;
|
|
103
|
+
this.__props.current.y = yCurrent;
|
|
104
|
+
this.__props.progress.x = xProgress;
|
|
105
|
+
this.__props.progress.y = yProgress;
|
|
106
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
|
|
107
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
|
|
108
|
+
}
|
|
109
|
+
}, __publicField(_a, "config", {
|
|
110
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
111
|
+
emits: ["scrolledInView"]
|
|
112
|
+
}), _a;
|
|
113
|
+
}
|
|
114
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @template {BaseConstructor} T
|
|
10
10
|
* @param {T} BaseClass
|
|
11
|
+
* @param {IntersectionObserverInit} options
|
|
11
12
|
* @return {T}
|
|
12
13
|
*/
|
|
13
|
-
export default function withScrolledInView<T extends typeof import("../Base").default>(BaseClass: T): T;
|
|
14
|
+
export default function withScrolledInView<T extends typeof import("../Base").default>(BaseClass: T, options: IntersectionObserverInit): T;
|
|
14
15
|
export type Base = import('../Base').default;
|
|
15
16
|
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
16
17
|
export type BaseConfig = import('../Base').BaseConfig;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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) {
|
|
|
30
33
|
y: 0
|
|
31
34
|
}
|
|
32
35
|
});
|
|
33
|
-
|
|
34
|
-
|
|
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(
|
|
49
|
-
this.$services.enable(
|
|
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) {
|
|
|
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(
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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) {
|
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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,60 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __publicField = (obj, key, value) => {
|
|
20
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/js-toolkit/decorators/withVue2.js
|
|
25
|
+
var withVue2_exports = {};
|
|
26
|
+
__export(withVue2_exports, {
|
|
27
|
+
default: () => withVue2_default
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(withVue2_exports);
|
|
30
|
+
var withVue2_default = (BaseClass, Vue) => {
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
return _c = class extends BaseClass {
|
|
33
|
+
constructor(element) {
|
|
34
|
+
super(element);
|
|
35
|
+
__publicField(this, "$vue");
|
|
36
|
+
const { vueConfig } = this.constructor;
|
|
37
|
+
if (!vueConfig) {
|
|
38
|
+
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
39
|
+
}
|
|
40
|
+
if (typeof vueConfig.render !== "function") {
|
|
41
|
+
throw new Error("[withVue] You must define a `render` function in vueConfig.");
|
|
42
|
+
}
|
|
43
|
+
this.$vue = new Vue(vueConfig);
|
|
44
|
+
this.$on("mounted", () => {
|
|
45
|
+
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
46
|
+
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
47
|
+
}
|
|
48
|
+
this.$vue.$mount(this.$refs.vue);
|
|
49
|
+
});
|
|
50
|
+
this.$on("destroyed", () => {
|
|
51
|
+
this.$vue.$destroy();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, __publicField(_c, "config", {
|
|
55
|
+
...BaseClass.config,
|
|
56
|
+
name: `${BaseClass.config.name}WithVue`,
|
|
57
|
+
refs: [...(_b = (_a = BaseClass.config) == null ? void 0 : _a.refs) != null ? _b : [], "vue"]
|
|
58
|
+
}), __publicField(_c, "vueConfig"), _c;
|
|
59
|
+
};
|
|
60
|
+
if (module.exports.default) module.exports = module.exports.default;
|