diff options
Diffstat (limited to 'src/features/smart-scroll/ui')
| -rw-r--r-- | src/features/smart-scroll/ui/controller.svelte.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/features/smart-scroll/ui/controller.svelte.ts b/src/features/smart-scroll/ui/controller.svelte.ts index 99d53ca..dbe65d1 100644 --- a/src/features/smart-scroll/ui/controller.svelte.ts +++ b/src/features/smart-scroll/ui/controller.svelte.ts @@ -22,6 +22,12 @@ export interface SmartScrollController { /** Reactive: show the "scroll to bottom" affordance (the user has scrolled up). */ readonly showButton: boolean; /** + * Non-reactive point-in-time query: is the view stuck to the bottom right now? + * For imperative callers (e.g. the chat-limit unload gate) that poll at event + * time rather than subscribing — reads the reducer state, not a rune. + */ + isAtBottom(): boolean; + /** * Attach to the scroll container; returns a teardown to call on unmount. * Pass the inner CONTENT element to also follow height changes that aren't a * transcript update (async markdown/highlight, image loads, a collapse toggling, @@ -84,6 +90,10 @@ export function createSmartScrollController(): SmartScrollController { return showButton; }, + isAtBottom(): boolean { + return state.stuck; + }, + attach(node: HTMLElement, content?: HTMLElement): () => void { el = node; node.addEventListener("scroll", handleScroll, { passive: true }); |
