when binding with mousewheel function window.scrollBy() does nothing
document.getElementsByClassName("elementor-section-wrap")[0].addEventListener('mousewheel',function(event){window.scrollBy(0, window.innerHeight); }, false);
But when binding with click event function window.scrollBy() does scroll down
document.getElementsByClassName("elementor-section-wrap")[0].addEventListener('click',function(event){window.scrollBy(0, window.innerHeight); }, false);
How could I do it with the mousewheel event?
答案 0 :(得分:0)
if you want bind this you can use
$(window).bind('mousewheel DOMMouseScroll', function(event){
if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
// scroll up
}
else {
// scroll down
}
});
you can listen on scroll event like this
window.onscroll = function() {
//your logic
}
also can be done like this:
window.addEventListener('scroll', effects);