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

cylinder-picker

v1.0.75

Published

The cylinder-picker library is a customizable, interactive cylindrical item picker for web applications, supporting features like infinite scroll, touch gestures, and dynamic updates.

Downloads

16

Readme

Cylinder picker

NPM NPM Downloads GitHub Repo stars Static Badge

Sample page

Link

Install

npm

npm i cylinder-picker

cdn

<script src="https://unpkg.com/cylinder-picker@latest/dist/index.umd.js"></script>

Report errors and suggestions

Gmail

Change log

| Version | Log | |---------|------------------------------------------------------------------------------| | 1.0.0 | Release | | 1.0.67 | Correction of UI errors on a cylinder-picker with a large amount of elements | | 1.0.75 | Improve the experience of using Touch-pan gestures |

Usage

Add the custom element to your HTML file:

default

<cylinder-picker>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</cylinder-picker>

with infinity scroll

<cylinder-picker infinite>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</cylinder-picker>

with disabled

<cylinder-picker disabled>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</cylinder-picker>

with curvature

<cylinder-picker curvature="25">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
</cylinder-picker>

Properties

The HTMLCylinderPicker class comes with several properties that can be both retrieved and set, allowing for customization and dynamic interaction.

List set

Sets the list of items to be displayed in the picker.

const picker = document.querySelector('cyliner-picker');
picker.list = ["Item 1", "Item 2", "Item 3"]; // set

Value get set

The index of the currently selected item.

const picker = document.querySelector('cyliner-picker');
picker.value = 3; // set
console.log(picker.value); // get
  • This example sets the value of the cylinder-picker to the third index.

ElementValue get

The HTMLLIElement corresponding to the current value.

const picker = document.querySelector('cyliner-picker');
console.log(picker.elementValue); // get

Curvature get set

Adjusts the curvature of the cylinder. default: 20

const picker = document.querySelector('cyliner-picker');
picker.curvature = 25; // set
console.log(picker.curvature); // get

Infinite get set

Enables infinite scrolling. default: false

const picker = document.querySelector('cyliner-picker');
picker.infinite = true; // set
console.log(picker.infinite); // get

Disabled get set

Disables user interaction with the picker. default: false

const picker = document.querySelector('cyliner-picker');
picker.disabled = true; // set
console.log(picker.disabled); // get

InertiaPanCallback set

Sets a callback function to be executed during inertia scrolling.

const picker = document.querySelector('cyliner-picker');
picker.inertiaPanCallback = () => {
    console.log(picker.value);
}; // set
  • This example outputs the value of the cylinder-picker when the pan gesture inertia of the cylinder-picker ends.

Length get

Length of elements in the cylinder-picker.

const picker = document.querySelector('cyliner-picker');
console.log(picker.length); // get

IsAnimating get

The cylinder-picker is currently animated.

const picker = document.querySelector('cyliner-picker');
console.log(picker.isAnimating); // get

Methods

stopInertia()

Stops any ongoing inertia scrolling.

const picker = document.querySelector('cyliner-picker');
await picker.stopInertia();

Events

The HTMLCylinderPicker dispatches a custom event change when the selected item changes. You can listen for this event as follows:

const picker = document.querySelector('cyliner-picker');
picker.addEventListener('change', (event) => {
    console.log('New value:', event.detail.value);
});

Interaction Capabilities

The HTMLCylinderPicker allows users to interact with it through various input methods:

Mouse Wheel

Users can scroll through the picker items using the mouse wheel.

Touch Pan Gesture / Mouse Pan Gesture

Touch pan or mouse pan gestures, such as swiping up and down on touch-enabled devices, can be used to navigate through the picker items.

Touch / Click

Touching or clicking an item directly will select that item.

These interactions are designed to provide a seamless and intuitive experience across different devices and input methods.