I am loading elements through AJAX. Some of them only show up when you scroll down the page Are there.
Is there a way that I can know that any element is now in the visual section of the page?
This should do the trick:
function isScrolledIntoView (elem) { Var docViewTop = $ (window) is .scrollTop (); Var docViewBottom = docViewTop + $ (window). Light (); Var elemTop = $ (elem) .offset () Top; Var elemBottom = elemTop + $ (elem). height (); Return ((albumbottom & lt; = docViewBottom) & amp; amp; amp; mtopp; = docViewTop; } Simple Utility Function This will allow you to call the utility function which accepts the element that you are looking for and if you fully understand the element Want to see or partially meet? Function utilities () {} Util. Prototype = {Constructor: UTILS, IELMENT INView: Function (Element, Full Inview) {var page top = $ (window) .scrollTop (); Var PageBottom = PageTop + $ (Window). Light (); Var elementTop = $ (element) .offset () Top; Var elementbottom = elementant + $ (element) .ite (); If (fully view === true) {return ((pagetop & lt; elementTop) & amp; amp; amp; amp; amp; amp;;} and {return ((element element & lt; = Page bottle) & amp; amp; amp; amp; amp; amp; amp; element & gt; = pageant) ;;}}} Var Utils = new utilities (); Usage (IsElementInView) {console.log (in 'View');} and {console.log ('Out of View');}
Comments
Post a Comment