Skip to content

Commit

Permalink
fix(scrollController): allow tab $historyId to remember scroll
Browse files Browse the repository at this point in the history
Fixes a bug with tabs, where tabs would only remember their scroll
position when directly related to a view state.

Closes #1654
  • Loading branch information
ajoslin committed Jun 24, 2014
1 parent 86ce480 commit 9b601b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/angular/controller/scrollController.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca
backListenDone();
if (self._rememberScrollId) {
$$scrollValueCache[self._rememberScrollId] = scrollView.getValues();
console.log($$scrollValueCache);
}
});

Expand All @@ -83,19 +84,21 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca
if (e.defaultPrevented) { return; }
e.preventDefault();

var viewId = historyData && historyData.viewId;
var viewId = historyData && historyData.viewId || $scope.$historyId;
if (viewId) {
$timeout(function() {
self.rememberScrollPosition(viewId);
self.scrollToRememberedPosition();

console.log("scrollToRememberedPosition: ",viewId, $$scrollValueCache);

backListenDone = $rootScope.$on('$viewHistory.viewBack', function(e, fromViewId, toViewId) {
//When going back from this view, forget its saved scroll position
if (viewId === fromViewId) {
self.forgetScrollPosition();
}
});
}, 1, false);
}, 0, false);
}
});

Expand Down

0 comments on commit 9b601b5

Please sign in to comment.