( visibleRect: Rect, contentSize: Size, edge: ScrollAnchorEdge, axis: ScrollAnchorAxis, threshold: number )
| 125 | * Virtualizer to compute wasNearAnchorEdge generically, without any layout-specific state. |
| 126 | */ |
| 127 | export function isNearEdge( |
| 128 | visibleRect: Rect, |
| 129 | contentSize: Size, |
| 130 | edge: ScrollAnchorEdge, |
| 131 | axis: ScrollAnchorAxis, |
| 132 | threshold: number |
| 133 | ): boolean { |
| 134 | if (edge === 'start') { |
| 135 | return visibleRect[axis] <= threshold; |
| 136 | } |
| 137 | let dimension = dimensionForAxis(axis); |
| 138 | let distanceFromEnd = contentSize[dimension] - (visibleRect[axis] + visibleRect[dimension]); |
| 139 | return distanceFromEnd <= threshold; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Works out the new scroll position after content changes. Tries to keep the anchor |
no test coverage detected