Skip to content

Commit

Permalink
Update Pager docs for offscreenLimit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes authored and jossiwolf committed Aug 1, 2021
1 parent 8b20d7b commit c29cc24
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/pager.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ Pages in both [`HorizontalPager`][api-horizpager] and [`VerticalPager`][api-vert

### Offscreen Limit

Both [`HorizontalPager`][api-horizpager] & [`VerticalPager`][api-vertpager] allow the setting of the `offscreenLimit`, which defines the number of pages that should be retained on either side of the current page. Pages beyond this limit will be removed, and then recreated when needed. This value defaults to `1`, but can be increased to enable pre-loading of more content:
The [PagerState][pagerstate-api] API allows the setting of the `offscreenLimit`, which defines the number of pages that should be retained on either side of the current page. Pages beyond this limit will be removed, and then recreated as needed. This value defaults to `1`, but can be increased to enable pre-loading of more content:

```kotlin
HorizontalPager(
state = pagerState,
val pagerState = rememberPagerState(
pageCount = 10,
offscreenLimit = 2,
) { page ->
)

HorizontalPager(state = pagerState) { page ->
// ...
}
```
Expand Down Expand Up @@ -249,4 +251,5 @@ limitations under the License.
[api-horizpager]: ../api/pager/pager/com.google.accompanist.pager/-horizontal-pager.html
[currentpage-api]: ../api/pager/pager/com.google.accompanist.pager/-pager-state/current-page.html
[currentpageoffset-api]: ../api/pager/pager/com.google.accompanist.pager/-pager-state/current-page-offset.html
[calcoffsetpage]: ../api/pager/pager/com.google.accompanist.pager/calculate-current-offset-for-page.html)
[calcoffsetpage]: ../api/pager/pager/com.google.accompanist.pager/calculate-current-offset-for-page.html
[pagerstate-api]: ../api/pager/pager/com.google.accompanist.pager/remember-pager-state.html

0 comments on commit c29cc24

Please sign in to comment.