@maas/vue-equipment 0.9.7 → 0.9.9
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/dist/nuxt/module.json
CHANGED
|
@@ -39,6 +39,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
39
39
|
const scrollPosition = inject(ScrollPositionKey, undefined)
|
|
40
40
|
const scrollParent = inject(ScrollParentKey)
|
|
41
41
|
|
|
42
|
+
const intersecting = ref()
|
|
42
43
|
const sceneRef = ref<HTMLElement | undefined>(undefined)
|
|
43
44
|
const progress = ref(0)
|
|
44
45
|
|
|
@@ -49,11 +50,10 @@ const { getCalculations, getProgress } = useScrollApi({
|
|
|
49
50
|
to: props.to,
|
|
50
51
|
})
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
async function calculate() {
|
|
53
54
|
getCalculations()
|
|
54
|
-
nextTick(
|
|
55
|
-
|
|
56
|
-
})
|
|
55
|
+
await nextTick()
|
|
56
|
+
progress.value = getProgress()
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
onMounted(() => {
|
|
@@ -69,15 +69,15 @@ watch(
|
|
|
69
69
|
},
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
const intersecting = ref()
|
|
73
|
-
|
|
74
72
|
useIntersectionObserver(
|
|
75
73
|
toRaw(sceneRef),
|
|
76
74
|
([{ isIntersecting }]) => {
|
|
77
75
|
intersecting.value = isIntersecting
|
|
78
|
-
|
|
76
|
+
if (isIntersecting) {
|
|
77
|
+
calculate()
|
|
78
|
+
}
|
|
79
79
|
},
|
|
80
|
-
{ rootMargin: '150% 0px 150% 0px' },
|
|
80
|
+
{ rootMargin: '150% 0px 150% 0px', threshold: 0.01 },
|
|
81
81
|
)
|
|
82
82
|
|
|
83
83
|
provide('mapValue', mapValue)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, inject, toValue } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { useWindowSize } from "@vueuse/core";
|
|
3
3
|
import { ScrollPositionKey } from "../symbols/index.mjs";
|
|
4
4
|
import { clampValue } from "@maas/vue-equipment/utils";
|
|
5
5
|
export function useScrollApi(params) {
|
|
@@ -9,13 +9,13 @@ export function useScrollApi(params) {
|
|
|
9
9
|
const parentRect = ref();
|
|
10
10
|
const start = ref(0);
|
|
11
11
|
const end = ref(0);
|
|
12
|
-
|
|
12
|
+
function splitLocation(location) {
|
|
13
13
|
return {
|
|
14
14
|
child: location.match(/^[a-z]+/)[0],
|
|
15
15
|
parent: location.match(/[a-z]+$/)[0]
|
|
16
16
|
};
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
function getOffsetTop(points) {
|
|
19
19
|
let y = 0;
|
|
20
20
|
if (!childRect.value)
|
|
21
21
|
return y;
|
|
@@ -53,18 +53,18 @@ export function useScrollApi(params) {
|
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
return y;
|
|
56
|
-
}
|
|
57
|
-
|
|
56
|
+
}
|
|
57
|
+
function getCalculations() {
|
|
58
58
|
childRect.value = toValue(child)?.getBoundingClientRect();
|
|
59
|
-
parentRect.value = toValue(parent) ?
|
|
59
|
+
parentRect.value = toValue(parent) ? toValue(parent)?.getBoundingClientRect() : { ...useWindowSize(), top: 0 };
|
|
60
60
|
start.value = getOffsetTop(splitLocation(from));
|
|
61
61
|
end.value = getOffsetTop(splitLocation(to));
|
|
62
|
-
}
|
|
63
|
-
|
|
62
|
+
}
|
|
63
|
+
function getProgress() {
|
|
64
64
|
const scrollY = toValue(scrollPosition?.y) || 0;
|
|
65
65
|
const total = Math.abs(end.value - start.value);
|
|
66
66
|
const current = scrollY - start.value;
|
|
67
67
|
return clampValue(current / total, 0, 1);
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
return { getCalculations, getProgress };
|
|
70
70
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maas/vue-equipment",
|
|
3
3
|
"description": "A magic collection of Vue composables, plugins, components and directives",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.9",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.5",
|