Last active
December 11, 2015 18:49
-
-
Save Schniz/4644718 to your computer and use it in GitHub Desktop.
scrolls the browser to a place in the window. FUN FUN FUN.
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
/** | |
* Nicely scrolls the window to a certain place in a page | |
* @param whereTo jQuery|px to scroll to | |
* @param speed in ms. default - 700 | |
* @param easing the easing. default - easeOutCirc | |
*/ | |
scrollWindowTo = function(whereTo, speed, easing) { | |
if (!speed) speed = 700; | |
if (!easing) easing = jQuery.easing["easeOutCirc"] ? "easeOutCirc" : null; | |
if (whereTo instanceof jQuery) { | |
whereTo = whereTo.offset().top; | |
} | |
$('html,body').animate({scrollTop: whereTo}, speed, easing); | |
}; | |
/** | |
* jQuery function | |
* @param speed in ms | |
* @param easing | |
*/ | |
$.fn.scrollHere = function(speed, easing) { | |
scrollWindowTo($(this), speed, easing); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment