Last active
February 14, 2016 21:09
-
-
Save ssddanbrown/0e00ce5400b187ef3243 to your computer and use it in GitHub Desktop.
Simple Jquery Plugins
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
/** | |
* 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