Last active
April 29, 2020 08:37
-
-
Save sukhikh18/339193ece679348d9fd5dfb4cf761d43 to your computer and use it in GitHub Desktop.
On scroll element appear. Use: $(this).scrollIn()
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
$.fn.scrollIn = function() { | |
var $window = $(window), | |
scrollTop = $window.scrollTop(), | |
viewport = { | |
top: scrollTop, | |
bottom: scrollTop + $window.height() | |
}, | |
bounds = this.offset(); | |
bounds.bottom = bounds.top + this.outerHeight(); | |
return (!(viewport.bottom < bounds.top || viewport.top > bounds.bottom)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment