Skip to content

Instantly share code, notes, and snippets.

@jbuncle
Last active May 19, 2016 12:29
Show Gist options
  • Save jbuncle/2cbcf09d59dcb4e8ea74235562f06c08 to your computer and use it in GitHub Desktop.
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
/*!
* 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