Skip to content

Commit

Permalink
docs: extend scrollMargin description (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wordllban authored Oct 28, 2024
1 parent c13a6a1 commit 907ae66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/api/virtualizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ This optional function is called when the virtualizer needs to dynamically measu
scrollMargin?: number
```

With this option, you can specify where the scroll offset should originate. Typically, this value represents the space between the beginning of the scrolling element and the start of the list. This is especially useful in common scenarios such as when you have a header preceding a window virtualizer or when multiple virtualizers are utilized within a single scrolling element.
With this option, you can specify where the scroll offset should originate. Typically, this value represents the space between the beginning of the scrolling element and the start of the list. This is especially useful in common scenarios such as when you have a header preceding a window virtualizer or when multiple virtualizers are utilized within a single scrolling element. If you are using absolute positioning of elements, you should take into account the `scrollMargin` in your CSS transform:
```tsx
transform: `translateY(${
virtualRow.start - rowVirtualizer.options.scrollMargin
}px)`
```
To dynamically measure value for `scrollMargin` you can use `getBoundingClientRect()` or ResizeObserver. This is helpful in scenarios when items above your virtual list might change their height.

### `gap`

Expand Down

0 comments on commit 907ae66

Please sign in to comment.