Last active
January 27, 2017 11:45
-
-
Save shohel/5a784fb67611f1abf2e0222f0d4562a8 to your computer and use it in GitHub Desktop.
Element on viewport simple jquery code
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).on('DOMContentLoaded load resize scroll', function(){ | |
//Selector | |
var element = 'footer'; | |
var top_of_element = $(element).offset().top; | |
var bottom_of_screen = $(window).scrollTop() + $(window).height(); | |
if((bottom_of_screen > top_of_element) ){ | |
console.log('I am In footer') | |
} | |
else { | |
console.log('I am out from footer') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment