From 5a9a062b64d0cf2852f5d5641d5cb408de094847 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Mon, 15 Jan 2024 13:49:41 +0100 Subject: [PATCH] Fix thread scroll-to-position on iPhone --- src/pages/Thread.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/Thread.tsx b/src/pages/Thread.tsx index 7cfdefa..77890fa 100644 --- a/src/pages/Thread.tsx +++ b/src/pages/Thread.tsx @@ -115,14 +115,21 @@ const Thread: Component = () => { if (!pn) return; setTimeout(() => { + const threadHeader = 72; + const iOSBanner = 54; + const rect = pn.getBoundingClientRect(); - const wh = window.innerHeight - 72; + const wh = window.innerHeight - threadHeader; const block = rect.height < wh && parentNotes().length > 0 ? 'end' : 'start'; pn.scrollIntoView({ block }); - block === 'start' && window.scrollBy({ top: -72 }); + + if (block === 'start') { + const moreScroll = threadHeader + (isIOS() ? iOSBanner : 0); + window.scrollBy({ top: -moreScroll }); + } }, 100); });