This is a simple jQuery plugin that detect whether or not an element is within the viewport.
Simply calling $('.element').isInView()
will return true
if the middle of the element is within the viewport and false
if not.
$(window).on('load scroll', function() {
if ( $('footer.main-footer').isInView() ) {
// start animation within footer
}
});