Created
June 23, 2016 15:19
-
-
Save rnaffer/d0309cefc9191983e6300c5732d6da67 to your computer and use it in GitHub Desktop.
Angular SmothScrollTo Directiva
This file contains hidden or 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
| 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