24 lines · 677 B · TypeScript
RawDownload
export const AUTO_SCROLL_BOTTOM_THRESHOLD_PX = 64; interface ScrollPosition {  scrollTop: number;  clientHeight: number;  scrollHeight: number;} export function isScrollContainerNearBottom(  position: ScrollPosition,  thresholdPx = AUTO_SCROLL_BOTTOM_THRESHOLD_PX,): boolean {  const threshold = Number.isFinite(thresholdPx)    ? Math.max(0, thresholdPx)    : AUTO_SCROLL_BOTTOM_THRESHOLD_PX;   const { scrollTop, clientHeight, scrollHeight } = position;  if (![scrollTop, clientHeight, scrollHeight].every(Number.isFinite)) {    return true;  }   const distanceFromBottom = scrollHeight - clientHeight - scrollTop;  return distanceFromBottom <= threshold;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t