Skip to content

Instantly share code, notes, and snippets.

@Layoric
Created June 16, 2014 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Layoric/cc0aa15a251c52320d6e to your computer and use it in GitHub Desktop.
Save Layoric/cc0aa15a251c52320d6e to your computer and use it in GitHub Desktop.
Simple angular replacement for scroll to content links
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