FIG-001/ HISTORY

history loading.

Scroll up to trigger older message loading while the viewport preserves its visible anchor as messages are prepended above.

  • Scroll near the top and onNeedHistory fires, so you can fetch an older batch and prepend it to the messages array — the chat starts with the most recent messages loaded.
  • As older messages are prepended above, the viewport preserves its visible anchor — the message you were reading stays exactly where it was, with no jump.
  • Anchor preservation compensates for the height of the inserted batch, so scrollTop is corrected in the same frame the messages land.
  • Keep scrolling up to page through the full backlog. The scroll-away state means loading history never yanks you back to the bottom.
↩ all examples
mode · prepend · anchored mode · live running source
file · HistoryLoading.svelte messages 21 oldest #80 loads 0 · scroll up to load more
you 07:12 AM #80
User message #80. Scroll up to load more history.
category · history
sheet · sheet 01 / 01
⟳ to re-run

History Loading