Last active
August 29, 2015 13:57
-
-
Save Joseph-N/9366552 to your computer and use it in GitHub Desktop.
With this jquery snippet you will be able to animate to an anchor from a url. If for example you follow a link from page A (e.g http://mywebsite.com/products/1#tomato) it will scroll smoothly to the element with id of tomato in page B
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// animate scroll put this on (PAGE B) | |
var elementClick = window.location.hash | |
var destination = $(elementClick).offset().top; | |
$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100, function() { | |
window.location.hash = elementClick | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment