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

slidy

v0.6.0

Published

Range slider component

Downloads

19

Readme

Slidy unstable

Customizable range slider component. Demo. Tests.

npm install slidy

var Slidy = require('slidy');

var slidy = new Slidy(el?, {
	//Minimum value
	min: 0,

	//Maximum value
	max: 100,

	//Step of the value. Can be a function (value) { return Math.round(value); }.
	step: 1,

	//Picker value. In case of multiple pickers - first picker's value.
	value: ( this.min - this.max ) / 2,

	//Type of placement: `horizontal`, `vertical`, `cartesian`, `circular`, `polar`.
	orientation: 'horizontal',

	//Repeat picker by axis: `'x'`, `'y'` or `'both'`.
	repeat: false,

	//Snap to steps during the drag or only when released.
	snap: false,

	//Options for picker instances (see addPicker method).
	//[{value:0}, {value: 1}, ...]
	pickers: [],

	//Class to add to each picker.
	pickerClass: 'slidy-picker',

	//Make pickers single-ponted.
	point: false,

	//Enable click interaction or leave only drag.
	click: true,

	//Enable keyboard interactions.
	keyboard: false,

	//Enable mousewheel interactions.
	wheel: false,

	//Enable aria roles management.
	aria: false,

	//Change callback, will be instantly bound.
	//The only way to catch initial `change` event.
	change: function (e) { }
})

//Update all pickers sizes and positions according to their values (window resize etc).
.update()

//Disable interactivity.
.disable()

//Enable interactivity.
.enable()

//Calls fn on value changes.
.on('change', fn)

//Calls fn on user inputs.
.on('input', fn)

//Append additional picker.
.addPicker({
	//Starting value of a picker.
	value: 0,

	//Apply release-animation.
	release: false,

	//Unlikely you want to redefine slidy’s params, but in case
	min: slidy.min,
	max: slidy.max,
	point: slidy.point
});


//Return picker being focused.
slidy.getActivePicker()

//Move picker to relative `x`, `y` coordinates, update value.
.move(x, y)

//Increment/decrement picker value by `this.step` `times`.
.inc(times [, timesY])

//Update size and position of the picker according to the value.
.update();


//Append slidy element to body.
document.body.appendChild(slidy.element);

In order to extend supported browsers you may need to polyfill WeakMap, WeakSet, Node.prototype.contains, MutationObserver:

https://cdn.polyfill.io/v1/polyfill.js?features=default,WeakMap,WeakSet,Node.prototype.contains

What slidy is not

  • Image slider. Use swiper, dragdealer or alike to create image sliders. Slidy is conceptually bound to value and it’s range, it is single-purpose plugin. Nonetheless, it is possible to create simple carousel with slidy.
  • Content scroller. You can use slidy as a scrollbar, but scrolling content is not slidy’s duty.
  • Slidy doesn’t paint range or any other visual information, because it is domain-specific data, and interpreting slidy input value[s] is up to user. Slider just provides a reliable mechanism of input. To build domain-specific picker, create a new component, like color-tool.
  • Slidy doesn not do non-linear value picking by default, because it supposes linear mapping of screen plot to picking values. The best way to implement logarithmic or similar non-linear picker is to manage value separately in change callback.
  • It does not polyfill native input nor provide hidden form input. Both tasks are implementable externally quite easily via change callback, having them in code would mean useless lines not fitting exact user needs. It is difficult to decide beforehead how values are to be serialized, e. g. 2d values. Focus of the slidy is to provide reliable and agile mechanism of slider input, but not to provide bunch of interfaces.
  • It does not implement native input DOM event mechanics (change, input): if you need that, you can implement that via callbacks. It is done so to keep DOM space unpolluted.

Related

draggy — draggable provider which just works. resizable — resizable provider for the full suite.