|
1 | 1 | <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') |
7 | 7 |
|
8 | 8 | // Check if CSS scroll-state container queries are supported |
9 | 9 | // 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 | +}) |
11 | 13 |
|
12 | 14 | function checkScrollable() { |
13 | 15 | return document.documentElement.scrollHeight > window.innerHeight |
@@ -52,10 +54,6 @@ useEventListener('scroll', onScroll, { passive: true }) |
52 | 54 | useEventListener('resize', onResize, { passive: true }) |
53 | 55 |
|
54 | 56 | 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 | | -
|
59 | 57 | nextTick(() => { |
60 | 58 | lastScrollY.value = window.scrollY |
61 | 59 | isScrollable.value = checkScrollable() |
|
0 commit comments