fix chromium

This commit is contained in:
Henry Jameson 2026-09-10 17:15:36 +03:00
commit e53222d632

View file

@ -29,22 +29,19 @@ export function useScrollPosition() {
const scrollIntoView = async (element, options) => { const scrollIntoView = async (element, options) => {
if (element == null) throw new TypeError(`Element is ${element}!`) if (element == null) throw new TypeError(`Element is ${element}!`)
inProgress.value = true inProgress.value = true
let call = element.scrollIntoViewIfNeeded if (!element.scrollIntoViewIfNeeded) {
if (!call) { const { height: windowHeight } = useWindowSize()
call = (options) => { const { top, height } = element.getBoundingClientRect()
const { height: windowHeight } = useWindowSize() const bottom = top + height
const { top, height } = element.getBoundingClientRect()
const bottom = top + height
const biggerThanScreen = height > windowHeight const biggerThanScreen = height > windowHeight
const aboveTop = top < 0 const aboveTop = top < 0
const belowBottom = bottom > windowHeight.value const belowBottom = bottom > windowHeight.value
if (aboveTop || belowBottom || biggerThanScreen) { if (aboveTop || belowBottom || biggerThanScreen) {
element.scrollIntoView(options) await element.scrollIntoView(options)
}
} }
} }
await call(options) await element.scrollIntoViewIfNeeded(options)
inProgress.value = false inProgress.value = false
} }