diff options
Diffstat (limited to 'src/features/messages.js')
| -rw-r--r-- | src/features/messages.js | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 6b3ff4c..72707a5 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -5445,7 +5445,7 @@ export function messagesFeature(ctx) { } // How far back you've scrolled: while the feed (or a profile's posts) // moves, a small chip under the top bar says when the post at the top of - // the screen was written, and fades a moment after the scrolling stops + // the screen was written, and goes the moment the scrolling stops // ("some sort of little counter that shows the date and time of posts // where I'm in the timeline", Adam, 2026-11-17). Painted straight into the // DOM, outside render(): it changes every frame of a fling. @@ -5476,13 +5476,22 @@ export function messagesFeature(ctx) { const head = document.querySelector('.brand-header'); const top = head ? Math.max(0, head.getBoundingClientRect().bottom) : 0; // the post at the top of the screen, below the bar - let key = null, box = null; - for (const r of rows) { - const b = r.getBoundingClientRect(); - if (b.bottom > top + 12) { key = r.getAttribute('data-key'); box = r.parentElement.getBoundingClientRect(); break; } + let key = null, box = null, frac = 0, nextKey = null; + for (let i = 0; i < rows.length; i++) { + const b = rows[i].getBoundingClientRect(); + if (b.bottom <= top + 12) continue; + key = rows[i].getAttribute('data-key'); + box = rows[i].parentElement.getBoundingClientRect(); + // how far through this post the top of the screen is, to blend its + // time toward the next post's: the clock rolls with the scroll + // instead of jumping post to post ("I'm good with blending", Adam) + frac = b.height > 0 ? Math.min(1, Math.max(0, (top + 12 - b.top) / b.height)) : 0; + nextKey = rows[i + 1]?.getAttribute('data-key'); + break; } if (whenIdx.list !== list) whenIdx = { list, map: list ? new Map(list.map((e) => [e.id, e])) : null }; const ev = key && whenIdx.map?.get(key); + const next = nextKey && whenIdx.map?.get(nextKey); // only once you're past the first screenful: at the top the posts' own times say it if (!ev || (window.scrollY || 0) < window.innerHeight * 0.75) { if (whenEl) whenEl.classList.remove('on'); return; } if (!whenEl) { @@ -5491,13 +5500,16 @@ export function messagesFeature(ctx) { whenEl.setAttribute('aria-hidden', 'true'); document.body.appendChild(whenEl); } - const label = whenLabel(ev.created_at); + const label = whenLabel(next ? ev.created_at + (next.created_at - ev.created_at) * frac : ev.created_at); if (whenEl.textContent !== label) whenEl.textContent = label; whenEl.style.top = (top + 8) + 'px'; whenEl.style.left = (box.left + box.width / 2) + 'px'; whenEl.classList.add('on'); clearTimeout(whenHide); - whenHide = setTimeout(() => whenEl && whenEl.classList.remove('on'), 1200); + // gone as soon as you stop to read ("I want it gone as soon as I'm + // stopped to look at something", Adam): a coast keeps sending scroll + // events, so this only fires once the page is still + whenHide = setTimeout(() => whenEl && whenEl.classList.remove('on'), 250); }); } async function loadOlderNotes(pk) { |
