Last active
August 29, 2015 14:09
-
-
Save klauskpm/f865cbc705bd3485a9a4 to your computer and use it in GitHub Desktop.
jQuery plugin to animate and scroll to it's destination.
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
// jQuery Plugin - ScrollToMe | |
// | |
// Needs: | |
// - jQuery(2.1.1) >> http://code.jquery.com/jquery-2.1.1.js | |
(function($) { | |
/** | |
* Plugin to scroll the page till it element | |
* @param {Object.<(string|integer), string>} options Object with | |
* duration time(duration) and animation style(easing) | |
* @returns {jQuery.this} | |
*/ | |
$.fn.scrollToMe = function(options) { | |
var settings = $.extend({duration: 500, easing: 'linear'}, options); | |
$('html, body').animate( | |
{scrollTop: this.offset().top}, | |
settings.duration, | |
settings.easing | |
); | |
return this; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment