@studiometa/js-toolkit 2.4.1 → 2.4.4-alpha.0
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 +10 -3
- package/Base/index.js +6 -2
- package/Base/managers/AbstractManager.cjs +13 -8
- package/Base/managers/AbstractManager.js +13 -8
- package/Base/managers/ChildrenManager.cjs +10 -3
- package/Base/managers/ChildrenManager.js +6 -2
- package/Base/managers/EventsManager.cjs +17 -4
- package/Base/managers/EventsManager.js +13 -3
- package/Base/managers/OptionsManager.cjs +18 -5
- package/Base/managers/OptionsManager.js +14 -4
- package/Base/managers/RefsManager.cjs +17 -4
- package/Base/managers/RefsManager.js +13 -3
- package/Base/managers/ResponsiveOptionsManager.cjs +4 -1
- package/Base/managers/ServicesManager.cjs +12 -5
- package/Base/managers/ServicesManager.js +8 -4
- package/Base/utils.cjs +5 -1
- package/Base/utils.js +5 -1
- package/decorators/index.cjs +5 -2
- package/decorators/withBreakpointManager.cjs +6 -4
- package/decorators/withBreakpointManager.js +1 -2
- package/decorators/withBreakpointObserver.cjs +12 -5
- package/decorators/withBreakpointObserver.js +7 -3
- package/decorators/withDrag.cjs +9 -3
- package/decorators/withDrag.js +4 -1
- package/decorators/withExtraConfig.cjs +5 -2
- package/decorators/withFreezedOptions.cjs +9 -7
- package/decorators/withFreezedOptions.js +8 -6
- package/decorators/withIntersectionObserver.cjs +11 -7
- package/decorators/withIntersectionObserver.js +10 -6
- package/decorators/withMountWhenInView.cjs +14 -11
- package/decorators/withMountWhenInView.js +13 -10
- package/decorators/withResponsiveOptions.cjs +6 -3
- package/decorators/withResponsiveOptions.js +1 -1
- package/decorators/withScrolledInView.cjs +77 -25
- package/decorators/withScrolledInView.js +72 -23
- package/decorators/withVue2.cjs +4 -4
- package/decorators/withVue2.js +3 -3
- package/helpers/importWhenIdle.cjs +8 -5
- package/helpers/importWhenIdle.js +8 -5
- package/helpers/index.cjs +4 -1
- package/index.cjs +5 -2
- package/package.json +2 -2
- package/services/drag.cjs +4 -1
- package/services/index.cjs +4 -1
- package/services/index.d.ts +7 -0
- package/services/key.cjs +4 -1
- package/services/resize.cjs +4 -1
- package/services/scroll.cjs +4 -1
- package/utils/collide/index.cjs +4 -1
- package/utils/css/animate.cjs +24 -13
- package/utils/css/animate.js +20 -12
- package/utils/css/index.cjs +4 -1
- package/utils/css/transition.cjs +4 -4
- package/utils/css/transition.js +0 -3
- package/utils/focusTrap.cjs +4 -1
- package/utils/history.cjs +4 -1
- package/utils/history.js +4 -1
- package/utils/index.cjs +4 -1
- package/utils/math/clamp01.cjs +4 -1
- package/utils/math/index.cjs +4 -1
- package/utils/math/inertiaFinalValue.cjs +4 -1
- package/utils/nextTick.cjs +5 -3
- package/utils/nextTick.js +5 -3
- package/utils/object/autoBind.cjs +4 -1
- package/utils/object/index.cjs +4 -1
- package/utils/scrollTo.cjs +4 -1
- package/utils/string/index.cjs +4 -1
- 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/withoutLeadingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutLeadingSlash.cjs +4 -1
- package/utils/string/withoutTrailingCharactersRecursive.cjs +4 -1
- package/utils/string/withoutTrailingSlash.cjs +4 -1
- package/utils/tween.cjs +4 -1
- package/Base/index.d.ts +0 -290
- package/Base/managers/AbstractManager.d.ts +0 -44
- package/Base/managers/ChildrenManager.d.ts +0 -41
- package/Base/managers/EventsManager.d.ts +0 -112
- package/Base/managers/OptionsManager.d.ts +0 -87
- package/Base/managers/RefsManager.d.ts +0 -32
- package/Base/managers/ResponsiveOptionsManager.d.ts +0 -26
- package/Base/managers/ServicesManager.d.ts +0 -109
- package/Base/utils.d.ts +0 -40
- package/decorators/index.d.ts +0 -10
- package/decorators/withBreakpointManager.d.ts +0 -10
- package/decorators/withBreakpointObserver.d.ts +0 -17
- package/decorators/withDrag.d.ts +0 -23
- package/decorators/withExtraConfig.d.ts +0 -18
- package/decorators/withFreezedOptions.d.ts +0 -14
- package/decorators/withIntersectionObserver.d.ts +0 -23
- package/decorators/withMountWhenInView.d.ts +0 -33
- package/decorators/withResponsiveOptions.d.ts +0 -8
- package/decorators/withScrolledInView.d.ts +0 -19
- package/decorators/withVue2.d.ts +0 -7
- package/helpers/createApp.d.ts +0 -14
- package/helpers/getDirectChildren.d.ts +0 -24
- package/helpers/getInstanceFromElement.d.ts +0 -14
- package/helpers/importOnInteraction.d.ts +0 -23
- package/helpers/importWhenIdle.d.ts +0 -21
- package/helpers/importWhenVisible.d.ts +0 -23
- package/helpers/index.d.ts +0 -6
- package/helpers/utils.d.ts +0 -10
- package/index.d.ts +0 -4
|
@@ -22,7 +22,9 @@ function hasBreakpointConfiguration(instance) {
|
|
|
22
22
|
function testConflictingBreakpointConfiguration(instance) {
|
|
23
23
|
const { activeBreakpoints, inactiveBreakpoints, name } = instance.$options;
|
|
24
24
|
if (activeBreakpoints && inactiveBreakpoints) {
|
|
25
|
-
throw new Error(
|
|
25
|
+
throw new Error(
|
|
26
|
+
`[${name}] Incorrect configuration: the \`activeBreakpoints\` and \`inactiveBreakpoints\` are not compatible.`
|
|
27
|
+
);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
function addToResize(key, instance) {
|
|
@@ -31,7 +33,7 @@ function addToResize(key, instance) {
|
|
|
31
33
|
}
|
|
32
34
|
const { add, has } = useResize();
|
|
33
35
|
if (!has(key)) {
|
|
34
|
-
add(key,
|
|
36
|
+
add(key, ({ breakpoint }) => {
|
|
35
37
|
const action = testBreakpoints(instance, breakpoint);
|
|
36
38
|
if (action === "$destroy" && instance.$isMounted) {
|
|
37
39
|
instance[action]();
|
|
@@ -50,7 +52,9 @@ function withBreakpointObserver(BaseClass) {
|
|
|
50
52
|
const { name } = this.$options;
|
|
51
53
|
if (!props().breakpoint) {
|
|
52
54
|
if (isDev) {
|
|
53
|
-
throw new Error(
|
|
55
|
+
throw new Error(
|
|
56
|
+
`[${name}] The \`BreakpointObserver\` class requires breakpoints to be defined.`
|
|
57
|
+
);
|
|
54
58
|
}
|
|
55
59
|
return;
|
|
56
60
|
}
|
package/decorators/withDrag.cjs
CHANGED
|
@@ -17,14 +17,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
27
|
return value;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
// packages/js-toolkit/decorators/withDrag.
|
|
30
|
+
// packages/js-toolkit/decorators/withDrag.ts
|
|
28
31
|
var withDrag_exports = {};
|
|
29
32
|
__export(withDrag_exports, {
|
|
30
33
|
default: () => withDrag
|
|
@@ -37,7 +40,10 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
|
|
|
37
40
|
constructor(el) {
|
|
38
41
|
super(el);
|
|
39
42
|
this.$on("mounted", () => {
|
|
40
|
-
this.$services.register(
|
|
43
|
+
this.$services.register(
|
|
44
|
+
"dragged",
|
|
45
|
+
import_drag.default.bind(void 0, target.call(this, this), options)
|
|
46
|
+
);
|
|
41
47
|
this.$services.enable("dragged");
|
|
42
48
|
});
|
|
43
49
|
this.$on("destroyed", () => {
|
package/decorators/withDrag.js
CHANGED
|
@@ -11,7 +11,10 @@ function withDrag(BaseClass, { target = (instance) => instance.$el, ...options }
|
|
|
11
11
|
constructor(el) {
|
|
12
12
|
super(el);
|
|
13
13
|
this.$on("mounted", () => {
|
|
14
|
-
this.$services.register(
|
|
14
|
+
this.$services.register(
|
|
15
|
+
"dragged",
|
|
16
|
+
useDrag.bind(void 0, target.call(this, this), options)
|
|
17
|
+
);
|
|
15
18
|
this.$services.enable("dragged");
|
|
16
19
|
});
|
|
17
20
|
this.$on("destroyed", () => {
|
|
@@ -17,14 +17,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
27
|
return value;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
// packages/js-toolkit/decorators/withExtraConfig.
|
|
30
|
+
// packages/js-toolkit/decorators/withExtraConfig.ts
|
|
28
31
|
var withExtraConfig_exports = {};
|
|
29
32
|
__export(withExtraConfig_exports, {
|
|
30
33
|
default: () => withExtraConfig
|
|
@@ -21,24 +21,26 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// packages/js-toolkit/decorators/withFreezedOptions.
|
|
24
|
+
// packages/js-toolkit/decorators/withFreezedOptions.ts
|
|
25
25
|
var withFreezedOptions_exports = {};
|
|
26
26
|
__export(withFreezedOptions_exports, {
|
|
27
27
|
default: () => withFreezedOptions
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(withFreezedOptions_exports);
|
|
30
30
|
function withFreezedOptions(BaseClass) {
|
|
31
|
-
return class extends BaseClass {
|
|
31
|
+
return class WithFreezedOptions extends BaseClass {
|
|
32
32
|
constructor() {
|
|
33
33
|
super(...arguments);
|
|
34
34
|
__publicField(this, "__freezedOptions");
|
|
35
35
|
}
|
|
36
36
|
get $options() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
if (!this.__freezedOptions) {
|
|
38
|
+
Object.defineProperty(this, "__freezedOptions", {
|
|
39
|
+
value: Object.freeze({ ...super.$options }),
|
|
40
|
+
enumerable: false,
|
|
41
|
+
configurable: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
42
44
|
return this.__freezedOptions;
|
|
43
45
|
}
|
|
44
46
|
};
|
|
@@ -5,17 +5,19 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
function withFreezedOptions(BaseClass) {
|
|
8
|
-
return class extends BaseClass {
|
|
8
|
+
return class WithFreezedOptions extends BaseClass {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
__publicField(this, "__freezedOptions");
|
|
12
12
|
}
|
|
13
13
|
get $options() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (!this.__freezedOptions) {
|
|
15
|
+
Object.defineProperty(this, "__freezedOptions", {
|
|
16
|
+
value: Object.freeze({ ...super.$options }),
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
19
21
|
return this.__freezedOptions;
|
|
20
22
|
}
|
|
21
23
|
};
|
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// packages/js-toolkit/decorators/withIntersectionObserver.
|
|
24
|
+
// packages/js-toolkit/decorators/withIntersectionObserver.ts
|
|
25
25
|
var withIntersectionObserver_exports = {};
|
|
26
26
|
__export(withIntersectionObserver_exports, {
|
|
27
27
|
default: () => withIntersectionObserver
|
|
@@ -35,12 +35,16 @@ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: creat
|
|
|
35
35
|
return _b = class extends BaseClass {
|
|
36
36
|
constructor(element) {
|
|
37
37
|
super(element);
|
|
38
|
-
this
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
__publicField(this, "$observer");
|
|
39
|
+
this.$observer = new IntersectionObserver(
|
|
40
|
+
(entries) => {
|
|
41
|
+
this.__callMethod("intersected", entries);
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
...defaultOptions,
|
|
45
|
+
...this.$options.intersectionObserver
|
|
46
|
+
}
|
|
47
|
+
);
|
|
44
48
|
this.$on("mounted", () => {
|
|
45
49
|
this.$observer.observe(this.$el);
|
|
46
50
|
});
|
|
@@ -12,12 +12,16 @@ function withIntersectionObserver(BaseClass, defaultOptions = { threshold: creat
|
|
|
12
12
|
return _b = class extends BaseClass {
|
|
13
13
|
constructor(element) {
|
|
14
14
|
super(element);
|
|
15
|
-
this
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
__publicField(this, "$observer");
|
|
16
|
+
this.$observer = new IntersectionObserver(
|
|
17
|
+
(entries) => {
|
|
18
|
+
this.__callMethod("intersected", entries);
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
...defaultOptions,
|
|
22
|
+
...this.$options.intersectionObserver
|
|
23
|
+
}
|
|
24
|
+
);
|
|
21
25
|
this.$on("mounted", () => {
|
|
22
26
|
this.$observer.observe(this.$el);
|
|
23
27
|
});
|
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// packages/js-toolkit/decorators/withMountWhenInView.
|
|
24
|
+
// packages/js-toolkit/decorators/withMountWhenInView.ts
|
|
25
25
|
var withMountWhenInView_exports = {};
|
|
26
26
|
__export(withMountWhenInView_exports, {
|
|
27
27
|
default: () => withMountWhenInView
|
|
@@ -34,17 +34,20 @@ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] })
|
|
|
34
34
|
super(element);
|
|
35
35
|
__publicField(this, "__isVisible", false);
|
|
36
36
|
__publicField(this, "__observer");
|
|
37
|
-
this.__observer = new IntersectionObserver(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.__isVisible
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
this.__observer = new IntersectionObserver(
|
|
38
|
+
(entries) => {
|
|
39
|
+
const isVisible = entries.reduce((acc, entry) => acc || entry.isIntersecting, false);
|
|
40
|
+
if (this.__isVisible !== isVisible) {
|
|
41
|
+
this.__isVisible = isVisible;
|
|
42
|
+
if (isVisible) {
|
|
43
|
+
this.$mount();
|
|
44
|
+
} else {
|
|
45
|
+
setTimeout(() => this.$destroy());
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
+
},
|
|
49
|
+
{ ...defaultOptions, ...this.$options.intersectionObserver }
|
|
50
|
+
);
|
|
48
51
|
this.__observer.observe(this.$el);
|
|
49
52
|
this.$on("terminated", () => {
|
|
50
53
|
this.__observer.disconnect();
|
|
@@ -11,17 +11,20 @@ function withMountWhenInView(BaseClass, defaultOptions = { threshold: [0, 1] })
|
|
|
11
11
|
super(element);
|
|
12
12
|
__publicField(this, "__isVisible", false);
|
|
13
13
|
__publicField(this, "__observer");
|
|
14
|
-
this.__observer = new IntersectionObserver(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.__isVisible
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
this.__observer = new IntersectionObserver(
|
|
15
|
+
(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
|
+
}
|
|
22
24
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
+
},
|
|
26
|
+
{ ...defaultOptions, ...this.$options.intersectionObserver }
|
|
27
|
+
);
|
|
25
28
|
this.__observer.observe(this.$el);
|
|
26
29
|
this.$on("terminated", () => {
|
|
27
30
|
this.__observer.disconnect();
|
|
@@ -16,10 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
|
-
// packages/js-toolkit/decorators/withResponsiveOptions.
|
|
25
|
+
// packages/js-toolkit/decorators/withResponsiveOptions.ts
|
|
23
26
|
var withResponsiveOptions_exports = {};
|
|
24
27
|
__export(withResponsiveOptions_exports, {
|
|
25
28
|
default: () => withResponsiveOptions
|
|
@@ -27,7 +30,7 @@ __export(withResponsiveOptions_exports, {
|
|
|
27
30
|
module.exports = __toCommonJS(withResponsiveOptions_exports);
|
|
28
31
|
var import_ResponsiveOptionsManager = __toESM(require("../Base/managers/ResponsiveOptionsManager.cjs"), 1);
|
|
29
32
|
function withResponsiveOptions(BaseClass) {
|
|
30
|
-
return class extends BaseClass {
|
|
33
|
+
return class WithResponsiveOptions extends BaseClass {
|
|
31
34
|
get __managers() {
|
|
32
35
|
return {
|
|
33
36
|
...super.__managers,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ResponsiveOptionsManager from "../Base/managers/ResponsiveOptionsManager.js";
|
|
2
2
|
function withResponsiveOptions(BaseClass) {
|
|
3
|
-
return class extends BaseClass {
|
|
3
|
+
return class WithResponsiveOptions extends BaseClass {
|
|
4
4
|
get __managers() {
|
|
5
5
|
return {
|
|
6
6
|
...super.__managers,
|
|
@@ -17,14 +17,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var __publicField = (obj, key, value) => {
|
|
23
26
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
27
|
return value;
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
// packages/js-toolkit/decorators/withScrolledInView.
|
|
30
|
+
// packages/js-toolkit/decorators/withScrolledInView.ts
|
|
28
31
|
var withScrolledInView_exports = {};
|
|
29
32
|
__export(withScrolledInView_exports, {
|
|
30
33
|
default: () => withScrolledInView
|
|
@@ -33,9 +36,29 @@ module.exports = __toCommonJS(withScrolledInView_exports);
|
|
|
33
36
|
var import_withMountWhenInView = __toESM(require("./withMountWhenInView.cjs"), 1);
|
|
34
37
|
var import_utils = require("../utils/index.cjs");
|
|
35
38
|
var scheduler = (0, import_utils.useScheduler)(["update", "render"]);
|
|
39
|
+
function updateProps(props, dampFactor, dampPrecision, axis = "x") {
|
|
40
|
+
props.current[axis] = (0, import_utils.clamp)(
|
|
41
|
+
axis === "x" ? window.pageXOffset : window.pageYOffset,
|
|
42
|
+
props.start[axis],
|
|
43
|
+
props.end[axis]
|
|
44
|
+
);
|
|
45
|
+
props.dampedCurrent[axis] = (0, import_utils.damp)(
|
|
46
|
+
props.current[axis],
|
|
47
|
+
props.dampedCurrent[axis],
|
|
48
|
+
dampFactor,
|
|
49
|
+
dampPrecision
|
|
50
|
+
);
|
|
51
|
+
props.progress[axis] = (0, import_utils.clamp01)(
|
|
52
|
+
(props.current[axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
|
|
53
|
+
);
|
|
54
|
+
props.dampedProgress[axis] = (0, import_utils.clamp01)(
|
|
55
|
+
(props.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
|
|
56
|
+
);
|
|
57
|
+
}
|
|
36
58
|
function withScrolledInView(BaseClass, options = {}) {
|
|
37
59
|
var _a;
|
|
38
|
-
|
|
60
|
+
const WithMountWhenInView = (0, import_withMountWhenInView.default)(BaseClass, options);
|
|
61
|
+
return _a = class extends WithMountWhenInView {
|
|
39
62
|
constructor(element) {
|
|
40
63
|
super(element);
|
|
41
64
|
__publicField(this, "__props", {
|
|
@@ -51,6 +74,10 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
51
74
|
x: 0,
|
|
52
75
|
y: 0
|
|
53
76
|
},
|
|
77
|
+
dampedCurrent: {
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0
|
|
80
|
+
},
|
|
54
81
|
progress: {
|
|
55
82
|
x: 0,
|
|
56
83
|
y: 0
|
|
@@ -62,6 +89,16 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
62
89
|
});
|
|
63
90
|
__publicField(this, "dampFactor", 0.1);
|
|
64
91
|
__publicField(this, "dampPrecision", 1e-3);
|
|
92
|
+
const render = () => {
|
|
93
|
+
scheduler.update(() => {
|
|
94
|
+
const renderFn = this.__callMethod("scrolledInView", this.__props);
|
|
95
|
+
if ((0, import_utils.isFunction)(renderFn)) {
|
|
96
|
+
scheduler.render(() => {
|
|
97
|
+
renderFn(this.__props);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
65
102
|
const delegate = {
|
|
66
103
|
handleEvent(event) {
|
|
67
104
|
delegate[event.type](event.detail[0]);
|
|
@@ -75,23 +112,12 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
75
112
|
}
|
|
76
113
|
},
|
|
77
114
|
ticked: () => {
|
|
78
|
-
this.__props
|
|
79
|
-
this.__props
|
|
80
|
-
this.__props.
|
|
81
|
-
this.__props.current.y = (0, import_utils.clamp)(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
82
|
-
this.__props.progress.y = (0, import_utils.clamp01)((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
83
|
-
this.__props.dampedProgress.y = (0, import_utils.damp)(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
84
|
-
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
115
|
+
updateProps(this.__props, this.dampFactor, this.dampPrecision, "x");
|
|
116
|
+
updateProps(this.__props, this.dampFactor, this.dampPrecision, "y");
|
|
117
|
+
if (this.__props.dampedCurrent.x === this.__props.current.x && this.__props.dampedCurrent.y === this.__props.current.y) {
|
|
85
118
|
this.$services.disable("ticked");
|
|
86
119
|
}
|
|
87
|
-
|
|
88
|
-
const renderFn = this.__callMethod("scrolledInView", this.__props);
|
|
89
|
-
if ((0, import_utils.isFunction)(renderFn)) {
|
|
90
|
-
scheduler.render(() => {
|
|
91
|
-
renderFn(this.__props);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
});
|
|
120
|
+
render();
|
|
95
121
|
}
|
|
96
122
|
};
|
|
97
123
|
this.$on("before-mounted", () => {
|
|
@@ -106,27 +132,37 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
106
132
|
this.$off("resized", delegate);
|
|
107
133
|
this.$off("scrolled", delegate);
|
|
108
134
|
this.$off("ticked", delegate);
|
|
135
|
+
this.__props.dampedCurrent.x = this.__props.current.x;
|
|
136
|
+
this.__props.dampedCurrent.y = this.__props.current.y;
|
|
137
|
+
this.__props.dampedProgress.x = this.__props.progress.x;
|
|
138
|
+
this.__props.dampedProgress.y = this.__props.progress.y;
|
|
139
|
+
render();
|
|
109
140
|
});
|
|
110
141
|
}
|
|
111
142
|
mounted() {
|
|
112
|
-
if ((0, import_utils.isFunction)(super.mounted))
|
|
143
|
+
if ((0, import_utils.isFunction)(super.mounted)) {
|
|
113
144
|
super.mounted();
|
|
145
|
+
}
|
|
114
146
|
}
|
|
115
147
|
resized(props) {
|
|
116
|
-
if ((0, import_utils.isFunction)(super.resized))
|
|
148
|
+
if ((0, import_utils.isFunction)(super.resized)) {
|
|
117
149
|
super.resized(props);
|
|
150
|
+
}
|
|
118
151
|
}
|
|
119
152
|
scrolled(props) {
|
|
120
|
-
if ((0, import_utils.isFunction)(super.scrolled))
|
|
153
|
+
if ((0, import_utils.isFunction)(super.scrolled)) {
|
|
121
154
|
super.scrolled(props);
|
|
155
|
+
}
|
|
122
156
|
}
|
|
123
157
|
ticked(props) {
|
|
124
|
-
if ((0, import_utils.isFunction)(super.ticked))
|
|
158
|
+
if ((0, import_utils.isFunction)(super.ticked)) {
|
|
125
159
|
super.ticked(props);
|
|
160
|
+
}
|
|
126
161
|
}
|
|
127
162
|
destroyed() {
|
|
128
|
-
if ((0, import_utils.isFunction)(super.destroyed))
|
|
163
|
+
if ((0, import_utils.isFunction)(super.destroyed)) {
|
|
129
164
|
super.destroyed();
|
|
165
|
+
}
|
|
130
166
|
}
|
|
131
167
|
__setProps() {
|
|
132
168
|
const sizes = options.useOffsetSizes ? (0, import_utils.getOffsetSizes)(this.$el) : this.$el.getBoundingClientRect();
|
|
@@ -144,10 +180,26 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
144
180
|
this.__props.end.y = yEnd;
|
|
145
181
|
this.__props.current.x = xCurrent;
|
|
146
182
|
this.__props.current.y = yCurrent;
|
|
183
|
+
this.__props.dampedCurrent.x = (0, import_utils.damp)(
|
|
184
|
+
xCurrent,
|
|
185
|
+
this.__props.dampedCurrent.x,
|
|
186
|
+
this.dampFactor,
|
|
187
|
+
this.dampPrecision
|
|
188
|
+
);
|
|
189
|
+
this.__props.dampedCurrent.y = (0, import_utils.damp)(
|
|
190
|
+
yCurrent,
|
|
191
|
+
this.__props.dampedCurrent.y,
|
|
192
|
+
this.dampFactor,
|
|
193
|
+
this.dampPrecision
|
|
194
|
+
);
|
|
147
195
|
this.__props.progress.x = xProgress;
|
|
148
196
|
this.__props.progress.y = yProgress;
|
|
149
|
-
this.__props.dampedProgress.x = (0, import_utils.
|
|
150
|
-
|
|
197
|
+
this.__props.dampedProgress.x = (0, import_utils.clamp01)(
|
|
198
|
+
(this.__props.dampedCurrent.x - xStart) / (xEnd - xStart)
|
|
199
|
+
);
|
|
200
|
+
this.__props.dampedProgress.y = (0, import_utils.clamp01)(
|
|
201
|
+
(this.__props.dampedCurrent.y - yStart) / (yEnd - yStart)
|
|
202
|
+
);
|
|
151
203
|
}
|
|
152
204
|
}, __publicField(_a, "config", {
|
|
153
205
|
name: `${BaseClass.config.name}WithMountWhenInView`,
|
|
@@ -7,9 +7,29 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
import withMountWhenInView from "./withMountWhenInView.js";
|
|
8
8
|
import { damp, clamp, clamp01, getOffsetSizes, isFunction, useScheduler } from "../utils/index.js";
|
|
9
9
|
const scheduler = useScheduler(["update", "render"]);
|
|
10
|
+
function updateProps(props, dampFactor, dampPrecision, axis = "x") {
|
|
11
|
+
props.current[axis] = clamp(
|
|
12
|
+
axis === "x" ? window.pageXOffset : window.pageYOffset,
|
|
13
|
+
props.start[axis],
|
|
14
|
+
props.end[axis]
|
|
15
|
+
);
|
|
16
|
+
props.dampedCurrent[axis] = damp(
|
|
17
|
+
props.current[axis],
|
|
18
|
+
props.dampedCurrent[axis],
|
|
19
|
+
dampFactor,
|
|
20
|
+
dampPrecision
|
|
21
|
+
);
|
|
22
|
+
props.progress[axis] = clamp01(
|
|
23
|
+
(props.current[axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
|
|
24
|
+
);
|
|
25
|
+
props.dampedProgress[axis] = clamp01(
|
|
26
|
+
(props.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
|
|
27
|
+
);
|
|
28
|
+
}
|
|
10
29
|
function withScrolledInView(BaseClass, options = {}) {
|
|
11
30
|
var _a;
|
|
12
|
-
|
|
31
|
+
const WithMountWhenInView = withMountWhenInView(BaseClass, options);
|
|
32
|
+
return _a = class extends WithMountWhenInView {
|
|
13
33
|
constructor(element) {
|
|
14
34
|
super(element);
|
|
15
35
|
__publicField(this, "__props", {
|
|
@@ -25,6 +45,10 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
25
45
|
x: 0,
|
|
26
46
|
y: 0
|
|
27
47
|
},
|
|
48
|
+
dampedCurrent: {
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0
|
|
51
|
+
},
|
|
28
52
|
progress: {
|
|
29
53
|
x: 0,
|
|
30
54
|
y: 0
|
|
@@ -36,6 +60,16 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
36
60
|
});
|
|
37
61
|
__publicField(this, "dampFactor", 0.1);
|
|
38
62
|
__publicField(this, "dampPrecision", 1e-3);
|
|
63
|
+
const render = () => {
|
|
64
|
+
scheduler.update(() => {
|
|
65
|
+
const renderFn = this.__callMethod("scrolledInView", this.__props);
|
|
66
|
+
if (isFunction(renderFn)) {
|
|
67
|
+
scheduler.render(() => {
|
|
68
|
+
renderFn(this.__props);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
39
73
|
const delegate = {
|
|
40
74
|
handleEvent(event) {
|
|
41
75
|
delegate[event.type](event.detail[0]);
|
|
@@ -49,23 +83,12 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
49
83
|
}
|
|
50
84
|
},
|
|
51
85
|
ticked: () => {
|
|
52
|
-
this.__props
|
|
53
|
-
|
|
54
|
-
this.__props.
|
|
55
|
-
this.__props.current.y = clamp(window.pageYOffset, this.__props.start.y, this.__props.end.y);
|
|
56
|
-
this.__props.progress.y = clamp01((this.__props.current.y - this.__props.start.y) / (this.__props.end.y - this.__props.start.y));
|
|
57
|
-
this.__props.dampedProgress.y = damp(this.__props.progress.y, this.__props.dampedProgress.y, this.dampFactor, this.dampPrecision);
|
|
58
|
-
if (this.__props.dampedProgress.x === this.__props.progress.x && this.__props.dampedProgress.y === this.__props.progress.y) {
|
|
86
|
+
updateProps(this.__props, this.dampFactor, this.dampPrecision, "x");
|
|
87
|
+
updateProps(this.__props, this.dampFactor, this.dampPrecision, "y");
|
|
88
|
+
if (this.__props.dampedCurrent.x === this.__props.current.x && this.__props.dampedCurrent.y === this.__props.current.y) {
|
|
59
89
|
this.$services.disable("ticked");
|
|
60
90
|
}
|
|
61
|
-
|
|
62
|
-
const renderFn = this.__callMethod("scrolledInView", this.__props);
|
|
63
|
-
if (isFunction(renderFn)) {
|
|
64
|
-
scheduler.render(() => {
|
|
65
|
-
renderFn(this.__props);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
91
|
+
render();
|
|
69
92
|
}
|
|
70
93
|
};
|
|
71
94
|
this.$on("before-mounted", () => {
|
|
@@ -80,27 +103,37 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
80
103
|
this.$off("resized", delegate);
|
|
81
104
|
this.$off("scrolled", delegate);
|
|
82
105
|
this.$off("ticked", delegate);
|
|
106
|
+
this.__props.dampedCurrent.x = this.__props.current.x;
|
|
107
|
+
this.__props.dampedCurrent.y = this.__props.current.y;
|
|
108
|
+
this.__props.dampedProgress.x = this.__props.progress.x;
|
|
109
|
+
this.__props.dampedProgress.y = this.__props.progress.y;
|
|
110
|
+
render();
|
|
83
111
|
});
|
|
84
112
|
}
|
|
85
113
|
mounted() {
|
|
86
|
-
if (isFunction(super.mounted))
|
|
114
|
+
if (isFunction(super.mounted)) {
|
|
87
115
|
super.mounted();
|
|
116
|
+
}
|
|
88
117
|
}
|
|
89
118
|
resized(props) {
|
|
90
|
-
if (isFunction(super.resized))
|
|
119
|
+
if (isFunction(super.resized)) {
|
|
91
120
|
super.resized(props);
|
|
121
|
+
}
|
|
92
122
|
}
|
|
93
123
|
scrolled(props) {
|
|
94
|
-
if (isFunction(super.scrolled))
|
|
124
|
+
if (isFunction(super.scrolled)) {
|
|
95
125
|
super.scrolled(props);
|
|
126
|
+
}
|
|
96
127
|
}
|
|
97
128
|
ticked(props) {
|
|
98
|
-
if (isFunction(super.ticked))
|
|
129
|
+
if (isFunction(super.ticked)) {
|
|
99
130
|
super.ticked(props);
|
|
131
|
+
}
|
|
100
132
|
}
|
|
101
133
|
destroyed() {
|
|
102
|
-
if (isFunction(super.destroyed))
|
|
134
|
+
if (isFunction(super.destroyed)) {
|
|
103
135
|
super.destroyed();
|
|
136
|
+
}
|
|
104
137
|
}
|
|
105
138
|
__setProps() {
|
|
106
139
|
const sizes = options.useOffsetSizes ? getOffsetSizes(this.$el) : this.$el.getBoundingClientRect();
|
|
@@ -118,10 +151,26 @@ function withScrolledInView(BaseClass, options = {}) {
|
|
|
118
151
|
this.__props.end.y = yEnd;
|
|
119
152
|
this.__props.current.x = xCurrent;
|
|
120
153
|
this.__props.current.y = yCurrent;
|
|
154
|
+
this.__props.dampedCurrent.x = damp(
|
|
155
|
+
xCurrent,
|
|
156
|
+
this.__props.dampedCurrent.x,
|
|
157
|
+
this.dampFactor,
|
|
158
|
+
this.dampPrecision
|
|
159
|
+
);
|
|
160
|
+
this.__props.dampedCurrent.y = damp(
|
|
161
|
+
yCurrent,
|
|
162
|
+
this.__props.dampedCurrent.y,
|
|
163
|
+
this.dampFactor,
|
|
164
|
+
this.dampPrecision
|
|
165
|
+
);
|
|
121
166
|
this.__props.progress.x = xProgress;
|
|
122
167
|
this.__props.progress.y = yProgress;
|
|
123
|
-
this.__props.dampedProgress.x =
|
|
124
|
-
|
|
168
|
+
this.__props.dampedProgress.x = clamp01(
|
|
169
|
+
(this.__props.dampedCurrent.x - xStart) / (xEnd - xStart)
|
|
170
|
+
);
|
|
171
|
+
this.__props.dampedProgress.y = clamp01(
|
|
172
|
+
(this.__props.dampedCurrent.y - yStart) / (yEnd - yStart)
|
|
173
|
+
);
|
|
125
174
|
}
|
|
126
175
|
}, __publicField(_a, "config", {
|
|
127
176
|
name: `${BaseClass.config.name}WithMountWhenInView`,
|