fix(#1249): break sticky-bottom lock when user scrolls up during snap animation
This commit is contained in:
parent
0723737d89
commit
9f8694e3cf
2 changed files with 31 additions and 6 deletions
|
|
@ -158,12 +158,29 @@ export function create(opts) {
|
|||
pill.classList.add('visible');
|
||||
}
|
||||
log.addEventListener('scroll', () => {
|
||||
// Swallow scroll events during smooth-snap animations — see
|
||||
// docs/web-ui.md::Shared terminal pane (Mid-animation scroll-event
|
||||
// guard).
|
||||
if (Date.now() < smoothScrollingUntil) return;
|
||||
stickToBottom = isNearBottom();
|
||||
// Sticky-bottom intent tracking. Outside an animation this is
|
||||
// straightforward — stickToBottom = isNearBottom(). During a
|
||||
// smooth-snap animation we swallow most of the event to avoid a
|
||||
// feedback loop (programmatic scrollTop changes → scroll events →
|
||||
// new snap → cancels current rAF), but we MUST still let the user
|
||||
// break out of sticky mode: if the user scrolls away from the
|
||||
// bottom while a snap animation is in flight, honour that intent
|
||||
// immediately so the MutationObserver stops re-firing snapToBottom()
|
||||
// and the animation-guard window can expire naturally. Without this,
|
||||
// live events arriving < 220ms apart permanently block scroll-to-top
|
||||
// and loadMore() never fires. See docs/web-ui.md::Shared terminal
|
||||
// pane (Mid-animation scroll-event guard).
|
||||
const inAnim = Date.now() < smoothScrollingUntil;
|
||||
const nearBottom = isNearBottom();
|
||||
if (!inAnim) {
|
||||
stickToBottom = nearBottom;
|
||||
} else if (!nearBottom) {
|
||||
// User scrolled up during an animation — break sticky mode so the
|
||||
// MO stops calling snapToBottom() and the gate expires.
|
||||
stickToBottom = false;
|
||||
}
|
||||
if (stickToBottom) { unseen = 0; updatePill(); }
|
||||
if (inAnim) return;
|
||||
// Auto-fetch older history when the user scrolls near the top — no
|
||||
// click required; the load-more pill stays as a visual indicator.
|
||||
if (rootLog.scrollTop <= LOAD_MORE_SCROLL_PX && histHasMore && !histLoading) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue