Reputation: 305
I've built custom scrolling on my page through wheel
event on window
. However it shoots even when I want to scroll the element with basic scrollbar. How to disable wheel
event on this element, but be able to scroll?
Upvotes: 0
Views: 160
Reputation: 318182
You can check in the event handler if the element is scrollable
window.addEventListener('wheel', function(event) {
if ( event.target.scrollHeight < event.target.clientHeight ) {
// scollheight less than clientheight, means it doesn't have scrollbars ...
// do stuff
}
})
Upvotes: 2