npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-wheelpicker

v1.0.8

Published

A simple React component which brings wheelpicker to the web!

Downloads

787

Readme

react-wheelpicker

A simple React component which brings iOS-like wheelpicker to the web!

Find the Demo here

Installation

npm install react-wheelpicker

Usage

The component imported is called WheelPicker.

To use the component, simply import the package on the top of the file and use to render

Import it as

import WheelPicker from 'react-wheelpicker'

Example:

import WheelPicker from 'react-wheelpicker'

class App extends React.Component {
    constructor(){
        super()

        this.state = {
            pickerOpen: false,
            data: ["Intro to Data Science", "Big Data", "Design and Analysis of Algorithms", "Operating Systems", "Cloud Computing", "Principles of Database Systems"],
            defaultSelection: 3,
            selection: "Big Data",
        }
    }

    render(){
        return (
            <React.Fragment>
            <div className="selected" onClick={() => this.setState({ pickerOpen: !this.state.pickerOpen})}>     {this.state.selection}
            </div>
            {this.state.pickerOpen &&
                <div className="demo-container">
                <WheelPicker
                    animation="wheel"
                    data={this.state.data}
                    height={40}
                    parentHeight={250}
                    fontSize={13}
                    defaultSelection={this.state.defaultSelection}
                    updateSelection={selectedIndex => this.setState({ selection: this.state.data[selectedIndex], defaultSelection: selectedIndex })}
                    scrollerId="scroll-select-subject"
                />
                </div>
            }
            </React.Fragment>
        )
    }
  
}

Props passed

  1. scrollerId (String) - COMPULSORY PROP

    • This is a unique string which is used to identify the WheelPicker. This prop allows the user to use multiple WheelPickers on the same page/within the same component. If you use more than one WheelPicker, each of them should recieve a unique scrollerId prop. This prop is used to add a 'scroll' eventlistner to the parent div.
  2. data (Array)

    • You'll need to pass an array of Strings. This array is used to render the picker options from which the user selects.
  3. animation (String)

    • This prop can take 2 values - 'falt' & 'wheel' When the value = 'wheel', the prop height is forced to be = 40
  4. height (Number)

    • This is the height of a single picker option. This value is used in calculating which option is currently in the selector window. Default value = 40 (Also equal to 40 when animation = 'wheel' )
  5. parentHeight (Number)

    • This is the height of the WheelPicker list. This value is also used in calculating which option is currently in the selector window.

    • Default value = (#items in data) * height. Therefore, if the number of items in the data prop is 10 and height of each item is 50px, then parentHeight = 10*50 = 500px

    • Ideal value <= (#items in data) * height

  6. defaultSelection (Number)

    • This is the index of the element that should be selected by default when the WheelPicker is rendered.
  7. updateSelection (Function)

    • This function recieves the selected index and can be used to update the state of the component that renders the WheelPicker. Using this selected index and the data array, we can see which option the user has selected
  8. fontSize (Number)

    • This is the font size of every element in the list