Skip to content

Instantly share code, notes, and snippets.

@eyy
Last active December 19, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyy/5921753 to your computer and use it in GitHub Desktop.
Save eyy/5921753 to your computer and use it in GitHub Desktop.
scrll -- animated scroll to an element
{
"name": "scrll",
"version": "0.5.0",
"authors": [
"eyy <etaypere@gmail.com>"
],
"dependencies": {
"jquery" : "*"
},
"description": "animated scroll to an element",
"main": "jquery.scrll.js",
"keywords": [
"scroll"
],
"license": "MIT",
"homepage": "https://gist.github.com/eyy/5921753",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
/*
scrll -- animated scroll to an element
version 0.5
like scrollTo, but smaller.
usage examples:
$.scrll('#about'[, 1000], callback);
*/
(function($) {
$.scrll = function(selector, speed, cb) {
if (!cb && $.isFunction(speed)) {
cb = speed;
speed = $.scrll.speed;
}
$(document.documentElement).animate({
scrollTop: $(selector).offset().top + $.scrll.offset
}, speed, cb);
};
$.scrll.speed = 500;
$.scrll.offset = 0;
})(jQuery);
@eyy
Copy link
Author

eyy commented Oct 22, 2013

Works great with Bootstrap Scrollspy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment