Created
June 16, 2014 07:15
-
-
Save Layoric/cc0aa15a251c52320d6e to your computer and use it in GitHub Desktop.
Simple angular replacement for scroll to content links
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
app.directive('scrollTo', [function () { | |
"use strict"; | |
return { | |
restrict: 'EA', | |
controller: function ($scope) { | |
}, | |
link: function ($scope,$element,$attrs) { | |
if($attrs.scrollTo != null) { | |
var elementNameToScroll = $attrs.scrollTo; | |
var elementToScrollToo = $('[name="' + elementNameToScroll + '"'); | |
$element.bind('click', function () { | |
if(elementToScrollToo != null) { | |
elementToScrollToo[0].scrollIntoView(true); | |
} | |
}); | |
} | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment