JQuery Throttled Scroll Event
var scrollTimeout;
var throttle = 50;
scrollEvent = function() {
if ($(window).scrollTop() > 500) {
$(".navbar").addClass("stuck");
} else {
$(".navbar").removeClass("stuck");
}
};
$(window).on('scroll', function() {
if (!scrollTimeout) {
scrollTimeout = setTimeout(function() {
scrollEvent();
scrollTimeout = null;
}, throttle);
}
// console.log('native scroll');
});