Slidy
Customizable range slider component. Demo. Tests.
var Slidy = require('slidy');
var slidy = new Slidy(el?, {
min: 0,
max: 100,
step: 1,
value: ( this.min - this.max ) / 2,
orientation: 'horizontal',
repeat: false,
snap: false,
pickers: [],
pickerClass: 'slidy-picker',
point: false,
click: true,
keyboard: false,
wheel: false,
aria: false,
change: function (e) { }
})
.update()
.disable()
.enable()
.on('change', fn)
.on('input', fn)
.addPicker({
value: 0,
release: false,
min: slidy.min,
max: slidy.max,
point: slidy.point
});
slidy.getActivePicker()
.move(x, y)
.inc(times [, timesY])
.update();
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.