@maas/vue-equipment 0.15.1 → 0.16.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/dist/nuxt/module.json +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +1 -6
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.d.ts +2 -2
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.mjs +9 -7
- package/dist/plugins/MagicScroll/src/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/nuxt/module.json
CHANGED
|
@@ -18,16 +18,11 @@ interface Props {
|
|
|
18
18
|
|
|
19
19
|
const props = defineProps<Props>()
|
|
20
20
|
const targetRef = ref<HTMLElement | undefined>(undefined)
|
|
21
|
-
const colDetect = ref()
|
|
22
21
|
|
|
23
22
|
const scrollPosition = inject(ScrollPositionKey, undefined)
|
|
24
23
|
const pageYOffset = computed(() => toValue(scrollPosition?.y) || 0)
|
|
25
24
|
|
|
26
25
|
onMounted(() => {
|
|
27
|
-
|
|
28
|
-
pageYOffset,
|
|
29
|
-
props.collisionEntries,
|
|
30
|
-
toValue(targetRef.value),
|
|
31
|
-
)
|
|
26
|
+
useCollisionDetect(pageYOffset, props.collisionEntries, toValue(targetRef))
|
|
32
27
|
})
|
|
33
28
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
-
import type { CollisionEntry,
|
|
2
|
+
import type { CollisionEntry, MappedCollisionEntry } from '../types.js';
|
|
3
3
|
export declare function useCollisionDetect(pageYOffset: ComputedRef<number>, collisionEntries: CollisionEntry[], parent: HTMLElement | undefined): {
|
|
4
|
-
|
|
4
|
+
mappedCollisionEntries: Ref<MappedCollisionEntry[]>;
|
|
5
5
|
};
|
|
6
6
|
export type UseCollisionDetectReturn = ReturnType<typeof useCollisionDetect>;
|
|
@@ -5,7 +5,7 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
5
5
|
const scrolled = ref(0);
|
|
6
6
|
const intersecting = ref();
|
|
7
7
|
const scrollDirection = ref();
|
|
8
|
-
const
|
|
8
|
+
const mappedCollisionEntries = ref([]);
|
|
9
9
|
const oppositeScrollDirection = computed(
|
|
10
10
|
() => scrollDirection.value === "up" ? "down" : "up"
|
|
11
11
|
);
|
|
@@ -19,7 +19,7 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
19
19
|
function initialize() {
|
|
20
20
|
if (!parent)
|
|
21
21
|
return;
|
|
22
|
-
|
|
22
|
+
mappedCollisionEntries.value = collisionEntries.map((entry) => {
|
|
23
23
|
const alerted = {
|
|
24
24
|
up: {
|
|
25
25
|
top: false,
|
|
@@ -32,8 +32,10 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
32
32
|
};
|
|
33
33
|
const offset = { top: 0, bottom: 0, ...entry.offset };
|
|
34
34
|
const element = entry.element ? parent?.querySelector(entry.element) : parent;
|
|
35
|
+
if (!element)
|
|
36
|
+
return void 0;
|
|
35
37
|
return { ...entry, offset, element, alerted };
|
|
36
|
-
});
|
|
38
|
+
}).filter((element) => !!element);
|
|
37
39
|
useIntersectionObserver(
|
|
38
40
|
parent.querySelector("*"),
|
|
39
41
|
([{ isIntersecting }]) => {
|
|
@@ -51,9 +53,9 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
51
53
|
}
|
|
52
54
|
scrollDirection.value = scrolled.value <= pageYOffset.value ? "down" : "up";
|
|
53
55
|
scrolled.value = pageYOffset.value;
|
|
54
|
-
let i =
|
|
56
|
+
let i = mappedCollisionEntries.value.length;
|
|
55
57
|
while (i--) {
|
|
56
|
-
const entry =
|
|
58
|
+
const entry = mappedCollisionEntries.value[i];
|
|
57
59
|
if (!entry.element)
|
|
58
60
|
return;
|
|
59
61
|
const boundingRect = entry.element.getBoundingClientRect();
|
|
@@ -66,7 +68,7 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
function resetAll() {
|
|
69
|
-
|
|
71
|
+
mappedCollisionEntries.value = mappedCollisionEntries.value.map((entry) => {
|
|
70
72
|
const alerted = {
|
|
71
73
|
up: {
|
|
72
74
|
top: false,
|
|
@@ -112,6 +114,6 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
112
114
|
}
|
|
113
115
|
);
|
|
114
116
|
return {
|
|
115
|
-
|
|
117
|
+
mappedCollisionEntries
|
|
116
118
|
};
|
|
117
119
|
}
|
|
@@ -18,7 +18,7 @@ interface CollisionEntry {
|
|
|
18
18
|
element?: string;
|
|
19
19
|
data: Record<string, any>;
|
|
20
20
|
}
|
|
21
|
-
interface
|
|
21
|
+
interface MappedCollisionEntry extends Omit<CollisionEntry, 'element'> {
|
|
22
22
|
alerted: {
|
|
23
23
|
up: AlertPositions;
|
|
24
24
|
down: AlertPositions;
|
|
@@ -30,4 +30,4 @@ type Dimensions = {
|
|
|
30
30
|
height: number;
|
|
31
31
|
};
|
|
32
32
|
type FromTo = 'top-top' | 'top-center' | 'top-bottom' | 'center-top' | 'center-center' | 'center-bottom' | 'bottom-top' | 'bottom-center' | 'bottom-bottom';
|
|
33
|
-
export type { FromTo, CollisionEvents, CollisionEntry,
|
|
33
|
+
export type { FromTo, CollisionEvents, CollisionEntry, MappedCollisionEntry, Dimensions, };
|
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.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.12",
|