Skip to content

Commit 7faaedd

Browse files
committed
perf(footer): use shallowRef instead deep ref
1 parent 3128fd0 commit 7faaedd

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

app/components/AppFooter.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<script setup lang="ts">
2-
const isMounted = ref(false)
3-
const isVisible = ref(false)
4-
const isScrollable = ref(true)
5-
const lastScrollY = ref(0)
6-
const footerRef = ref<HTMLElement>()
2+
const isMounted = shallowRef(false)
3+
const isVisible = shallowRef(false)
4+
const isScrollable = shallowRef(true)
5+
const lastScrollY = shallowRef(0)
6+
const footerRef = useTemplateRef('footerRef')
77
88
// Check if CSS scroll-state container queries are supported
99
// Once this becomes baseline, we can remove the JS scroll handling entirely
10-
const supportsScrollStateQueries = ref(false)
10+
const supportsScrollStateQueries = useSupported(() => {
11+
return isMounted.value && CSS.supports('container-type', 'scroll-state')
12+
})
1113
1214
function checkScrollable() {
1315
return document.documentElement.scrollHeight > window.innerHeight
@@ -52,10 +54,6 @@ useEventListener('scroll', onScroll, { passive: true })
5254
useEventListener('resize', onResize, { passive: true })
5355
5456
onMounted(() => {
55-
// Feature detect CSS scroll-state container queries (Chrome 133+)
56-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/@container#scroll-state_container_descriptors
57-
supportsScrollStateQueries.value = CSS.supports('container-type', 'scroll-state')
58-
5957
nextTick(() => {
6058
lastScrollY.value = window.scrollY
6159
isScrollable.value = checkScrollable()

0 commit comments

Comments
 (0)