Hi there,
I was just wondering whether there is a way to get the mousewheel scroll to land on anchors in the page that comes pre-built with the theme?
And if not, is there a piece of code you could recommend? I used this code but it’s not working for me:
(function() {
var delay = false;
jQuery(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.getElementsByClass (‘anchor’);
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(i >= 0 && i < a.length) {
jQuery(‘html,body’).animate({
scrollTop: a[i].offsetTop
});
}
});
})();
console.clear();