fix: use window scroll API for cross-browser compatibility (Safari)

This commit is contained in:
Julien Calixte
2026-02-19 19:03:06 +01:00
parent bb06274c41
commit 4a06c11b0a

View File

@@ -4,7 +4,6 @@ import { computed, ref } from 'vue'
import { MOBILE_BREAKPOINT } from '@/constants/mobile' import { MOBILE_BREAKPOINT } from '@/constants/mobile'
export const useOverlay = (listen = true) => { export const useOverlay = (listen = true) => {
const body = document.body
const x = ref(0) const x = ref(0)
const y = ref(0) const y = ref(0)
const { width } = useWindowSize() const { width } = useWindowSize()
@@ -12,12 +11,11 @@ export const useOverlay = (listen = true) => {
if (listen) { if (listen) {
useEventListener( useEventListener(
body, window,
'scroll', 'scroll',
(event) => { () => {
const target = event.target as HTMLElement x.value = window.scrollX
x.value = target.scrollLeft y.value = window.scrollY
y.value = target.scrollTop
}, },
{ {
passive: true, passive: true,
@@ -36,7 +34,7 @@ export const useOverlay = (listen = true) => {
left: to left: to
} }
body.scroll(scrollOptions) window.scrollTo(scrollOptions)
} }
setTimeout(() => { setTimeout(() => {