CODE
(function() {
var delay = false;
$(document).on('mousewheel DOMMouseScroll', function(event) {
event.preventDefault();
if(delay) return;
delay = true;
setTimeout(function(){delay = false},200)
var wd = event.originalEvent.wheelDelta || -event.originalEvent.detail;
var a= document.getElementsByTagName('a');
if(wd < 0) {
for(var i = 0; i < a.length; i++) {
var t = a[i].getClientRects()[0].top;
if(t >= 40) break;
}
}
else {
for(var i = a.length-1; i >= 0; i--) {
var t = a[i].getClientRects()[0].top;
if(t < -20) break;
}
}
if (typeof a[i] != 'undefined') {
$('html,body').animate({
scrollTop: a[i].offsetTop
});
var href = $.attr(a[i], 'name');
window.location.hash = href;
} else {
history.pushState("", document.title, window.location.pathname + window.location.search);
}
});
})();
var delay = false;
$(document).on('mousewheel DOMMouseScroll', function(event) {
event.preventDefault();
if(delay) return;
delay = true;
setTimeout(function(){delay = false},200)
var wd = event.originalEvent.wheelDelta || -event.originalEvent.detail;
var a= document.getElementsByTagName('a');
if(wd < 0) {
for(var i = 0; i < a.length; i++) {
var t = a[i].getClientRects()[0].top;
if(t >= 40) break;
}
}
else {
for(var i = a.length-1; i >= 0; i--) {
var t = a[i].getClientRects()[0].top;
if(t < -20) break;
}
}
if (typeof a[i] != 'undefined') {
$('html,body').animate({
scrollTop: a[i].offsetTop
});
var href = $.attr(a[i], 'name');
window.location.hash = href;
} else {
history.pushState("", document.title, window.location.pathname + window.location.search);
}
});
})();
Jan 23 2016, 08:28 PM
Quote
0.0149sec
1.07
6 queries
GZIP Disabled