diff --git a/src/App.vue b/src/App.vue index 30b9626..9d7363a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,6 @@ const { isATProtoReady } = useATProtoLogin() -

 
 
 
diff --git a/src/hooks/useOverlay.hook.ts b/src/hooks/useOverlay.hook.ts
index df2be63..84132d1 100644
--- a/src/hooks/useOverlay.hook.ts
+++ b/src/hooks/useOverlay.hook.ts
@@ -40,42 +40,14 @@ export const useOverlay = (listen = true) => {
     }, 80)
   }
 
-  const scrollToElement = (element: HTMLElement) => {
+  const scrollToElement = (element: HTMLElement, anchorTop?: number) => {
     const mainApp = document.getElementById("main-app")
-    const clickTop = (window as unknown as { __scrollAtClick?: number })
-      .__scrollAtClick
-
-    if (mainApp && clickTop !== undefined) {
-      mainApp.scrollTop = clickTop
+    if (mainApp && anchorTop !== undefined) {
+      mainApp.scrollTop = anchorTop
     }
 
     requestAnimationFrame(() => {
-      const debug = document.getElementById("scroll-debug")
-      if (debug && mainApp) {
-        const er = element.getBoundingClientRect()
-        const cr = mainApp.getBoundingClientRect()
-        const lines = [
-          `clickTop: ${clickTop ?? "n/a"}`,
-          `before scrollTop: ${mainApp.scrollTop}`,
-          `mainApp scrollH: ${mainApp.scrollHeight} clientH: ${mainApp.clientHeight}`,
-          `body scrollY: ${window.scrollY} innerH: ${window.innerHeight}`,
-          `el.rect.top: ${er.top.toFixed(1)}`,
-          `mainApp.rect.top: ${cr.top.toFixed(1)}`,
-          `target: ${(er.top - cr.top + mainApp.scrollTop).toFixed(1)}`
-        ]
-        debug.textContent = lines.join("\n")
-
-        element.scrollIntoView({ behavior: "smooth", block: "start" })
-
-        requestAnimationFrame(() => {
-          debug.textContent += `\nafter1f scrollTop: ${mainApp.scrollTop}`
-          setTimeout(() => {
-            debug.textContent += `\nafter500ms scrollTop: ${mainApp.scrollTop}`
-          }, 500)
-        })
-      } else {
-        element.scrollIntoView({ behavior: "smooth", block: "start" })
-      }
+      element.scrollIntoView({ behavior: "smooth", block: "start" })
     })
   }
 
diff --git a/src/hooks/useRouteQueryStackedNotes.hook.ts b/src/hooks/useRouteQueryStackedNotes.hook.ts
index 86deb7a..c79cb95 100644
--- a/src/hooks/useRouteQueryStackedNotes.hook.ts
+++ b/src/hooks/useRouteQueryStackedNotes.hook.ts
@@ -50,6 +50,7 @@ export const useRouteQueryStackedNotes = () => {
   const scrollToNoteElement = (
     cleanNoteId: string,
     index: number,
+    anchorTop?: number,
     attempts = 30
   ) => {
     const element = document.querySelector(
@@ -57,7 +58,7 @@ export const useRouteQueryStackedNotes = () => {
     ) as HTMLElement | null
 
     if (element) {
-      scrollToElement(element)
+      scrollToElement(element, anchorTop)
       return
     }
 
@@ -67,7 +68,7 @@ export const useRouteQueryStackedNotes = () => {
     }
 
     requestAnimationFrame(() => {
-      scrollToNoteElement(cleanNoteId, index, attempts - 1)
+      scrollToNoteElement(cleanNoteId, index, anchorTop, attempts - 1)
     })
   }
 
@@ -76,20 +77,22 @@ export const useRouteQueryStackedNotes = () => {
     notes?: string[]
     hash?: string
     smoothHash?: boolean
+    anchorTop?: number
   }
 
   const scrollToFocusedNote = ({
     noteId = null,
     notes = stackedNotes.value,
     hash,
-    smoothHash = false
+    smoothHash = false,
+    anchorTop
   }: ScrollToFocusedNoteOptions = {}) => {
     nextTick(() => {
       const index = noteId ? notes.findIndex((nid) => nid === noteId) : 0
 
       if (isMobile.value) {
         if (noteId) {
-          scrollToNoteElement(noteId.replaceAll(":", "-"), index)
+          scrollToNoteElement(noteId.replaceAll(":", "-"), index, anchorTop)
         } else {
           scrollToNote(0)
         }
@@ -114,15 +117,15 @@ export const useRouteQueryStackedNotes = () => {
     selector?: string,
     hash?: string
   ) => {
-    const mainAppEl = document.getElementById("main-app")
-    ;(window as unknown as { __scrollAtClick?: number }).__scrollAtClick =
-      mainAppEl?.scrollTop ?? 0
+    const anchorTop =
+      document.getElementById("main-app")?.scrollTop ?? undefined
 
     if (stackedNotes.value.includes(sha)) {
       scrollToFocusedNote({
         noteId: selector ?? sha,
         hash,
-        smoothHash: true
+        smoothHash: true,
+        anchorTop
       })
       return
     }
@@ -143,7 +146,7 @@ export const useRouteQueryStackedNotes = () => {
       stackedNotes.value = newStackedNotes
     }
 
-    scrollToFocusedNote({ noteId: selector ?? sha, hash })
+    scrollToFocusedNote({ noteId: selector ?? sha, hash, anchorTop })
   }
 
   return {