From b5a80b44933a516bbaa5556a51f43ed2b465fd3f Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 29 Mar 2013 09:11:10 +0100 Subject: [PATCH] scroll to entry when opened --- src/main/webapp/js/directives.js | 18 ++++++++++++++++++ src/main/webapp/templates/feeds.html | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index b0a4a851..165a85b9 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -1,5 +1,23 @@ var module = angular.module('commafeed.directives', []); +module.directive('scrollTo', function() { + return { + restrict : 'A', + controller : function($scope, $element, $attrs) { + + }, + link : function(scope, element, attrs) { + scope.$watch(attrs.scrollTo, function(value) { + if (value) { + $('html, body').animate({ + scrollTop : $(element).offset().top + 'px' + }, 'fast'); + } + }); + } + }; +}); + module.directive('subscribe', function(SubscriptionService) { return { scope : {}, diff --git a/src/main/webapp/templates/feeds.html b/src/main/webapp/templates/feeds.html index e4a13c85..9a541022 100644 --- a/src/main/webapp/templates/feeds.html +++ b/src/main/webapp/templates/feeds.html @@ -6,7 +6,7 @@
- {{entry.feedName}}