@@ -9,13 +9,15 @@ const isActive = computed(() => !excludedRoutes.has(route.name as string))
99const SCROLL_TO_TOP_DURATION = 500
1010
1111const isMounted = useMounted ()
12+ const isTouchDeviceClient = shallowRef (false )
1213const isVisible = shallowRef (false )
1314const scrollThreshold = 300
1415const { isSupported : supportsScrollStateQueries } = useCssSupports (
1516 ' container-type' ,
1617 ' scroll-state' ,
1718 { ssrValue: false },
1819)
20+ const shouldShowButton = computed (() => isActive .value && isTouchDeviceClient .value )
1921
2022function onScroll() {
2123 if (supportsScrollStateQueries .value ) {
@@ -29,14 +31,15 @@ const { scrollToTop } = useScrollToTop({ duration: SCROLL_TO_TOP_DURATION })
2931useEventListener (' scroll' , onScroll , { passive: true })
3032
3133onMounted (() => {
34+ isTouchDeviceClient .value = isTouchDevice ()
3235 onScroll ()
3336})
3437 </script >
3538
3639<template >
3740 <!-- When CSS scroll-state is supported, use CSS-only visibility -->
3841 <button
39- v-if =" isActive && supportsScrollStateQueries"
42+ v-if =" shouldShowButton && supportsScrollStateQueries"
4043 type =" button"
4144 class =" scroll-to-top-css fixed bottom-4 inset-ie-4 z-50 w-12 h-12 bg-bg-elevated border border-border rounded-full shadow-lg flex items-center justify-center text-fg-muted hover:text-fg transition-colors active:scale-95"
4245 :aria-label =" $t('common.scroll_to_top')"
@@ -56,7 +59,7 @@ onMounted(() => {
5659 leave-to-class =" opacity-0 translate-y-2"
5760 >
5861 <button
59- v-if =" isActive && isMounted && isVisible"
62+ v-if =" shouldShowButton && isMounted && isVisible"
6063 type =" button"
6164 class =" fixed bottom-4 inset-ie-4 z-50 w-12 h-12 bg-bg-elevated border border-border rounded-full shadow-lg flex items-center justify-center text-fg-muted hover:text-fg transition-colors active:scale-95"
6265 :aria-label =" $t('common.scroll_to_top')"
0 commit comments