Scroll to the top of a note if it is too long to fit the screen

This commit is contained in:
Bojan Mojsilovic 2024-01-10 14:05:07 +01:00
parent 925e927528
commit b0c2b394e0

View File

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