@ulu/frontend-vue 0.1.3-beta.15 → 0.1.3-beta.17
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/frontend-vue.js +491 -469
- package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue.d.ts +3 -0
- package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue.d.ts.map +1 -1
- package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsSection.vue.d.ts.map +1 -1
- package/dist/types/components/systems/scroll-anchors/useScrollAnchorSection.d.ts.map +1 -1
- package/dist/types/components/systems/scroll-anchors/useScrollAnchors.d.ts.map +1 -1
- package/lib/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue +21 -7
- package/lib/components/systems/scroll-anchors/UluScrollAnchorsSection.vue +15 -4
- package/lib/components/systems/scroll-anchors/useScrollAnchorSection.js +5 -1
- package/lib/components/systems/scroll-anchors/useScrollAnchors.js +9 -3
- package/package.json +1 -1
package/dist/types/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UluScrollAnchorsHeadlessSection.vue.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UluScrollAnchorsHeadlessSection.vue.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/UluScrollAnchorsHeadlessSection.vue"],"names":[],"mappings":"wBAsKqB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;;qBAEpD,CAAC,EAAE,CAAC;;;AARzB;YAGmB,OAAO,CAAC,OAAO,KAAK,CAAC;;;;2OAErC;;;;;;;;;;;AA9GD;;;;EAmBG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UluScrollAnchorsSection.vue.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/UluScrollAnchorsSection.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UluScrollAnchorsSection.vue.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/UluScrollAnchorsSection.vue"],"names":[],"mappings":"wBA+NqB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;;qBAEpD,CAAC,EAAE,CAAC;;;AARzB;YAGmB,OAAO,CAAC,OAAO,KAAK,CAAC;;;;;;;;2OAErC;;;;;;;;AA5ID;;;;;;;;EA4CG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollAnchorSection.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/useScrollAnchorSection.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,8CAHW,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"useScrollAnchorSection.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/useScrollAnchorSection.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,8CAHW,MAAM,GACJ,MAAM,CAmDlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollAnchors.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/useScrollAnchors.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,4EAFW;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,WAAW;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,
|
|
1
|
+
{"version":3,"file":"useScrollAnchors.d.ts","sourceRoot":"","sources":["../../../../../lib/components/systems/scroll-anchors/useScrollAnchors.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,4EAFW;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,WAAW;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,QAqJnF"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="element"
|
|
4
|
-
:class="[
|
|
5
|
-
|
|
2
|
+
<component
|
|
3
|
+
:is="element"
|
|
4
|
+
:class="[
|
|
5
|
+
'scroll-anchors__section',
|
|
6
|
+
{ 'is-active': isActive }
|
|
7
|
+
]"
|
|
8
|
+
:data-scrollpoint-state="sectionState"
|
|
9
|
+
ref="sectionRef"
|
|
6
10
|
>
|
|
7
|
-
<slot :isActive="isActive" :titleId="titleId" :section="section" />
|
|
11
|
+
<slot :isActive="isActive" :titleId="titleId" :section="section" :inactiveFrom="inactiveFrom" :activeFrom="activeFrom" :sectionState="sectionState" />
|
|
8
12
|
</component>
|
|
9
13
|
</template>
|
|
10
14
|
|
|
11
15
|
<script setup>
|
|
16
|
+
import { computed } from "vue";
|
|
12
17
|
import { useScrollAnchorSection } from "./useScrollAnchorSection";
|
|
13
18
|
|
|
14
19
|
const props = defineProps({
|
|
@@ -24,7 +29,7 @@
|
|
|
24
29
|
*/
|
|
25
30
|
customTitleId: String,
|
|
26
31
|
/**
|
|
27
|
-
* Element to use
|
|
32
|
+
* Element to use
|
|
28
33
|
*/
|
|
29
34
|
element: {
|
|
30
35
|
type: String,
|
|
@@ -32,5 +37,14 @@
|
|
|
32
37
|
}
|
|
33
38
|
});
|
|
34
39
|
|
|
35
|
-
const { sectionRef, titleId, isActive, section } = useScrollAnchorSection(props);
|
|
40
|
+
const { sectionRef, titleId, isActive, inactiveFrom, activeFrom, section } = useScrollAnchorSection(props);
|
|
41
|
+
|
|
42
|
+
const sectionState = computed(() => {
|
|
43
|
+
if (isActive.value) {
|
|
44
|
+
if (activeFrom.value) return `enter-${activeFrom.value}`;
|
|
45
|
+
} else {
|
|
46
|
+
if (inactiveFrom.value) return `exit-${inactiveFrom.value}`;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
});
|
|
36
50
|
</script>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="element"
|
|
4
|
-
:class="[wrapperClass, { [activeClass]
|
|
2
|
+
<component
|
|
3
|
+
:is="element"
|
|
4
|
+
:class="[wrapperClass, { [activeClass]: activeClass && isActive }]"
|
|
5
|
+
:data-scrollpoint-state="sectionState"
|
|
5
6
|
ref="sectionRef"
|
|
6
7
|
>
|
|
7
8
|
<component :is="titleElement" :class="titleClass" :id="titleId">
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
</template>
|
|
15
16
|
|
|
16
17
|
<script setup>
|
|
18
|
+
import { computed } from "vue";
|
|
17
19
|
import { useScrollAnchorSection } from "./useScrollAnchorSection";
|
|
18
20
|
|
|
19
21
|
const props = defineProps({
|
|
@@ -62,5 +64,14 @@
|
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
66
|
|
|
65
|
-
const { sectionRef, titleId, isActive, section } = useScrollAnchorSection(props);
|
|
67
|
+
const { sectionRef, titleId, isActive, inactiveFrom, activeFrom, section } = useScrollAnchorSection(props);
|
|
68
|
+
|
|
69
|
+
const sectionState = computed(() => {
|
|
70
|
+
if (isActive.value) {
|
|
71
|
+
if (activeFrom.value) return `enter-${activeFrom.value}`;
|
|
72
|
+
} else {
|
|
73
|
+
if (inactiveFrom.value) return `exit-${inactiveFrom.value}`;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
});
|
|
66
77
|
</script>
|
|
@@ -22,7 +22,9 @@ export function useScrollAnchorSection(props) {
|
|
|
22
22
|
title: props.title,
|
|
23
23
|
titleId: titleId.value,
|
|
24
24
|
element: null, // will be set on mount
|
|
25
|
-
active: false
|
|
25
|
+
active: false,
|
|
26
|
+
inactiveFrom: null,
|
|
27
|
+
activeFrom: null
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
// Keep title and titleId in sync with props
|
|
@@ -51,6 +53,8 @@ export function useScrollAnchorSection(props) {
|
|
|
51
53
|
sectionRef, // the ref for the user to attach
|
|
52
54
|
titleId,
|
|
53
55
|
isActive: computed(() => section.active),
|
|
56
|
+
inactiveFrom: computed(() => section.inactiveFrom),
|
|
57
|
+
activeFrom: computed(() => section.activeFrom),
|
|
54
58
|
section
|
|
55
59
|
};
|
|
56
60
|
}
|
|
@@ -15,9 +15,13 @@ export function useScrollAnchors({ sections, props, emit, componentElRef }) {
|
|
|
15
15
|
return sections.value.findIndex(({ element }) => el === element);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function removeActive(except = null) {
|
|
18
|
+
function removeActive(except = null, scrollDirection = 'down') {
|
|
19
19
|
sections.value.forEach(s => {
|
|
20
20
|
if (s !== except) {
|
|
21
|
+
if (s.active) {
|
|
22
|
+
s.inactiveFrom = scrollDirection === 'down' ? 'forward' : 'reverse';
|
|
23
|
+
s.activeFrom = null;
|
|
24
|
+
}
|
|
21
25
|
s.active = false;
|
|
22
26
|
}
|
|
23
27
|
});
|
|
@@ -67,8 +71,10 @@ export function useScrollAnchors({ sections, props, emit, componentElRef }) {
|
|
|
67
71
|
if (sectionToActivate && !sectionToActivate.active) {
|
|
68
72
|
if (props.debug) console.log("Activating section:", sectionToActivate.title);
|
|
69
73
|
nextTick(() => {
|
|
70
|
-
removeActive(sectionToActivate);
|
|
74
|
+
removeActive(sectionToActivate, scrollDirection);
|
|
71
75
|
sectionToActivate.active = true;
|
|
76
|
+
sectionToActivate.inactiveFrom = null;
|
|
77
|
+
sectionToActivate.activeFrom = scrollDirection === 'down' ? 'forward' : 'reverse';
|
|
72
78
|
emit("section-change", { section: sectionToActivate, sections: sections.value, active: true });
|
|
73
79
|
});
|
|
74
80
|
}
|
|
@@ -84,7 +90,7 @@ export function useScrollAnchors({ sections, props, emit, componentElRef }) {
|
|
|
84
90
|
if ((isFirst && scrollDirection === 'up' && !props.firstItemActive) || (isLast && scrollDirection === 'down')) {
|
|
85
91
|
if (props.debug) console.log("Deactivating section at edge:", activeSection.title);
|
|
86
92
|
nextTick(() => {
|
|
87
|
-
removeActive();
|
|
93
|
+
removeActive(null, scrollDirection);
|
|
88
94
|
emit("section-change", { section: activeSection, sections: sections.value, active: false });
|
|
89
95
|
});
|
|
90
96
|
}
|