ViewPager
A page-snapped horizontal content navigator for ReactLynx with optional off-screen lazy rendering.Info
You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.
Basic Usage
Render data-driven pages and track the current page through change events.
Examples
Auto Height
Let page content determine the pager's natural height without setting one explicitly.
Dynamic Height
Interpolate the pager height on the main thread as differently sized pages move.
Lazy Rendering
Lazy-render pages and navigate them through imperative controls.
Nested List
Combine horizontal paging with independently scrollable vertical lists.
Structure
Component API
ViewPager
bouncesiOSAndroid
Enable the native spring effect where supported.
childreniOSAndroid
Render page content. Selection state is intentionally not passed, so a
native swipe does not require React to rerender page content.
classNameiOSAndroidHarmony
className
dataiOSAndroid
Data rendered as pages. ViewPager creates one direct native
viewpager-item child for every entry.
enableScrolliOSAndroid
Enable horizontal swipe gestures.
getItemKeyiOSAndroid
Return a stable, unique key for an entry. When omitted, the item index is
used. Provide this function when items can be inserted, removed, or reordered.
getItemPropsiOSAndroid
Native props for an individual generated item. Its class name is added to
itemClassName; its style overrides matching itemStyle properties. The
item's key, ref, and children are managed by ViewPager.
idiOSAndroid
Identifier applied to the native ViewPager root.
initialSelectIndexiOSAndroid
Initial page index. Later changes are ignored; use ref.scrollToPage to navigate.
itemClassNameiOSAndroid
Class name applied to every generated viewpager-item.
itemStyleiOSAndroid
Style applied to every generated viewpager-item.
lazyOptionsiOSAndroid
Exposure-driven lazy rendering. The initial page renders immediately;
other pages render when their placeholders enter the configured exposure
area. Rendered pages stay mounted. Omit this prop to render every page.
main-thread:onOffsetChangeiOSAndroid
Main-thread scroll progress handler. Use a main thread function.
main-thread:onPageChangeiOSAndroid
Main-thread page completion handler. Use a main thread function.
main-thread:onPageWillChangeiOSAndroid
Main-thread page transition handler. Use a main thread function.
onOffsetChangeiOSAndroid
Native scroll progress event. Read its data from event.detail.
onPageChangeiOSAndroid
Native page completion event. Read the selected index from event.detail.index.
onPageWillChangeiOSAndroid
Native event before a page transition completes. Read its data from event.detail.
styleiOSAndroidHarmony
style
viewpagerPropsiOSAndroid
Native pager attributes not managed by the component.
ViewPagerRef
scrollToPageiOSAndroid
Slide to a page through the native node ref. Animation defaults to true.
Indexes are clamped to available pages. Empty pagers ignore requests.
Completion is reported through onPageChange; success confirms invocation.
Supporting Types
ViewPagerItemProps
ViewPagerItemProps
ViewPagerExposureMargin
ViewPagerExposureMargin
ViewPagerLazyOptions
ViewPagerLazyOptions
Disable lazy rendering.
ViewPagerChangeEvent
ViewPagerChangeEvent
ViewPagerWillChangeEvent
ViewPagerWillChangeEvent
ViewPagerOffsetChangeEvent
ViewPagerOffsetChangeEvent