{"_id":"@brandingbrand/react-native-pager-view","_rev":"11-31ea5ecde658f663e83044c5957d4388","name":"@brandingbrand/react-native-pager-view","dist-tags":{"latest":"6.2.2"},"versions":{"6.2.2":{"name":"@brandingbrand/react-native-pager-view","version":"6.2.2","keywords":["react-native","ios","android"],"author":{"url":"https://github.com/callstack","name":"troZee","email":"hello@callstack.com"},"license":"MIT","_id":"@brandingbrand/react-native-pager-view@6.2.2","maintainers":[{"name":"bbtravisreadonly","email":"travis@brandingbrand.com"},{"name":"tom_thornton","email":"thomas.thornton@brandingbrand.com"},{"name":"philtompkins","email":"philip.tompkins@brandingbrand.com"},{"name":"nathan-sankbeil","email":"nathan.sankbeil@brandingbrand.com"},{"name":"chrisjlan89branding","email":"chris.lantier@brandingbrand.com"},{"name":"branderbrett","email":"brett@brandingbrand.com"},{"name":"skyeckstrom","email":"npm@skyeckstrom.com"},{"name":"nickburkhartbb","email":"nick.burkhart@brandingbrand.com"},{"name":"bbtravis","email":"travis+bbtravis@brandingbrand.com"},{"name":"deemaabdallah","email":"deema.abdallah@brandingbrand.com"},{"name":"msiauko","email":"mikhail@brandingbrand.com"},{"name":"jasonmosleybb","email":"jason.mosley@brandingbrand.com"},{"name":"dshadrick","email":"dan.shadrick@brandingbrand.com"},{"name":"nickbb","email":"nick@brandingbrand.com"},{"name":"notajvento","email":"aj@brandingbrand.com"},{"name":"andyschwob","email":"andy.schwob@brandingbrand.com"},{"name":"xero","email":"andrew.harrison@brandingbrand.com"},{"name":"varzamanbb","email":"stefan.neamtu@brandingbrand.com"},{"name":"bb_jenkins","email":"ops@brandingbrand.com"},{"name":"crherman7","email":"crherman7@gmail.com"},{"name":"wsedlacekc","email":"william.sedlacek@icloud.com"},{"name":"ckornell","email":"ckornell@gmail.com"},{"name":"jmwr","email":"johnmichael.w.riley@gmail.com"},{"name":"mjweb48","email":"michael.webster@brandingbrand.com"},{"name":"winescout","email":"matt.clark@brandingbrand.com"}],"homepage":"https://github.com/callstack/react-native-pager-view#readme","bugs":{"url":"https://github.com/callstack/react-native-pager-view/issues"},"dist":{"shasum":"79763ce7f6d396626041c0ddc237f3310ad40b4c","tarball":"https://registry.npmjs.org/@brandingbrand/react-native-pager-view/-/react-native-pager-view-6.2.2.tgz","fileCount":61,"integrity":"sha512-HhcYDzrWC53y/+MisfSSXrr7ogZKhzJYEffnEim9q7xuPdLWiqkyf49RhNfhwQlkswXQCwgBjqeBm8OfYnwQ8w==","signatures":[{"sig":"MEUCIQD08ypznywBAlyIwWot+h2ux4NH3egT7pAZvkHLqaTZWQIgM0MQv0ZROA1CStEviZG9pMHqsOjb4rsqnH7bDOz1Cos=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":180069},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"main":"lib/commonjs/index","types":"lib/typescript/index.d.ts","module":"lib/module/index","source":"src/index","gitHead":"2afe46c421ca112ad3ec47a63e145a4a4ad17926","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"jest","example":"yarn --cwd example","prepare":"bob build","release":"release-it","bootstrap":"yarn example && yarn && yarn example pods","typescript":"tsc --noEmit","releaseNext":"release-it --npm.tag=newarch --preRelease=rc","test:e2e:ios":"bash ./scripts/run-maestro-tests.sh ios","run-example-ios":"cd example;react-native run-ios --configuration Release --simulator \"iPhone 13 (15.2)\"","bootstrap-fabric":"yarn example && yarn && yarn example pods-fabric","test:e2e:android":"bash ./scripts/run-maestro-tests.sh android","bootstrap-no-pods":"yarn example && yarn","run-example-android":"cd example;react-native run-android --variant=release"},"_npmUser":{"name":"branderbrett","email":"brett@brandingbrand.com"},"prettier":{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/callstack/react-native-pager-view.git","type":"git"},"_npmVersion":"9.6.2","description":"React Native wrapper for Android and iOS ViewPager","directories":{},"resolutions":{"@types/react":"18.0.29"},"_nodeVersion":"16.13.1","eslintConfig":{"root":true,"rules":{"prettier/prettier":["error",{"useTabs":false,"tabWidth":2,"quoteProps":"consistent","singleQuote":true,"trailingComma":"es5"}]},"parser":"@babel/eslint-parser","extends":["@react-native-community","prettier"]},"eslintIgnore":["node_modules/","lib/"],"react-native":"src/index","codegenConfig":{"name":"RNCViewPager","type":"components","jsSrcsDir":"src"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^28.1.1","react":"18.1.0","eslint":"^8.4.1","prettier":"^2.0.5","release-it":"^14.2.2","typescript":"^4.5.2","@types/jest":"^28.1.2","pod-install":"^0.1.0","@types/react":"18.0.29","react-native":"0.70.0","@types/react-native":"0.70.0","@babel/eslint-parser":"^7.18.2","@tsconfig/react-native":"^3.0.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","react-native-builder-bob":"^0.18.3","@react-native/metro-config":"^0.72.11","@react-native/eslint-config":"^0.72.2","metro-react-native-babel-preset":"0.76.8","@release-it/conventional-changelog":"^2.0.0","@react-native-community/eslint-config":"^3.0.2"},"peerDependencies":{"react":"*","react-native":"*"},"_npmOperationalInternal":{"tmp":"tmp/react-native-pager-view_6.2.2_1698352264545_0.9725405682359995","host":"s3://npm-registry-packages"},"react-native-builder-bob":{"output":"lib","source":"src","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]}}},"time":{"created":"2023-10-26T20:31:04.543Z","modified":"2026-03-13T16:20:30.448Z","6.2.2":"2023-10-26T20:31:04.757Z"},"bugs":{"url":"https://github.com/callstack/react-native-pager-view/issues"},"author":{"url":"https://github.com/callstack","name":"troZee","email":"hello@callstack.com"},"license":"MIT","homepage":"https://github.com/callstack/react-native-pager-view#readme","keywords":["react-native","ios","android"],"repository":{"url":"git+https://github.com/callstack/react-native-pager-view.git","type":"git"},"description":"React Native wrapper for Android and iOS ViewPager","maintainers":[{"email":"nathan.sankbeil@brandingbrand.com","name":"nathan-sankbeil"},{"email":"nick.burkhart@brandingbrand.com","name":"nickburkhartbb"},{"email":"travis+bbtravis@brandingbrand.com","name":"bbtravis"},{"email":"deema.abdallah@brandingbrand.com","name":"deemaabdallah"},{"email":"mikhail@brandingbrand.com","name":"msiauko"},{"email":"jason.mosley@brandingbrand.com","name":"jasonmosleybb"},{"email":"nick@brandingbrand.com","name":"nickbb"},{"email":"aj@brandingbrand.com","name":"notajvento"},{"email":"andrew.harrison@brandingbrand.com","name":"xero"},{"email":"stefan.neamtu@brandingbrand.com","name":"varzamanbb"},{"email":"ops@brandingbrand.com","name":"bb_jenkins"},{"email":"crherman7@gmail.com","name":"crherman7"},{"email":"johnmichael.w.riley@gmail.com","name":"jmwr"},{"email":"travis@brandingbrand.com","name":"bbtravisreadonly"}],"readme":"# react-native-pager-view <img src=\"img/viewpager-logo.png\" alt=\"ViewPager\" width=\"24\" height=\"24\">\n\n[![npm package](https://badge.fury.io/js/react-native-pager-view.svg)](https://badge.fury.io/js/react-native-pager-view)\n[![Lean Core Extracted](https://img.shields.io/badge/Lean%20Core-Extracted-brightgreen.svg)](https://github.com/facebook/react-native/issues/23313)\n[![License](https://img.shields.io/github/license/callstack/react-native-pager-view?color=blue)](https://github.com/callstack/react-native-pager-view/blob/master/LICENSE)\n\n[![Lint](https://github.com/callstack/react-native-pager-view/actions/workflows/main.yml/badge.svg)](https://github.com/callstack/react-native-pager-view/actions/workflows/main.yml)\n[![iOS Build](https://github.com/callstack/react-native-pager-view/actions/workflows/ios.yml/badge.svg)](https://github.com/callstack/react-native-pager-view/actions/workflows/ios.yml)\n[![Android Build](https://github.com/callstack/react-native-pager-view/actions/workflows/android.yml/badge.svg)](https://github.com/callstack/react-native-pager-view/actions/workflows/android.yml)\n\nThis component allows the user to swipe left and right through pages of data. Under the hood it is using the native [Android ViewPager](https://developer.android.com/reference/android/support/v4/view/ViewPager) and the [iOS UIPageViewController](https://developer.apple.com/documentation/uikit/uipageviewcontroller) implementations. [See it in action!](https://github.com/callstack/react-native-pager-view#preview)\n\n<br/>\n<p align=\"center\">\n  <img src=\"img/vp-carousel.gif\" alt=\"ViewPager\" width=\"300\">\n</p>\n\n<br/>\n\n## Versions\n\n| 4.x        | 5.x and above |\n| ---------- | ------------- |\n| iOS        | iOS support   |\n| ViewPager1 | ViewPager2    |\n\n## Migration\n\nIn version **6.x** support for `transitionStyle` property has been dropped. More information [here](https://github.com/callstack/react-native-pager-view/blob/master/MIGRATION.md).\n\n`\"@react-native-community/viewpager\"` library has been changed to `react-native-pager-view`. Here you can find more information, how to migrate pager view to the latest [version](https://github.com/callstack/react-native-pager-view/blob/master/MIGRATION.md)\n\n## Getting started\n\n`yarn add react-native-pager-view`\n\n## Linking\n\n### >= 0.60\n\nAutolinking will just do the job.\n\n### < 0.60\n\n#### Mostly automatic\n\n`react-native link react-native-pager-view`\n\n#### Manual linking\n\n<details>\n<summary>Manually link the library on iOS</summary>\n</br>\n\nFollow the [instructions in the React Native documentation](https://facebook.github.io/react-native/img/linking-libraries-ios#manual-linking) to manually link the framework or link using [Cocoapods](https://cocoapods.org) by adding this to your `Podfile`:\n\n```ruby\npod 'react-native-pager-view', :path => '../node_modules/react-native-pager-view'\n```\n\n</details>\n\n<details>\n<summary>Manually link the library on Android</summary>\n</br>\nMake the following changes:\n\n#### `android/settings.gradle`\n\n```groovy\ninclude ':react-native-pager-view'\nproject(':react-native-pager-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pager-view/android')\n```\n\n#### `android/app/build.gradle`\n\n```groovy\ndependencies {\n   ...\n   implementation project(':react-native-pager-view')\n}\n```\n\n#### `android/app/src/main/.../MainApplication.java`\n\nOn top, where imports are:\n\nAdd `import com.reactnativepagerview.PagerViewPackage;`\n\nAdd the `PagerViewPackage` class to your list of exported packages.\n\n```java\n@Override\nprotected List<ReactPackage> getPackages() {\n  return Arrays.<ReactPackage>asList(\n    new MainReactPackage(),\n    new PagerViewPackage()\n  );\n}\n```\n\n</details>\n\n## Usage\n\n```js\nimport React from 'react';\nimport { StyleSheet, View, Text } from 'react-native';\nimport PagerView from 'react-native-pager-view';\n\nconst MyPager = () => {\n  return (\n    <PagerView style={styles.pagerView} initialPage={0}>\n      <View key=\"1\">\n        <Text>First page</Text>\n      </View>\n      <View key=\"2\">\n        <Text>Second page</Text>\n      </View>\n    </PagerView>\n  );\n};\n\nconst styles = StyleSheet.create({\n  pagerView: {\n    flex: 1,\n  },\n});\n```\n\n**Attention:** Note that you can only use `View` components as children of `PagerView` (cf. folder _/example_)\n. For Android if `View` has own children, set prop `collapsable` to false <https://reactnative.dev/docs/view#collapsable-android>, otherwise react-native might remove those children views and and its children will be rendered as separate pages\n\n## Advanced usage\n\nFor advanced usage please take a look into our [example project](https://github.com/callstack/react-native-pager-view/blob/master/example/src/BasicPagerViewExample.tsx)\n\n## API\n\n| Prop                                                                 |                                                                                                                             Description                                                                                                                             | Platform |\n| -------------------------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------: |\n| `initialPage`                                                        |                                                                                                            Index of initial page that should be selected                                                                                                            |   both   |\n| `scrollEnabled: boolean`                                             |                                                                                                            Should pager view scroll, when scroll enabled                                                                                                            |   both   |\n| `onPageScroll: (e: PageScrollEvent) => void`                         |                                                    Executed when transitioning between pages (ether because the animation for the requested page has changed or when the user is swiping/dragging between pages)                                                    |   both   |\n| `onPageScrollStateChanged: (e: PageScrollStateChangedEvent) => void` |                                                                                                      Function called when the page scrolling state has changed                                                                                                      |   both   |\n| `onPageSelected: (e: PageSelectedEvent) => void`                     |                                                                                      This callback will be called once the ViewPager finishes navigating to the selected page                                                                                       |   both   |\n| `pageMargin: number`                                                 |                                                                                                                Blank space to be shown between pages                                                                                                                |   both   |\n| `keyboardDismissMode: ('none' / 'on-drag')`                          |                                                                                                Determines whether the keyboard gets dismissed in response to a drag                                                                                                 |   both   |\n| `orientation: Orientation`                                           |                                                                                       Set `horizontal` or `vertical` scrolling orientation (it does **not** work dynamically)                                                                                       |   both   |\n| `overScrollMode: OverScrollMode`                                      |                                                                              Used to override default value of overScroll mode. Can be `auto`, `always` or `never`. Defaults to `auto`                                                                              | Android  |\n| `offscreenPageLimit: number`                                         | Set the number of pages that should be retained to either side of the currently visible page(s). Pages beyond this limit will be recreated from the adapter when needed. Defaults to RecyclerView's caching strategy. The given value must either be larger than 0. | Android  |\n| `overdrag: boolean`                                                  |                                                                                   Allows for overscrolling after reaching the end or very beginning or pages. Defaults to `false`                                                                                   |   iOS    |\n| `layoutDirection: ('ltr' / 'rtl' / 'locale')`                        |                                                      Specifies layout direction. Use `ltr` or `rtl` to set explicitly or `locale` to deduce from the default language script of a locale. Defaults to `locale`                                                      |   both   |\n\n| Method                                     |                                                                                                         Description                                                                                                          | Platform |\n| ------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------: |\n| `setPage(index: number)`                   |                                                                      Function to scroll to a specific page in the PagerView. Invalid index is ignored.                                                                       |   both   |\n| `setPageWithoutAnimation(index: number)`   |                                                                      Function to scroll to a specific page in the PagerView. Invalid index is ignored.                                                                       |   both   |\n| `setScrollEnabled(scrollEnabled: boolean)` | A helper function to enable/disable scroll imperatively. The recommended way is using the scrollEnabled prop, however, there might be a case where a imperative solution is more useful (e.g. for not blocking an animation) |   both   |\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## Known Issues\n\n- `flex:1` does not work for child views, please use `width: '100%', height: '100%'` [instead](https://github.com/callstack/react-native-pager-view/issues/186#issuecomment-675320732)\n\n- [iOS]: In case of `UIViewControllerHierarchyInconsistency` error, please use below fix:\n\n```\nrequestAnimationFrame(() => refPagerView.current?.setPage(index));\n```\n\n## Preview\n\n### Android\n\n|                            horizontal                             |                                  vertical                                  |\n| :---------------------------------------------------------------: | :------------------------------------------------------------------------: |\n| <img src=\"img/android-viewpager.gif\" alt=\"ViewPager\" width=\"325\"> | <img src=\"img/android-viewpager-vertical.gif\" alt=\"ViewPager\" width=\"325\"> |\n\n### iOS\n\n|                              horizontal                              |                                vertical                                |\n| :------------------------------------------------------------------: | :--------------------------------------------------------------------: |\n| <img src=\"img/ios-viewpager-scroll.gif\" alt=\"ViewPager\" width=\"325\"> | <img src=\"img/ios-viewpager-vertical.gif\" alt=\"ViewPager\" width=\"325\"> |\n\n## Reanimated onPageScroll handler\n\nAn example can be found [here](https://github.com/callstack/react-native-pager-view/blob/master/example/src/ReanimatedOnPageScrollExample.tsx)\n\n#### Instructions\n\nTo attach reanimated handler with `onPageScroll` follow the below steps.\n\n```jsx\n// 1. Define the handler\nfunction usePageScrollHandler(handlers, dependencies) {\n  const { context, doDependenciesDiffer } = useHandler(handlers, dependencies);\n  const subscribeForEvents = ['onPageScroll'];\n\n  return useEvent(\n    (event) => {\n      'worklet';\n      const { onPageScroll } = handlers;\n      if (onPageScroll && event.eventName.endsWith('onPageScroll')) {\n        onPageScroll(event, context);\n      }\n    },\n    subscribeForEvents,\n    doDependenciesDiffer\n  );\n}\n\n// 2. Attach the event handler\nimport PagerView from 'react-native-pager-view';\nimport Animated from 'react-native-reanimated';\nconst AnimatedPagerView = Animated.createAnimatedComponent(PagerView);\n\nconst pageScrollHandler = usePageScrollHandler({\n  onPageScroll: (e) => {\n    'worklet';\n    offset.value = e.offset;\n    console.log(e.offset, e.position);\n  },\n});\n\n<AnimatedPagerView onPageScroll={pageScrollHandler} />;\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}