From c29cc24d7ed4fcaf3721a02025c7debf8cf7fe93 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Sun, 9 May 2021 10:27:39 +0100 Subject: [PATCH] Update Pager docs for offscreenLimit changes Fixes #397 --- docs/pager.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/pager.md b/docs/pager.md index 62234bf79..c235ef995 100644 --- a/docs/pager.md +++ b/docs/pager.md @@ -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 -> // ... } ``` @@ -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) \ No newline at end of file + [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 \ No newline at end of file