@studiometa/js-toolkit 2.0.0-beta.0 → 2.0.0-beta.12
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 +287 -0
- package/Base/index.d.ts +27 -1
- package/Base/index.js +149 -179
- package/Base/managers/ChildrenManager.cjs +122 -0
- package/Base/managers/ChildrenManager.js +29 -55
- package/Base/managers/EventsManager.cjs +182 -0
- package/Base/managers/EventsManager.d.ts +3 -1
- package/Base/managers/EventsManager.js +85 -127
- package/Base/managers/OptionsManager.cjs +167 -0
- package/Base/managers/OptionsManager.d.ts +2 -0
- package/Base/managers/OptionsManager.js +46 -88
- package/Base/managers/RefsManager.cjs +96 -0
- package/Base/managers/RefsManager.d.ts +2 -0
- package/Base/managers/RefsManager.js +24 -35
- package/Base/managers/ServicesManager.cjs +130 -0
- package/Base/managers/ServicesManager.d.ts +29 -4
- package/Base/managers/ServicesManager.js +33 -63
- package/Base/utils.cjs +43 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +47 -0
- package/decorators/index.d.ts +8 -9
- package/decorators/index.js +18 -9
- package/decorators/withBreakpointManager.cjs +89 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +114 -0
- package/decorators/withBreakpointObserver.js +40 -88
- package/decorators/withDrag.cjs +52 -0
- package/decorators/withDrag.js +16 -18
- package/decorators/withExtraConfig.cjs +42 -0
- package/decorators/withExtraConfig.js +11 -12
- package/decorators/withIntersectionObserver.cjs +59 -0
- package/decorators/withIntersectionObserver.js +23 -31
- package/decorators/withMountWhenInView.cjs +66 -0
- package/decorators/withMountWhenInView.js +31 -55
- package/decorators/withScrolledInView.cjs +110 -0
- package/decorators/withScrolledInView.d.ts +4 -1
- package/decorators/withScrolledInView.js +77 -73
- package/decorators/withVue2.cjs +58 -0
- package/decorators/withVue2.js +21 -32
- package/helpers/createApp.cjs +54 -0
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +54 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +50 -0
- package/helpers/importWhenIdle.js +13 -17
- package/helpers/importWhenVisible.cjs +52 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +39 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +37 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +36 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -3
- package/services/Service.cjs +73 -0
- package/services/Service.d.ts +22 -17
- package/services/Service.js +14 -28
- package/services/drag.cjs +192 -0
- package/services/drag.d.ts +4 -18
- package/services/drag.js +103 -156
- package/services/index.cjs +45 -0
- package/services/index.d.ts +13 -10
- package/services/index.js +16 -8
- package/services/key.cjs +99 -0
- package/services/key.d.ts +4 -13
- package/services/key.js +58 -77
- package/services/load.cjs +68 -0
- package/services/load.d.ts +3 -13
- package/services/load.js +31 -36
- package/services/pointer.cjs +157 -0
- package/services/pointer.d.ts +4 -13
- package/services/pointer.js +91 -121
- package/services/raf.cjs +79 -0
- package/services/raf.d.ts +3 -13
- package/services/raf.js +32 -52
- package/services/resize.cjs +104 -0
- package/services/resize.d.ts +3 -13
- package/services/resize.js +52 -52
- package/services/scroll.cjs +127 -0
- package/services/scroll.d.ts +3 -13
- package/services/scroll.js +75 -89
- package/utils/collide/boundingRectToCircle.cjs +36 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +36 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +48 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +33 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +30 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +30 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +43 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +46 -0
- package/utils/css/classes.js +13 -12
- package/utils/css/index.cjs +39 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +10 -5
- package/utils/css/matrix.cjs +31 -0
- package/utils/css/matrix.js +6 -5
- package/utils/css/styles.cjs +49 -0
- package/utils/css/styles.js +13 -12
- package/utils/css/transition.cjs +119 -0
- package/utils/css/transition.js +62 -117
- package/utils/debounce.cjs +36 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +86 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +93 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +55 -0
- package/utils/index.d.ts +12 -35
- package/utils/index.js +30 -17
- package/utils/keyCodes.cjs +37 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +30 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +36 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +30 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +90 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +46 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +39 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +30 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +30 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +30 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +45 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +42 -0
- package/utils/nextFrame.js +14 -9
- package/utils/object/autoBind.cjs +53 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +39 -0
- package/utils/object/getAllProperties.js +11 -14
- package/utils/object/index.cjs +37 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +30 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +84 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +51 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +36 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +36 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +36 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +36 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +30 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +41 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +36 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +30 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +41 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +36 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +38 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
var withIntersectionObserver_exports = {};
|
|
24
|
+
__export(withIntersectionObserver_exports, {
|
|
25
|
+
default: () => withIntersectionObserver
|
|
26
|
+
});
|
|
27
|
+
function createArrayOfNumber(length) {
|
|
28
|
+
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
29
|
+
}
|
|
30
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
31
|
+
return class extends BaseClass {
|
|
32
|
+
static config = {
|
|
33
|
+
...BaseClass.config || {},
|
|
34
|
+
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
35
|
+
options: {
|
|
36
|
+
...BaseClass?.config?.options || {},
|
|
37
|
+
intersectionObserver: Object
|
|
38
|
+
},
|
|
39
|
+
emits: ["intersected"]
|
|
40
|
+
};
|
|
41
|
+
constructor(element) {
|
|
42
|
+
super(element);
|
|
43
|
+
if (!this.intersected || typeof this.intersected !== "function") {
|
|
44
|
+
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
45
|
+
}
|
|
46
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
47
|
+
this.__callMethod("intersected", entries);
|
|
48
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
|
|
49
|
+
this.$on("mounted", () => {
|
|
50
|
+
this.$observer.observe(this.$el);
|
|
51
|
+
});
|
|
52
|
+
this.$on("destroyed", () => {
|
|
53
|
+
this.$observer.unobserve(this.$el);
|
|
54
|
+
});
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
module.exports = __toCommonJS(withIntersectionObserver_exports);
|
|
@@ -1,43 +1,35 @@
|
|
|
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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
1
|
function createArrayOfNumber(length) {
|
|
8
2
|
return [...new Array(length + 1)].map((val, index) => index / length);
|
|
9
3
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
function withIntersectionObserver(BaseClass, defaultOptions = { threshold: createArrayOfNumber(100) }) {
|
|
5
|
+
return class extends BaseClass {
|
|
6
|
+
static config = {
|
|
7
|
+
...BaseClass.config || {},
|
|
8
|
+
name: `${BaseClass?.config?.name ?? ""}WithIntersectionObserver`,
|
|
9
|
+
options: {
|
|
10
|
+
...BaseClass?.config?.options || {},
|
|
11
|
+
intersectionObserver: Object
|
|
12
|
+
},
|
|
13
|
+
emits: ["intersected"]
|
|
14
|
+
};
|
|
18
15
|
constructor(element) {
|
|
19
16
|
super(element);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw new Error('[withIntersectionObserver] The `intersected` method must be defined.');
|
|
17
|
+
if (!this.intersected || typeof this.intersected !== "function") {
|
|
18
|
+
throw new Error("[withIntersectionObserver] The `intersected` method must be defined.");
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.$on('mounted', () => {
|
|
20
|
+
this.$observer = new IntersectionObserver((entries) => {
|
|
21
|
+
this.__callMethod("intersected", entries);
|
|
22
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver || {} });
|
|
23
|
+
this.$on("mounted", () => {
|
|
29
24
|
this.$observer.observe(this.$el);
|
|
30
25
|
});
|
|
31
|
-
this.$on(
|
|
26
|
+
this.$on("destroyed", () => {
|
|
32
27
|
this.$observer.unobserve(this.$el);
|
|
33
28
|
});
|
|
34
29
|
return this;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
})), _temp;
|
|
43
|
-
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
withIntersectionObserver as default
|
|
35
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
var withMountWhenInView_exports = {};
|
|
24
|
+
__export(withMountWhenInView_exports, {
|
|
25
|
+
default: () => withMountWhenInView
|
|
26
|
+
});
|
|
27
|
+
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
28
|
+
return class extends BaseClass {
|
|
29
|
+
static config = {
|
|
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;
|
|
39
|
+
constructor(element) {
|
|
40
|
+
super(element);
|
|
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
|
+
};
|
|
65
|
+
}
|
|
66
|
+
module.exports = __toCommonJS(withMountWhenInView_exports);
|
|
@@ -1,66 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] }) {
|
|
2
|
+
return class extends BaseClass {
|
|
3
|
+
static config = {
|
|
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;
|
|
20
13
|
constructor(element) {
|
|
21
14
|
super(element);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
39
|
-
var method = isVisible ? '$mount' : '$destroy';
|
|
40
|
-
this[method]();
|
|
15
|
+
this.#observer = new IntersectionObserver((entries) => {
|
|
16
|
+
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
17
|
+
if (this.#isVisible !== isVisible) {
|
|
18
|
+
this.#isVisible = isVisible;
|
|
19
|
+
if (isVisible) {
|
|
20
|
+
this.$mount();
|
|
21
|
+
} else {
|
|
22
|
+
setTimeout(() => this.$destroy());
|
|
23
|
+
}
|
|
41
24
|
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.$on('terminated', () => {
|
|
47
|
-
_classPrivateFieldGet(this, _observer).disconnect();
|
|
25
|
+
}, { ...defaultOptions, ...this.$options.intersectionObserver });
|
|
26
|
+
this.#observer.observe(this.$el);
|
|
27
|
+
this.$on("terminated", () => {
|
|
28
|
+
this.#observer.disconnect();
|
|
48
29
|
});
|
|
49
30
|
return this;
|
|
50
31
|
}
|
|
51
|
-
|
|
52
32
|
$mount() {
|
|
53
|
-
if (
|
|
33
|
+
if (this.#isVisible) {
|
|
54
34
|
super.$mount();
|
|
55
35
|
}
|
|
56
|
-
|
|
57
36
|
return this;
|
|
58
37
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
})), _temp;
|
|
66
|
-
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
withMountWhenInView as default
|
|
42
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var withScrolledInView_exports = {};
|
|
29
|
+
__export(withScrolledInView_exports, {
|
|
30
|
+
default: () => withScrolledInView
|
|
31
|
+
});
|
|
32
|
+
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.js"), 1);
|
|
33
|
+
var import_utils = require("../utils/index.js");
|
|
34
|
+
function withScrolledInView(BaseClass, options) {
|
|
35
|
+
return class extends (0, import_withMountWhenInView.default)(BaseClass, options) {
|
|
36
|
+
static config = {
|
|
37
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
38
|
+
emits: ["scrolledInView"]
|
|
39
|
+
};
|
|
40
|
+
__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
|
+
dampFactor = 0.1;
|
|
63
|
+
dampPrecision = 1e-3;
|
|
64
|
+
mounted() {
|
|
65
|
+
this.__setProps();
|
|
66
|
+
}
|
|
67
|
+
resized() {
|
|
68
|
+
this.__setProps();
|
|
69
|
+
}
|
|
70
|
+
scrolled(props) {
|
|
71
|
+
if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
|
|
72
|
+
this.$services.enable("ticked");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
ticked() {
|
|
76
|
+
this.__props.current.x = (0, import_utils.clamp)(window.pageXOffset, this.__props.start.x, this.__props.end.x);
|
|
77
|
+
this.__props.progress.x = (0, import_utils.clamp01)((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
|
|
78
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
|
|
79
|
+
this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
80
|
+
this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
81
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
82
|
+
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
83
|
+
this.$services.disable("ticked");
|
|
84
|
+
}
|
|
85
|
+
this.__callMethod("scrolledInView", this.__props);
|
|
86
|
+
}
|
|
87
|
+
__setProps() {
|
|
88
|
+
const sizes = this.$el.getBoundingClientRect();
|
|
89
|
+
const yEnd = sizes.top + window.pageYOffset + sizes.height;
|
|
90
|
+
const yStart = yEnd - window.innerHeight - sizes.height;
|
|
91
|
+
const yCurrent = (0, import_utils.clamp)(window.pageYOffset, yStart, yEnd);
|
|
92
|
+
const yProgress = (0, import_utils.clamp01)((yCurrent - yStart) / (yEnd - yStart));
|
|
93
|
+
const xEnd = sizes.left + window.pageXOffset + sizes.width;
|
|
94
|
+
const xStart = xEnd - window.innerWidth - sizes.width;
|
|
95
|
+
const xCurrent = (0, import_utils.clamp)(window.pageXOffset, xStart, xEnd);
|
|
96
|
+
const xProgress = (0, import_utils.clamp01)((xCurrent - xStart) / (xEnd - xStart));
|
|
97
|
+
this.__props.start.x = xStart;
|
|
98
|
+
this.__props.start.y = yStart;
|
|
99
|
+
this.__props.end.x = xEnd;
|
|
100
|
+
this.__props.end.y = yEnd;
|
|
101
|
+
this.__props.current.x = xCurrent;
|
|
102
|
+
this.__props.current.y = yCurrent;
|
|
103
|
+
this.__props.progress.x = xProgress;
|
|
104
|
+
this.__props.progress.y = yProgress;
|
|
105
|
+
this.__props.dampedProgress.x = (0, import_utils.damp)(xProgress, this.__props.dampedProgress.x);
|
|
106
|
+
this.__props.dampedProgress.y = (0, import_utils.damp)(yProgress, this.__props.dampedProgress.y);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
module.exports = __toCommonJS(withScrolledInView_exports);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../Base').default} Base
|
|
3
3
|
* @typedef {import('../Base').BaseConstructor} BaseConstructor
|
|
4
|
+
* @typedef {import('../Base').BaseConfig} BaseConfig
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
7
|
* Add scrolled in view capabilities to a component.
|
|
7
8
|
*
|
|
8
9
|
* @template {BaseConstructor} T
|
|
9
10
|
* @param {T} BaseClass
|
|
11
|
+
* @param {IntersectionObserverInit} options
|
|
10
12
|
* @return {T}
|
|
11
13
|
*/
|
|
12
|
-
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;
|
|
13
15
|
export type Base = import('../Base').default;
|
|
14
16
|
export type BaseConstructor = import('../Base').BaseConstructor;
|
|
17
|
+
export type BaseConfig = import('../Base').BaseConfig;
|
|
@@ -1,77 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import withMountWhenInView from "./withMountWhenInView.js";
|
|
2
|
+
import { damp, clamp, clamp01 } from "../utils/index.js";
|
|
3
|
+
function withScrolledInView(BaseClass, options) {
|
|
4
|
+
return class extends withMountWhenInView(BaseClass, options) {
|
|
5
|
+
static config = {
|
|
6
|
+
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
7
|
+
emits: ["scrolledInView"]
|
|
8
|
+
};
|
|
9
|
+
__props = {
|
|
10
|
+
start: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0
|
|
13
|
+
},
|
|
14
|
+
end: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0
|
|
17
|
+
},
|
|
18
|
+
current: {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0
|
|
21
|
+
},
|
|
22
|
+
progress: {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0
|
|
25
|
+
},
|
|
26
|
+
dampedProgress: {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
dampFactor = 0.1;
|
|
32
|
+
dampPrecision = 1e-3;
|
|
33
|
+
mounted() {
|
|
34
|
+
this.__setProps();
|
|
35
|
+
}
|
|
36
|
+
resized() {
|
|
37
|
+
this.__setProps();
|
|
38
|
+
}
|
|
39
|
+
scrolled(props) {
|
|
40
|
+
if (!this.$services.has("ticked") && props.changed.y || props.changed.x) {
|
|
41
|
+
this.$services.enable("ticked");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
ticked() {
|
|
45
|
+
this.__props.current.x = clamp(window.pageXOffset, this.__props.start.x, this.__props.end.x);
|
|
46
|
+
this.__props.progress.x = clamp01((this.__props.current.x - this.__props.start.x) / (this.__props.end.x - this.__props.start.x));
|
|
47
|
+
this.__props.dampedProgress.x = damp(this.__props.progress.x, this.__props.dampedProgress.x, this.dampFactor, this.dampPrecision);
|
|
48
|
+
this.__props.current.y = clamp(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
49
|
+
this.__props.progress.y = clamp01((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
50
|
+
this.__props.dampedProgress.y = damp(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
51
|
+
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
52
|
+
this.$services.disable("ticked");
|
|
53
|
+
}
|
|
54
|
+
this.__callMethod("scrolledInView", this.__props);
|
|
44
55
|
}
|
|
45
|
-
|
|
46
56
|
__setProps() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.__props =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
x: xCurrent,
|
|
67
|
-
y: yCurrent
|
|
68
|
-
},
|
|
69
|
-
progress: {
|
|
70
|
-
x: xProgress,
|
|
71
|
-
y: yProgress
|
|
72
|
-
}
|
|
73
|
-
};
|
|
57
|
+
const sizes = this.$el.getBoundingClientRect();
|
|
58
|
+
const yEnd = sizes.top + window.pageYOffset + sizes.height;
|
|
59
|
+
const yStart = yEnd - window.innerHeight - sizes.height;
|
|
60
|
+
const yCurrent = clamp(window.pageYOffset, yStart, yEnd);
|
|
61
|
+
const yProgress = clamp01((yCurrent - yStart) / (yEnd - yStart));
|
|
62
|
+
const xEnd = sizes.left + window.pageXOffset + sizes.width;
|
|
63
|
+
const xStart = xEnd - window.innerWidth - sizes.width;
|
|
64
|
+
const xCurrent = clamp(window.pageXOffset, xStart, xEnd);
|
|
65
|
+
const xProgress = clamp01((xCurrent - xStart) / (xEnd - xStart));
|
|
66
|
+
this.__props.start.x = xStart;
|
|
67
|
+
this.__props.start.y = yStart;
|
|
68
|
+
this.__props.end.x = xEnd;
|
|
69
|
+
this.__props.end.y = yEnd;
|
|
70
|
+
this.__props.current.x = xCurrent;
|
|
71
|
+
this.__props.current.y = yCurrent;
|
|
72
|
+
this.__props.progress.x = xProgress;
|
|
73
|
+
this.__props.progress.y = yProgress;
|
|
74
|
+
this.__props.dampedProgress.x = damp(xProgress, this.__props.dampedProgress.x);
|
|
75
|
+
this.__props.dampedProgress.y = damp(yProgress, this.__props.dampedProgress.y);
|
|
74
76
|
}
|
|
75
|
-
|
|
76
77
|
};
|
|
77
|
-
}
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
withScrolledInView as default
|
|
81
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
var withVue2_exports = {};
|
|
24
|
+
__export(withVue2_exports, {
|
|
25
|
+
default: () => withVue2_default
|
|
26
|
+
});
|
|
27
|
+
var withVue2_default = (BaseClass, Vue) => {
|
|
28
|
+
return class WithVue2 extends BaseClass {
|
|
29
|
+
static config = {
|
|
30
|
+
...BaseClass.config || {},
|
|
31
|
+
name: `${BaseClass?.config?.name ?? ""}WithVue`,
|
|
32
|
+
refs: [...BaseClass?.config?.refs ?? [], "vue"]
|
|
33
|
+
};
|
|
34
|
+
$vue;
|
|
35
|
+
static vueConfig;
|
|
36
|
+
constructor(element) {
|
|
37
|
+
super(element);
|
|
38
|
+
const { vueConfig } = this.constructor;
|
|
39
|
+
if (!vueConfig) {
|
|
40
|
+
throw new Error("[withVue] You must define a `vueConfig` object.");
|
|
41
|
+
}
|
|
42
|
+
if (typeof vueConfig.render !== "function") {
|
|
43
|
+
throw new Error("[withVue] You must define a `render` function in vueConfig.");
|
|
44
|
+
}
|
|
45
|
+
this.$vue = new Vue(vueConfig);
|
|
46
|
+
this.$on("mounted", () => {
|
|
47
|
+
if (!(this.$refs.vue instanceof HTMLElement)) {
|
|
48
|
+
throw new Error("[withVue] The `vue` refs must be a single HTMLElement.");
|
|
49
|
+
}
|
|
50
|
+
this.$vue.$mount(this.$refs.vue);
|
|
51
|
+
});
|
|
52
|
+
this.$on("destroyed", () => {
|
|
53
|
+
this.$vue.$destroy();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
module.exports = __toCommonJS(withVue2_exports);
|