Skip to content

Instantly share code, notes, and snippets.

@rnaffer
Created June 23, 2016 15:19
Show Gist options
  • Select an option

  • Save rnaffer/d0309cefc9191983e6300c5732d6da67 to your computer and use it in GitHub Desktop.

Select an option

Save rnaffer/d0309cefc9191983e6300c5732d6da67 to your computer and use it in GitHub Desktop.
Angular SmothScrollTo Directiva
angular.module('app')
.directive('uiScrollGo', function() {
return {
restrict: 'AC',
link: function(scope, el, attr) {
el.on('click', function(e) {
var target = $('#' + attr.uiScrollGo);
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 600);
return false;
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment