srcdev-nuxt-components 6.2.0 → 6.2.1
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.
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
'animation-timeline': key === itemCount - 1 ? 'none' : `--section-${timelineId}-${key}`,
|
|
16
16
|
'z-index': itemCount - key,
|
|
17
17
|
}"
|
|
18
|
+
ref="stickyItemsRef"
|
|
18
19
|
>
|
|
19
20
|
<slot :name="`stickyItem-${key}`"></slot>
|
|
20
21
|
</div>
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
:style="{
|
|
28
29
|
'view-timeline-name': `--section-${timelineId}-${key}`,
|
|
29
30
|
}"
|
|
31
|
+
ref="scrollingItemsRef"
|
|
30
32
|
>
|
|
31
33
|
<slot :name="`scrollingItem-${key}`"></slot>
|
|
32
34
|
</section>
|
|
@@ -54,7 +56,9 @@ const { elementClasses, resetElementClasses } = useStyleClassPassthrough(props.s
|
|
|
54
56
|
|
|
55
57
|
const timelineId = useId()
|
|
56
58
|
const stickyItemsContainerRef = useTemplateRef<HTMLElement | null>("stickyItemsContainerRef")
|
|
59
|
+
const stickyItemsRef = useTemplateRef<HTMLElement[] | null>("stickyItemsRef")
|
|
57
60
|
const scrollContainerRef = useTemplateRef<HTMLElement | null>("scrollContainerRef")
|
|
61
|
+
const scrollingItemsRef = useTemplateRef<HTMLElement[] | null>("scrollingItemsRef")
|
|
58
62
|
const timelineInset = ref("35% 35%")
|
|
59
63
|
const topPercent = ref("0")
|
|
60
64
|
const bottomPercent = ref("0")
|
|
@@ -94,13 +98,36 @@ watch(
|
|
|
94
98
|
}
|
|
95
99
|
)
|
|
96
100
|
|
|
101
|
+
const fallbackScrollHandler = () => {
|
|
102
|
+
const sections = scrollingItemsRef.value || []
|
|
103
|
+
const layers = stickyItemsRef.value || []
|
|
104
|
+
|
|
105
|
+
const mid = window.innerHeight / 2
|
|
106
|
+
|
|
107
|
+
sections.forEach((section, i) => {
|
|
108
|
+
const rect = section.getBoundingClientRect()
|
|
109
|
+
const active = rect.top <= mid && rect.bottom >= mid
|
|
110
|
+
if (layers[i]) layers[i].style.opacity = active ? "1" : "0"
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const supportsScrollTimeline = import.meta.client ? CSS.supports("animation-timeline: view()") : false
|
|
115
|
+
|
|
97
116
|
onMounted(() => {
|
|
98
117
|
calculateInset()
|
|
99
|
-
|
|
118
|
+
if (supportsScrollTimeline) {
|
|
119
|
+
window.addEventListener("scroll", onScrollDebounce)
|
|
120
|
+
} else {
|
|
121
|
+
window.addEventListener("scroll", fallbackScrollHandler)
|
|
122
|
+
}
|
|
100
123
|
})
|
|
101
124
|
|
|
102
125
|
onUnmounted(() => {
|
|
103
|
-
|
|
126
|
+
if (supportsScrollTimeline) {
|
|
127
|
+
window.removeEventListener("scroll", onScrollDebounce)
|
|
128
|
+
} else {
|
|
129
|
+
window.removeEventListener("scroll", fallbackScrollHandler)
|
|
130
|
+
}
|
|
104
131
|
})
|
|
105
132
|
</script>
|
|
106
133
|
|
|
@@ -141,4 +168,11 @@ onUnmounted(() => {
|
|
|
141
168
|
animation-range: entry 0% entry 100%;
|
|
142
169
|
}
|
|
143
170
|
}
|
|
171
|
+
|
|
172
|
+
@supports not (animation-timeline: view()) {
|
|
173
|
+
.sticky-item {
|
|
174
|
+
opacity: 0;
|
|
175
|
+
transition: opacity 0.4s ease-in-out;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
144
178
|
</style>
|
package/package.json
CHANGED