| 43 | } |
| 44 | |
| 45 | async function getRowCenter(page: Page, index: number, isWindow: boolean) { |
| 46 | return page.evaluate( |
| 47 | ({ index, isWindow }) => { |
| 48 | const row = document.querySelector(`tr[data-index="${index}"]`); |
| 49 | if (!row) return null; |
| 50 | const rect = row.getBoundingClientRect(); |
| 51 | const scroller = document.querySelector('[data-testid="scroller"]'); |
| 52 | const viewTop = isWindow ? 0 : scroller!.getBoundingClientRect().top; |
| 53 | const viewHeight = isWindow |
| 54 | ? document.documentElement.clientHeight |
| 55 | : scroller!.clientHeight; |
| 56 | return (rect.top + rect.bottom) / 2 - viewTop - viewHeight / 2; |
| 57 | }, |
| 58 | { index, isWindow } |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | for (const isWindow of [false, true]) { |
| 63 | for (const isDynamic of [false, true]) { |