Draggable multiple range sliders
Elessar is available via npm and Bower, and as standalone files:
npm install elessar
bower install elessar
Elessar exports as a CommonJS (Node) module, an AMD module, or a browser global:
var RangeBar = require('elessar');
require(['elessar'], function(RangeBar) { ... });
<script src="path/to/elessar.js"></script>
RangeBar
is a function which takes an options object and returns a jQuery element, ready to be inserted into the DOM.
RangeBar({
values: [], // array of value pairs; each pair is the min and max of the range it creates
readonly: false, // whether this bar is read-only
min: 0, // value at start of bar
max: 100, // value at end of bar
valueFormat: function(a) {return a;}, // formats a value on the bar for output
valueParse: function(a) {return a;}, // parses an output value for the bar
snap: 0, // clamps range ends to multiples of this value (in bar units)
minSize: 0, // smallest allowed range (in bar units)
maxRanges: Infinity, // maximum number of ranges allowed on the bar
bgLabels: 0, // number of value labels to write in the background of the bar
indicator: null, // pass a function(RangeBar, Indicator, Function?) Value to calculate where to put a current indicator, calling the function whenever you want the position to be recalculated
allowDelete: false, // set to true to enable double-middle-click-to-delete
deleteTimeout: 5000 // maximum time in ms between middle clicks
});
Returns array of pairs of min and max values of each range.
bar.val(); //=> [[0,20], [34,86]]
Updates the ranges in the bar with the values. Returns the bar, for chaining.
bar.val([[0,30], [40,68]]); //=> bar: RangeBar
Event that triggers constantly as the value changes. Useful for reactively triggering things in your UI. Callback is passed the current values of the ranges and the range element that is changing.
Event that triggers after the user has finished changing a range. Useful for updating a Backbone model. Callback is passed the current values of the ranges and the range element that has changed.