Skip to content

Instantly share code, notes, and snippets.

@ssddanbrown
Last active February 14, 2016 21:09
Show Gist options
  • Save ssddanbrown/0e00ce5400b187ef3243 to your computer and use it in GitHub Desktop.
Save ssddanbrown/0e00ce5400b187ef3243 to your computer and use it in GitHub Desktop.
Simple Jquery Plugins
/**
* Smoothly scrolls to elements it's called upon
* Returns Jquery object for chaining
*/
$.fn.smoothScrollTo = function(speed, offset) {
if (typeof speed === 'undefined') speed = 800;
if (typeof offset === 'undefined') offset = 100;
$('html, body').animate({
scrollTop: this.offset().top - offset // Adjust to change final scroll position top margin
}, speed); // Adjust to change animations speed (ms)
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment