Advertisement
Guest User

Untitled

a guest
May 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. // Checking visibility
  2. jQuery.fn.isScrolledIntoView = function () {
  3.  
  4. var thisOffset = $(this).offset().top;
  5. var windowHeight = $(window).height();
  6.  
  7. var heightToThis = thisOffset - windowHeight;
  8.  
  9. var scrollPosition = $(window).scrollTop();
  10.  
  11. if ( (scrollPosition >= heightToThis ) ) {
  12. return true;
  13. }
  14.  
  15. }
  16.  
  17. // Timer on scroll
  18.  
  19. $(window).scroll(function(){
  20. // Resize actions are in handleScroll()
  21.  
  22. if (scrollTimer) {
  23. clearTimeout(scrollTimer); // clear any previous pending timer
  24. }
  25. scrollTimer = setTimeout(handleScroll, 1); // set new timer
  26.  
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement