Git Product home page Git Product logo

react-native-wheely's Introduction

react-native-wheely

CircleCI npm package npm downloads

An all JavaScript, highly customizable wheel picker for react native.

drawingdrawingdrawingdrawingdrawingdrawing

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 rotation equation
opacityFunction (x: number) => number Function to determine the opacity of items based on their current distance to the center (which is x). Default is opacity equation
decelerationRate "normal", "fast", number How quickly the underlying scroll view decelerates after the user lifts their finger. See the ScrollView docs. Default is "fast".
scrollEventThrottle number How often the scroll event will be fired while scrolling (as a time interval in ms). Impacts tradeof between scroll performance and tracking accuracy. See the ScrollView docs. Default is 1.

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.

react-native-wheely's People

Contributors

dependabot[bot] avatar erksch avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

unkwebdev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.