|
@@ -31,20 +31,17 @@
|
|
|
const top: Ref<number | null> = ref(null)
|
|
const top: Ref<number | null> = ref(null)
|
|
|
const bottom: Ref<number | null> = ref(null)
|
|
const bottom: Ref<number | null> = ref(null)
|
|
|
|
|
|
|
|
- onMounted(() => {
|
|
|
|
|
|
|
+ const onScroll = (scroll: any) => {
|
|
|
top.value = section.value!.offsetTop
|
|
top.value = section.value!.offsetTop
|
|
|
bottom.value = section.value!.offsetTop + section.value!.offsetHeight
|
|
bottom.value = section.value!.offsetTop + section.value!.offsetHeight
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
- const onScroll = (e: any) => {
|
|
|
|
|
if (top.value === null || bottom.value === null) {
|
|
if (top.value === null || bottom.value === null) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const screenVerticalCenter = document.documentElement.scrollTop + window.innerHeight / 2
|
|
|
|
|
|
|
+ const screenVerticalCenter = scroll.target.documentElement.scrollTop + window.innerHeight / 2
|
|
|
|
|
|
|
|
const active = screenVerticalCenter > top.value && screenVerticalCenter < bottom.value
|
|
const active = screenVerticalCenter > top.value && screenVerticalCenter < bottom.value
|
|
|
-
|
|
|
|
|
if (active !== layoutStore.isAnchoredSectionOnScreen[props.id]) {
|
|
if (active !== layoutStore.isAnchoredSectionOnScreen[props.id]) {
|
|
|
layoutStore.setIsAnchoredSectionOnScreen(
|
|
layoutStore.setIsAnchoredSectionOnScreen(
|
|
|
props.id,
|
|
props.id,
|