diff --git a/index.html b/index.html index d38d79b..df3ff1f 100644 --- a/index.html +++ b/index.html @@ -58,5 +58,6 @@ + diff --git a/js/directives/keepScrollPos.js b/js/directives/keepScrollPos.js new file mode 100644 index 0000000..7fb5f35 --- /dev/null +++ b/js/directives/keepScrollPos.js @@ -0,0 +1,30 @@ +// Source: http://stackoverflow.com/a/25073496/1110183 +taskBoardDirectives.directive("keepScrollPos", function($route, $window, $timeout, $location, $anchorScroll) { + + // cache scroll position of each route's templateUrl + var scrollPosCache = {}; + + // compile function + return function(scope, element, attrs) { + scope.$on('$routeChangeStart', function() { + // store scroll position for the current view + if ($route.current) { + scrollPosCache[$route.current.loadedTemplateUrl] = [ $window.pageXOffset, $window.pageYOffset ]; + } + }); + + scope.$on('$routeChangeSuccess', function() { + // if hash is specified explicitly, it trumps previously stored scroll position + if ($location.hash()) { + $anchorScroll(); + + // else get previous scroll position; if none, scroll to the top of the page + } else { + var prevScrollPos = scrollPosCache[$route.current.loadedTemplateUrl] || [ 0, 0 ]; + $timeout(function() { + $window.scrollTo(prevScrollPos[0], prevScrollPos[1]); + }, 0); + } + }); + } + }); \ No newline at end of file diff --git a/partials/board.html b/partials/board.html index 1234673..416497b 100644 --- a/partials/board.html +++ b/partials/board.html @@ -37,7 +37,7 @@
+ data-context-menu="onContextMenu(lane.id)" data-target="laneMenu" data-keep-scroll-pos>

{{ lane.name }} {{ lane.ownItem.length || 0 }} @@ -59,7 +59,7 @@

{{ item.title }}

{{ item.points }}

-
+

Assigned To: {{ userNames[item.assignee] }}