Skip to content

Instantly share code, notes, and snippets.

@christierney402
Created September 30, 2015 22:14
Show Gist options
  • Save christierney402/948f57f88792eb746b05 to your computer and use it in GitHub Desktop.
Save christierney402/948f57f88792eb746b05 to your computer and use it in GitHub Desktop.
wait for all jQuery animations to complete then make the newly expanded section can be seen in the viewport
$container = $('myElem');
$(":animated").promise().done( function() {
if( $container[0].getBoundingClientRect().top < 50 ) {
$('html,body').animate({scrollTop: $container.offset().top}, 800);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment