Fix thread scroll-to-position on iPhone

This commit is contained in:
Bojan Mojsilovic 2024-01-15 13:49:41 +01:00
parent 44cfa8f469
commit 5a9a062b64

View File

@ -115,14 +115,21 @@ const Thread: Component = () => {
if (!pn) return; if (!pn) return;
setTimeout(() => { setTimeout(() => {
const threadHeader = 72;
const iOSBanner = 54;
const rect = pn.getBoundingClientRect(); const rect = pn.getBoundingClientRect();
const wh = window.innerHeight - 72; const wh = window.innerHeight - threadHeader;
const block = rect.height < wh && parentNotes().length > 0 ? const block = rect.height < wh && parentNotes().length > 0 ?
'end' : 'start'; 'end' : 'start';
pn.scrollIntoView({ block }); pn.scrollIntoView({ block });
block === 'start' && window.scrollBy({ top: -72 });
if (block === 'start') {
const moreScroll = threadHeader + (isIOS() ? iOSBanner : 0);
window.scrollBy({ top: -moreScroll });
}
}, 100); }, 100);
}); });