Mousewheel scroll to anchor

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();

Hi @Jacqui,

Thanks for writing in.

We would like to help you regarding this customization however it is beyond the scope of our support. It would be best that you will contact a custom developer regarding this customization.

Thank you so much for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.