Skip to content

Instantly share code, notes, and snippets.

@jongacnik
Created November 15, 2014 22:58
Show Gist options
  • Save jongacnik/d7ec21bd3fe26ea282d9 to your computer and use it in GitHub Desktop.
Save jongacnik/d7ec21bd3fe26ea282d9 to your computer and use it in GitHub Desktop.
scrollTo an element using Velocity
/**
* 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