Created
April 10, 2014 16:55
-
-
Save ShaneHudson/10401851 to your computer and use it in GitHub Desktop.
NoUiSlider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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