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

svelte-wheel-picker

v0.20.7

Published

A customizable and interactive wheel picker component for Svelte applications, inspired by the classic iOS time selector.

Downloads

14

Readme

svelte-wheel-picker

A customizable and interactive wheel picker component for Svelte applications, inspired by the classic iOS time selector.

npm version License: MIT

Features

  • Customizable wheel picker with smooth scrolling and inertia
  • Configurable number of visible options and density
  • Perspective effect for a 3D wheel appearance
  • Hover effects with unwrapping and stamping effect options
  • Responsive design with options to fill parent container
  • Touch and mouse event support for mobile and desktop
  • No dependencies

Installation

npm install svelte-wheel-picker

Basic Usage

<script>
  import WheelPicker from 'svelte-wheel-picker';

  let data = [
    {value: 1, label: "Option 1"},
    {value: 2, label: "Option 2"},
    {value: 3, label: "Option 3"},
    // Add more options as needed
  ];
</script>

<WheelPicker {data} />

Advanced Usage

Customizing Appearance and Behavior

<script>
  import WheelPicker from 'svelte-wheel-picker';

  let data = [
    // Your data array here
  ];

  let options = {
    visibleOptions: 5,
    density: 10,
    perspective: 30,
    friction: 3,
  };

  let rollOnHover = {
    enable: true,
    unwrap: 85,
    stamp: true,
    fixList: false,
    transformSpeed: 0.3
  };

  let fillParent = {
    enable: true
  };
</script>

<WheelPicker 
  {data}
  {options}
  {rollOnHover}
  {fillParent}
  classes="custom-class"
  style="background-color: #f0f0f0;"
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | Array | [...] | Array of objects with value and label properties | | selectedOption | object | data[0] | Initially selected option | | classes | string | "" | Custom CSS classes | | style | string | "" | Custom inline styles | | options | object | {} | Configuration options for the wheel | | rollOnHover | object | {enable: false} | Configuration for hover effects | | fillParent | object | {enable: false} | Configuration for filling parent container |

options Object Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | visibleOptions | number | 7 | Number of visible options | | density | number | visibleOptions * 2 | Density of options (affects scaling) | | marginY | number | 2 | Vertical margin (in %) | | perspective | number | 0 | Perspective effect (0-180) | | staticPointerTimer | number | 200 | Timer for static pointer (in ms) | | friction | number | 4 | Friction for inertia effect | | overflow | string | "hidden" | Overflow behavior ("hidden" or "visible") |

rollOnHover Object Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | enable | boolean | false | Enable hover effects | | unwrap | number | 85 | Unwrap percentage on hover (0-99) | | stamp | boolean | false | Enable stamping effect | | fixList | boolean | true | Fix list position on hover | | transformSpeed | number | 0.3 | Animation speed for transformations |

fillParent Object Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | enable | boolean | false | Enable filling parent container | | height | string | undefined | Custom height when not filling parent |

Events

The WheelPicker component does not emit custom events, but it updates the selectedOption internally. You can bind to this value to react to changes:

<script lang="ts">
  import WheelPicker from 'svelte-wheel-picker';
  import type {DataOption} from 'svelte-wheel-picker'
  
  let selectedOption:DataOption;
</script>

<WheelPicker bind:selectedOption {...otherProps} />

{#if selectedOption}
  <p>Selected: {selectedOption.label} (Value: {selectedOption.value})</p>
{/if}

Styling

The WheelPicker component uses inline styles for most of its styling needs. You can customize its appearance using the classes and style props, as well as by adjusting the options object.

Browser Compatibility

This component uses modern JavaScript features and CSS properties. Ensure you're using it in a compatible environment or provide appropriate polyfills.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

About

Created by um-dev