项目
在 GitHub 查看
erksch/react-native-wheely
关于
完全使用 JavaScript 编写的 react-native 滚轮选择器,无需任何原生代码。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- -2
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文react-native-wheely
An all JavaScript, highly customizable wheel picker for react native.







Installation
Install with npm
npm install --save react-native-wheely
Install with yarn
yarn add react-native-wheely
Usage
import React, { useState } from 'react';
import WheelPicker from 'react-native-wheely';
function CityPicker() {
const [selectedIndex, setSelectedIndex] = useState(0);
return (
<WheelPicker
selectedIndex={selectedIndex}
options={['Berlin', 'London', 'Amsterdam']}
onChange={(index) => setSelectedIndex(index)}
/>
);
}
Props
| Name | Type | Description |
|---|---|---|
options |
string[] |
Options to be displayed in the wheel picker. Options are rendered from top to bottom, meaning the first item in the options will be at the top and the last at the bottom. |
selectedIndex |
number |
Index of the currently selected option. |
onChange |
(index: number) => void |
Handler that is called when the selected option changes. |
visibleRest |
number |
Amount of additional options that are visible in each direction. Default is 2, resulting in 5 visible options. |
itemHeight |
number |
Height of each option in the picker. Default is 40. |
itemStyle |
StyleProp<ViewStyle> |
Style for the option's container. |
itemTextStyle |
StyleProp<TextStyle> |
Style for the option's text. |
containerStyle |
StyleProp<ViewStyle> |
Style of the picker. |
selectedIndicatorStyle |
StyleProp<ViewStyle> |
Style of overlaying selected-indicator in the middle of the picker. |
rotationFunction |
(x: number) => number |
Function to determine the x rotation of items based on their current distance to the center (which is x). Default is |
scaleFunction |
(x: number) => number |
Function to determine the scale of items based on their current distance to the center (which is x). Default is |
opacityFunction |
(x: number) => number |
Function to determine the opacity of items based on their current distance to the center (which is x). Default is |
decelerationRate |
"normal", "fast", number | How quickly the underlying scroll view decelerates after the user lifts their finger. See the ScrollView docs. Default is "fast". |
containerProps |
ViewProps |
Props that are applied to the container which wraps the FlatList and the selected indicator. |
flatListProps |
FlatListProps |
Props that are applied to the FlatList. |
Memoization
The individual items in the picker (<WheelPickerItem />) are strictly memoized, meaning that they will not rerender after the initial render. Rerendering the picker items uncontrollably would lead to bad performance with large number of options. Item styles, animation functions and other parameters of items therefore must be static and changes to them after the initial render will have no effect.
探索相关项目
加载中…