Last active
October 1, 2015 13:28
-
-
Save victor-falcon/2000612 to your computer and use it in GitHub Desktop.
Animate Anchors
This file contains 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 all anchors links | |
* Add Jquery | |
*/ | |
jQuery(document).ready(function($) { | |
$("a[href*=#]").click(function(event) { | |
if ($(this).attr('href').indexOf(document.URL) >= 0) | |
event.preventDefault(); | |
searchFor = '#' + $(this).attr('href').split('#')[1]; | |
var offset = $(searchFor).offset().top; | |
$('html, body').animate({scrollTop:offset}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment