Skip to content

Instantly share code, notes, and snippets.

@adrianorsouza
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianorsouza/e7ed1309489c914af1c0 to your computer and use it in GitHub Desktop.
Save adrianorsouza/e7ed1309489c914af1c0 to your computer and use it in GitHub Desktop.
jQuery scrollTo element effect
$("body,html").animate({
scrollTop : (
$('div.element:last').offset().top // get the offset of the last element to scrollTo
- $('header.navbar').outerHeight() // get the difference whether there is fixed header element
+ $('div.element:last').outerHeight() // get the element itself height to make scroolTo be exact under the fixed header
)
},1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment