Skip to content

Instantly share code, notes, and snippets.

@ShaneHudson
Created April 10, 2014 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShaneHudson/10401851 to your computer and use it in GitHub Desktop.
Save ShaneHudson/10401851 to your computer and use it in GitHub Desktop.
NoUiSlider
var min = 1;
var max = 20;
var Link = $.noUiSlider.Link;
$(".range-slider").noUiSlider({
start: [2, 14],
connect: true,
behaviour: 'tap-drag',
range: {
'min': min,
'max': max
},
serialization: {
lower: [
new Link({
target: $(".js-min")
})
],
upper: [
new Link({
target: $(".js-max")
})
],
format: {
decimals: 1
}
}
});
$(".range-slider").on('slide', function(event, val) {
var interval;
interval = setInterval(function() {
if (val[0] <= min) {
$(this).val([val -1, null]);
}
if (val[1] > max) {
$(this).val([null, val + 1]);
}
console.log(val);
}, 100);
$(this).on('set', function() {
clearInterval(interval);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment