MaxelRus MaxelRus - 4 months ago 21
Javascript Question

Prevent 'wheel' event scrolling if element has basic scroll

I've built custom scrolling on my page through

event on
. However it shoots even when I want to scroll the element with basic scrollbar. How to disable
event on this element, but be able to scroll?


You can check in the event handler if the element is scrollable

window.addEventListener('wheel', function(event) {
    if ( < ) {
          // scollheight less than clientheight, means it doesn't have scrollbars ...
          // do stuff