Skip to content

Instantly share code, notes, and snippets.

@artofhuman
Created January 27, 2013 07:49
Show Gist options
  • Save artofhuman/4647271 to your computer and use it in GitHub Desktop.
Save artofhuman/4647271 to your computer and use it in GitHub Desktop.
Javascript: ScrollToElement
/**
* Scrol to elem
* @param {String} selector [description]
* @param {Function} callback [description]
*/
function scrollToElement(selector, callback){
var animation = {scrollTop: $(selector).offset().top};
console.log(selector);
$('html,body').animate(animation, 'slow', 'swing', function() {
if (typeof callback == 'function') {
callback();
}
callback = null;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment