fix chromium
This commit is contained in:
parent
5aec392320
commit
e53222d632
1 changed files with 10 additions and 13 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue