Skip to content

Instantly share code, notes, and snippets.

@eyy
Last active December 19, 2015 07:49
Show Gist options
  • Select an option

  • Save eyy/5921753 to your computer and use it in GitHub Desktop.

Select an option

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 <[email protected]>"
],
"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
Copy Markdown
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