RsD0p9BK
2/26/2016 - 4:58 AM

getBoundingClientRect.js

elem.getBoundingClientRect();
 // https://learn.javascript.ru/coordinates#getboundingclientrect

$.fn.inView = function(){
    var rect = this[0].getBoundingClientRect();
    return (
      rect.top >= 0 &&
      rect.left >= 0 &&
      rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
      rect.right <= (window.innerWidth || document.documentElement.clientWidth)
    );
};

$(window).on('scroll',function() { 
    if( $('footer').inView() ) {
      // do cool stuff
    });
});

// http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport


// http://javascript.info/tutorial/coordinates#the-right-way-elem-getboundingclientrect

// A tale of two viewports — part two
// http://www.quirksmode.org/mobile/viewports2.html