fix(scrollController): allow tab $historyId to remember scroll

Fixes a bug with tabs, where tabs would only remember their scroll
position when directly related to a view state.

Closes #1654
This commit is contained in:
Andrew
2014-06-24 09:57:53 +09:00
parent 86ce480696
commit 9b601b5523

View File

@@ -65,6 +65,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca
backListenDone();
if (self._rememberScrollId) {
$$scrollValueCache[self._rememberScrollId] = scrollView.getValues();
console.log($$scrollValueCache);
}
});
@@ -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);
}
});