fix scroll on ios
Deploy app frontend / app frontend (push) Successful in 1m34s

This commit is contained in:
2024-12-07 23:18:32 +02:00
parent cd0cddbf84
commit 0d40aaf2da
2 changed files with 18 additions and 8 deletions
+17 -4
View File
@@ -3,7 +3,7 @@
class="grid h-full sm:grid-rows-[auto_1fr_auto] grid-rows-[1fr_auto_auto] overflow-hidden touch-none"
>
<div
class="flex overflow-hidden overflow-y-scroll scroll-touch pb-safe-or-4 sm:pt-safe px-4 overscroll-contain"
class="flex overflow-hidden overflow-y-auto pb-safe-or-4 sm:pt-safe px-4 overscroll-contain touch-manipulation"
ref="contentScrollContainer"
>
<div class="sm:max-w-prose grid grid-cols-1 mx-auto my-5 w-full">
@@ -67,19 +67,32 @@ const onresize = () => {
}
}
}
const onresizeOptions: AddEventListenerOptions = { passive: true }
visualViewport?.addEventListener('resize', onresize, onresizeOptions)
function preventScroll(e: TouchEvent) {
if (
contentScrollContainerRef.value &&
contentScrollContainerRef.value.scrollHeight <= contentScrollContainerRef.value.clientHeight
) {
e.preventDefault()
}
}
const layoutPageHead = useHead({
htmlAttrs: { class: 'overflow-hidden overscroll-none touch-none fix-layout-scrolling' },
bodyAttrs: { class: 'overflow-hidden overscroll-none touch-none' },
})
onMounted(() => {
visualViewport?.addEventListener('resize', onresize, { passive: true })
contentScrollContainerRef.value!.addEventListener('touchmove', preventScroll, { passive: false })
})
onBeforeUnmount(() => {
layoutPageHead?.dispose()
visualViewport?.removeEventListener('resize', onresize, onresizeOptions)
visualViewport?.removeEventListener('resize', onresize)
document.documentElement.style.removeProperty('--visual-viewport-offset-top')
document.documentElement.style.removeProperty('--visual-viewport-height')
contentScrollContainerRef.value!.removeEventListener('touchmove', preventScroll)
})
</script>
+1 -4
View File
@@ -7,9 +7,6 @@
@layer tailwind-utilities {
@tailwind components;
@tailwind utilities;
.scroll-touch {
-webkit-overflow-scrolling: touch;
}
}
/*html, body, #app {*/
@@ -24,4 +21,4 @@ html {
body, #app {
height: 100%;
}
}