Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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