Skip to content

Instantly share code, notes, and snippets.

@getflourish
Created October 12, 2011 12:20
Show Gist options
  • Select an option

  • Save getflourish/1281079 to your computer and use it in GitHub Desktop.

Select an option

Save getflourish/1281079 to your computer and use it in GitHub Desktop.
Scroll to an anchor with transition
<script type="text/javascript">
$(document).ready(function() {
$('.scrollPage').click(function() {
var elementClicked = $(this).attr("href");
var destination = $(elementClicked).offset().top;
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination+1}, 500, function() { window.location.href = elementClicked;} );
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment