Last active
May 19, 2016 12:29
-
-
Save jbuncle/2cbcf09d59dcb4e8ea74235562f06c08 to your computer and use it in GitHub Desktop.
Simple jQuery Plugin for using an animated scroll to on page anchors/links
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
/*! | |
* Simple jQuery Plugin for using an animated scroll to on page anchors/links. | |
* | |
* Copyright 2016 James Buncle | |
* | |
* Released under the MIT license. | |
* http://jquery.org/license | |
* | |
*/ | |
(function ($) { | |
$.fn.scroller = function () { | |
$(this).each(function () { | |
$(this).click(function (event) { | |
event.preventDefault(); | |
var target = $(this).attr('href'); | |
$('html, body').stop().animate({ | |
scrollTop: $(target).offset().top | |
}, 1000, 'easeOutExpo'); | |
}); | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment