Created
November 15, 2014 22:58
-
-
Save jongacnik/d7ec21bd3fe26ea282d9 to your computer and use it in GitHub Desktop.
scrollTo an element using Velocity
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
/** | |
* Functionality: | |
* - scrolls to an element using Velocity | |
* | |
* Assumes: | |
* - window.jQuery = window.$ = require('jquery'); | |
*/ | |
var velocity = require('velocity-animate'); | |
// Public | |
module.exports = function(element, opts){ | |
var options = $.extend({ | |
'duration' : 600, | |
'easing' : 'easeOutCirc', | |
'callback' : function(){ } | |
}, opts); | |
$(element).velocity('scroll', { | |
'duration' : options.duration, | |
'offset' : -8, | |
'easing' : options.easing, | |
'complete' : options.callback | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment