1.0.75 • Published 1 year ago

cylinder-picker v1.0.75

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

VersionLog
1.0.0Release
1.0.67Correction of UI errors on a cylinder-picker with a large amount of elements
1.0.75Improve 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.

1.0.75

1 year ago

1.0.74

1 year ago

1.0.73

1 year ago

1.0.72

1 year ago

1.0.71

1 year ago

1.0.70

1 year ago

1.0.69

1 year ago

1.0.68

1 year ago

1.0.67

1 year ago

1.0.66

1 year ago

1.0.65

1 year ago

1.0.64

1 year ago

1.0.63

1 year ago

1.0.62

1 year ago

1.0.61

1 year ago

1.0.60

1 year ago

1.0.59

1 year ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.49

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago