refactor(scroll): delegate note scroll to scrollIntoView
Native scrollIntoView reads the element position at scroll time and picks the right scrollable ancestor itself, sidestepping iOS Safari quirks with scrollTo on overflow containers and visual-viewport shifts.
This commit is contained in:
@@ -41,15 +41,8 @@ export const useOverlay = (listen = true) => {
|
||||
}
|
||||
|
||||
const scrollToElement = (element: HTMLElement) => {
|
||||
const mainApp = document.getElementById("main-app")
|
||||
if (!mainApp) return
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
const top =
|
||||
element.getBoundingClientRect().top -
|
||||
mainApp.getBoundingClientRect().top +
|
||||
mainApp.scrollTop
|
||||
mainApp.scrollTo({ top, behavior: "smooth" })
|
||||
element.scrollIntoView({ behavior: "smooth", block: "start" })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user