rnaffer
6/23/2016 - 3:19 PM

Angular SmothScrollTo Directiva

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;
                    }
                });
            }
        };
    });