Created
July 20, 2018 08:54
-
-
Save ihorduchenko/08b0e6f8f248495e2df729d7af5188e6 to your computer and use it in GitHub Desktop.
Bind scroll to element(not "window")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener( | |
'scroll', | |
function(event){ | |
var $elm = $(event.target); | |
if( $elm.is('.element1, .element2')){ // or any other filtering condition | |
// do some stuff | |
console.log('scrolling'); | |
} | |
}, | |
true // Capture event | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment