├── .gitignore ├── demo.gif ├── tsconfig.json ├── LICENSE ├── package.json ├── README.md └── index.tsx /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | node_modules 3 | .DS_Store 4 | .swp 5 | .idea 6 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rheng001/react-native-wheel-scrollview-picker/HEAD/demo.gif -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": ["node_modules", "./node_modules", "./node_modules/*"], 3 | "declaration": "true", 4 | "compilerOptions": { 5 | "allowSyntheticDefaultImports": true, 6 | "allowJs": true, 7 | "esModuleInterop": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "isolatedModules": true, 10 | "jsx": "preserve", 11 | "lib": ["dom", "dom.iterable", "esnext", "es6"], 12 | "module": "esnext", 13 | "moduleResolution": "node", 14 | "noEmit": true, 15 | "noImplicitAny": true, 16 | "noImplicitReturns": true, 17 | "noUnusedParameters": true, 18 | "resolveJsonModule": true, 19 | "skipDefaultLibCheck": true, 20 | "skipLibCheck": true, 21 | "strict": true, 22 | "strictNullChecks": true, 23 | "target": "es5" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Richard Heng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-wheel-scrollview-picker", 3 | "version": "2.0.9", 4 | "description": "A pure js picker for React Native", 5 | "main": "index.tsx", 6 | "scripts": { 7 | "test": "echo \"No test specified\"", 8 | "prepublish": "tsc" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/rheng001/react-native-wheel-scrollview-picker.git" 13 | }, 14 | "keywords": [ 15 | "picker", 16 | "wheel", 17 | "react-native", 18 | "react-native-picker" 19 | ], 20 | "author": "rheng001", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/rheng001/react-native-wheel-scrollview-picker/issues" 24 | }, 25 | "homepage": "https://github.com/rheng001/react-native-wheel-scrollview-picker#readme", 26 | "peerDependencies": { 27 | "@types/react": "*", 28 | "@types/react-native": "*", 29 | "react": "*", 30 | "react-native": "*", 31 | "typescript": "*" 32 | }, 33 | "devDependencies": { 34 | "@types/react": "^17.0.15", 35 | "@types/react-native": "^0.64.12", 36 | "react": "^17.0.2", 37 | "react-native": "^0.64.2", 38 | "typescript": "^4.3.5" 39 | }, 40 | "types": "index.d.ts" 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

react-native-wheel-scrollview-picker

2 | 3 |

4 | 5 |

6 | 7 |

A pure js picker for React Native 8 | 9 |

https://www.npmjs.com/package/react-native-wheel-scrollview-picker

10 | 11 | > - Original repository by @veizz: [react-native-picker-scrollview](https://github.com/veizz/react-native-picker-scrollview). 12 | > - Fork by @yasemincidem who added the real cross platform behavior and datepicker [react-native-wheel-scroll-picker](https://github.com/yasemincidem/react-native-picker-scrollview). 13 | > - This is the third fork of repository, since it seems that @yasemincidem is no longer supporting [react-native-wheel-scroll-picker](https://github.com/yasemincidem/react-native-picker-scrollview). 14 | 15 | --- 16 | 17 | ## Table of Contents 18 | 19 | 1. [Features](#features) 20 | 2. [Installation](#installation) 21 | 3. [Usage](#usage) 22 | - [Example](#usage) 23 | 4. [Props](#props) 24 | 5. [License](#license) 25 | 26 | ## Installation 27 | 28 | ```sh 29 | yarn add react-native-wheel-scrollview-picker 30 | # or 31 | npm install react-native-wheel-scrollview-picker --save 32 | ``` 33 | 34 | ## Usage 35 | 36 | ```jsx 37 | import React, { Component } from "react"; 38 | import ScrollPicker from "react-native-wheel-scrollview-picker"; 39 | 40 | export default class SimpleExample extends Component { 41 | render() { 42 | return ( 43 | { 47 | // 48 | }} 49 | onValueChange={(data, selectedIndex) => { 50 | // 51 | }} 52 | wrapperHeight={180} 53 | wrapperBackground="#FFFFFF" 54 | itemHeight={60} 55 | highlightColor="#d8d8d8" 56 | highlightBorderWidth={2} 57 | /> 58 | ); 59 | } 60 | } 61 | ``` 62 | 63 | ## Props 64 | 65 | | Props | Description | Type | Default | 66 | | -------------------- | :---------------------------: | :----: | --------: | 67 | | dataSource | Data of the picker | Array | | 68 | | selectedIndex | selected index of the item | number | 1 | 69 | | wrapperHeight | height of the picker | number | | 70 | | wrapperBackground | picker background | string | '#FFF' | 71 | | itemHeight | height of each item | number | | 72 | | highlightColor | color of the indicator line | number | "#d8d8d8" | 73 | | highlightBorderWidth | width of the indicator | string | 1 | 74 | | activeItemTextStyle | Active Item Text object style | object | | 75 | | itemTextStyle | Item Text object style | object | | 76 | 77 | ## Extra 78 | 79 | If you want to scroll to target index, you need the instance function, and that is exposed some functions to parent components by using `useImperativeHandle` ,you can use it。 80 | 81 | ```jsx 82 | import React from "react"; 83 | import { Button } from 'react-native'; 84 | import ScrollPicker from "react-native-wheel-scrollview-picker"; 85 | 86 | const dataSource = ["1", "2", "3", "4", "5", "6"] 87 | export const Demo = () => { 88 | const ref = React.useRef(); 89 | const [index, setIndex] = React.useState(0); 90 | const onValueChange = (data, selectedIndex) => { 91 | setIndex(selectedIndex); 92 | }; 93 | 94 | const onNext = () => { 95 | if (index === dataSource.length - 1) return; 96 | setIndex(index + 1); 97 | ref.current && ref.current.scrollToTargetIndex(index + 1); 98 | } 99 | return ( 100 | 105 |