Skip to content

Commit

Permalink
feat(android): add offscreenPageLimit property for view pager
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Nov 4, 2024
1 parent 0ce4d47 commit 78e5fe0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/hippy-react/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ import icon from './qb_icon_new.png';
| ------------------------ | ------------------------------------------------------------ | -------------------------------------------- | -------- |
| bounces | 是否开启回弹效果,默认 `true` | `boolean` | `iOS、Voltron` |
| initialPage | 指定一个数字,用于决定初始化后默认显示的页面 index,默认不指定的时候是0 | `number` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| offscreenPageLimit | 指定一个数字,用于设置最大挂载到view tree的page item数量,默认为1,如果在间隔较大的item之间切换遇到一些刷新闪动问题,可以尝试设置该属性为最大page item count来解决 | `number` | `Android` |
| scrollEnabled | 指定 ViewPager 是否可以滑动,默认为 `true` | `boolean` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onPageSelected | 指定一个函数,当 page 被选中时进行回调。回调参数是一个 event 对象,回调参数: `position: number` - 表示即将滑到的目标 page 的索引 | `(obj: {position: number}) => void` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onPageScroll | 指定一个函数,当 page 被滑动时进行回调。回调参数是一个 event 对象,回调参数 `position: number` - 表示即将滑到的目标 page 的索引,`offset: number` - 当前被选中的 page 的相对位移,取值范围 -1 到 1 | `(obj: {position: number, offset: number}) => void` | `Android、iOS、Web-Renderer、Voltron` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void setOverflow(HippyViewPager pager, String overflow) {
pager.setOverflow(overflow);
}

@HippyControllerProps(name = "offscreenPageLimit", defaultNumber = 0, defaultType = HippyControllerProps.NUMBER)
public void setOffscreenPageLimit(HippyViewPager parent, int limit) {
parent.setOffscreenPageLimit(limit);
}

private void resolveInvalidParams(@Nullable Promise promise) {
if (promise != null) {
String msg = "Invalid parameter!";
Expand Down

0 comments on commit 78e5fe0

Please sign in to comment.