Skip to content

Commit b07ba45

Browse files
committed
perf(scroll-to-top): use shallowRef instead deep ref
1 parent c8aed17 commit b07ba45

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

app/components/ScrollToTop.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ const excludedRoutes = new Set(['index', 'code'])
77
const isActive = computed(() => !excludedRoutes.has(route.name as string))
88
99
const isMounted = useMounted()
10-
const isVisible = ref(false)
10+
const isVisible = shallowRef(false)
1111
const scrollThreshold = 300
12-
const supportsScrollStateQueries = ref(false)
12+
const supportsScrollStateQueries = useSupported(() => {
13+
return isMounted.value && CSS.supports('container-type', 'scroll-state')
14+
})
1315
1416
function onScroll() {
1517
if (!supportsScrollStateQueries.value) {
@@ -25,9 +27,6 @@ function scrollToTop() {
2527
useEventListener('scroll', onScroll, { passive: true })
2628
2729
onMounted(() => {
28-
// Feature detect CSS scroll-state container queries (Chrome 133+)
29-
supportsScrollStateQueries.value = CSS.supports('container-type', 'scroll-state')
30-
3130
onScroll()
3231
})
3332
</script>

0 commit comments

Comments
 (0)