Last active
December 19, 2015 07:49
-
-
Save eyy/5921753 to your computer and use it in GitHub Desktop.
scrll -- animated scroll to an element
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
{ | |
"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" | |
] | |
} |
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
/* | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great with Bootstrap Scrollspy.