* Determine the page size for the given tree based on an item in the tree. We * estimate this size by trying to see how many items will fit in the given * tree. If the tree is within a scroll container, we will use the height of * that container. Otherwise, we'll use the current window height
(root: Element, item: HTMLElement | null)
| 215 | * that container. Otherwise, we'll use the current window height |
| 216 | */ |
| 217 | function getPageSize(root: Element, item: HTMLElement | null) { |
| 218 | const scrollContainer = getScrollContainer(root) |
| 219 | const {height: itemHeight} = item?.getBoundingClientRect() ?? defaultSize |
| 220 | const availableHeight = scrollContainer?.clientHeight ?? window.innerHeight |
| 221 | return Math.floor(availableHeight / itemHeight) |
| 222 | } |
| 223 | |
| 224 | function getNextPageElement(element: HTMLElement): HTMLElement | undefined { |
| 225 | const root = element.closest('[role="tree"]') |
no test coverage detected