Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slidy

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slidy

Range slider component

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

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

Keywords

FAQs

Package last updated on 10 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc