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

drum-control

v0.1.4

Published

Drum is responsive, accessible jQuery revolving drum control plugin to replace a number field or a select menu

Downloads

1

Readme

Drum

Drum is responsive, accessible jQuery plugin to replace a number field or a select menu.

Demo

Getting Started

Using npm

Navigate to your project directory and install the Drum module

$ npm install --save drum-control

Given you have this element in your html:

<div class="drum"></div>

In your script:

import 'drum-control'

$('.drum').drum();

Manually downloading the script

Download the minified production version

In your web page:

<div class="drum"></div>

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="jquery.drum.min.js"></script>

<script>
  jQuery(function($) {
    $('.drum').drum();
  });
</script>

A note about jQuery file

The plugin uses jQuery Widget Factory. Two files are available: one that contains the Widget Factory code, and one that doesn't.

  1. You can use the smaller jquery.drum.bare.min.js, if you have already included the jQuery Widget Factory or another native jQuery widget in your page.
  2. Otherwise you must use jquery.drum.min.js, which includes the jQuery Widget Factory code.

Usage

Initiate Drum

$('.drum').drum(options);

where options is object map of options (optional).

Options

You can customize Drum with these options by either passing options object at initiation, or setting them later, e. g.:

$('.drum').drum('option', 'value', 20);

or

$('.drum').drum('option', {
	max: 100,
	value: 20,
});

All available options

| Option | Type | Default | Description | | ------ | ---- | ------- | ----------- | | type | string | number | Type: either numer or select (currently it is not possible to change type after initialization) | | min | number | 0 | Minimum value (for type=number) | | max | number | Infinity | Maximum value (for type=number) | | step | number | 1 | Increment step (for type=number) | | options | array | [] | Array of items for type=select. Supported format is either strings or objects {value: 'value', label: 'Value'} | | orderAsc | boolean | true | Whether the items are displayed in ascending order or descending | | watchOutside | boolean | true | Whether dragging outside the widget rigion should be counted | | edgeLimit | number | 0.8 | Limit where the drum can reach on the edges as part of the viewport.E.g. edgeLimit: 1 means the drum can be spinned to the viewport edge but no further.edgeLimit: .5 - the drum can't go further than half the viewport.valuew higher than 1 will let the drum go beyond viewport. | | acceleration | number | 300 | Drum acceleration (deceleration) | | renderItemsNum | integer | 100 | Number of items to render in the drum. If total number of items is more, they will be inserted as the drum rolls closer to the edge. | | maxSpinOffset | number | 500 | Maximum offset the drum can spin to after a swipe in pixels |

Events

You can listen to events by passing a callback at the initialization:

$(".drum").drum({
	max: 100,
	value: 13,
	change: function(event, data) {
		console.log('Value: '+ data.value);
	}
});

or attach a listener to the "drumchange" event at a later point:

$(".drum").on('drumchange', function(event, data) {
	console.log('Value: '+ data.value);
});

In both cases the callback receives data object with the new value.

All events

| Event | Description | | ----- | ----------- | | dragstart | Triggers when dragging has started on the drum (similar to mousedown) | | drag | Triggers during drag (similar to mousemove) | | dragend | Triggers when dragging has ended (similar to mouseup) | | change | Triggers when the drum has finished revolving and we have a new value |

Styling

To customize widget's appearance, you can style its underlying HTML elements with CSS. The elements' classes are:

| Class | Description | | ------------------- | ----------- | | drum-viewport | The viewport container | | drum-drum | The drum containing all the items. Stretches outside the viewport | | drum-item | Single item inside the drum | | drum-item-current | Currently selected drum item |

You can also add classes using option:

$('.drum').drum('option', 'classes.drum-viewport', 'my-container-name');

The default options are stored in jQuery.fn.drum.defaults. You can override them, so that all instances will be created with the overridden options.

Browser Support

Chrome, Firefox, Safari, Edge and IE 11 are supported.

License

© 2019 Tigran Sargsyan

Licensed under the MIT License