@agentman/chat-widget
Version:
Agentman Chat Widget for easy integration with web applications
78 lines (77 loc) • 1.91 kB
TypeScript
/**
* ScrollManager - Intelligent scroll behavior for chat messages
*
* Handles:
* - Auto-scroll when user is at bottom
* - Preserve scroll position when user is reading
* - Show "new content" indicator when not auto-scrolling
* - Smooth vs instant scroll options
*/
export interface ScrollConfig {
threshold?: number;
smoothScroll?: boolean;
debug?: boolean;
}
export declare class ScrollManager {
private container;
private isUserScrolling;
private lastScrollTop;
private scrollEndTimer;
private newContentIndicator;
private logger;
private config;
constructor(config?: ScrollConfig);
/**
* Initialize scroll manager with container
*/
init(container: HTMLElement): void;
/**
* Clean up listeners and resources
*/
destroy(): void;
/**
* Check if user is at the bottom of the scroll container
*/
isAtBottom(): boolean;
/**
* Check if user is actively scrolling
*/
isScrolling(): boolean;
/**
* Scroll to bottom if appropriate
* @param force - Force scroll even if user is reading
*/
scrollToBottom(force?: boolean): void;
/**
* Handle new content during streaming
*/
handleStreamingUpdate(): void;
/**
* Attach scroll event listeners
*/
private attachListeners;
/**
* Handle scroll events
*/
private handleScroll;
/**
* Handle wheel events (user scrolling with mouse)
*/
private handleWheel;
/**
* Handle touch start (user scrolling on mobile)
*/
private handleTouchStart;
/**
* Show indicator that new content is available
*/
private showNewContentIndicator;
/**
* Hide the new content indicator
*/
private hideNewContentIndicator;
/**
* Reset scroll state (e.g., when switching conversations)
*/
reset(): void;
}