fix(scroll): snap to click-time scrollTop before smooth scroll
Capture mainApp.scrollTop synchronously when addStackedNote runs and snap the scroll back to that value before scrollIntoView fires, so the smooth scroll begins from where the user actually tapped rather than from a position drifted by momentum or async work.
This commit is contained in:
@@ -114,6 +114,10 @@ export const useRouteQueryStackedNotes = () => {
|
||||
selector?: string,
|
||||
hash?: string
|
||||
) => {
|
||||
const mainAppEl = document.getElementById("main-app")
|
||||
;(window as unknown as { __scrollAtClick?: number }).__scrollAtClick =
|
||||
mainAppEl?.scrollTop ?? 0
|
||||
|
||||
if (stackedNotes.value.includes(sha)) {
|
||||
scrollToFocusedNote({
|
||||
noteId: selector ?? sha,
|
||||
|
||||
Reference in New Issue
Block a user