×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: user386d9
Added: May 18, 2017 7:43 AM
Modified: May 18, 2017 8:01 AM
Views: 5
Tags: no tags
  1. function isScrolledIntoView(elem) {
  2.     var docViewTop = $(window).scrollTop();
  3.     var docViewBottom = docViewTop + $(window).height();
  4.  
  5.     var elemTop = $(elem).offset().top;
  6.     var elemBottom = elemTop + $(elem).height();
  7.  
  8.     return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
  9. }