test(sideMenu2): update test to reflect changes

This commit is contained in:
Andy Joslin
2014-03-17 07:48:52 -06:00
parent 4715a118e0
commit cc0a4ef775
5 changed files with 35 additions and 23 deletions

View File

@@ -34,7 +34,7 @@ angular.module('ionic.ui.service.scrollDelegate', [])
* }
* ```
*/
.factory('$ionicScrollDelegate', ['$rootScope', '$timeout', '$location', function($rootScope, $timeout, $location) {
.factory('$ionicScrollDelegate', ['$rootScope', '$timeout', '$location', '$ionicViewService', function($rootScope, $timeout, $location, $ionicViewService) {
function getScrollCtrl($scope) {
var ctrl;
@@ -131,6 +131,18 @@ angular.module('ionic.ui.service.scrollDelegate', [])
}, element[0]);
},
/**
* @ngdoc method
* @name $ionicScrollDelegate#rememberScrollPosition
* @description Used on an instance of $ionicScrollDelegate.
*
* If this scroll area is associated with a view in the history,
* load the last scroll position from the last time this view was shown.
*/
rememberScrollPosition: function(animate) {
scrollScope.$broadcast('scroll.rememberPosition', !!animate);
},
/**
* @private
* Attempt to get the current scroll view in scope (if any)
@@ -204,6 +216,15 @@ angular.module('ionic.ui.service.scrollDelegate', [])
}
});
});
$scope.$on('scroll.rememberPosition', function(e, animate) {
scrollViewResize().then(function() {
var view = $ionicViewService.getCurrentView();
var values = view && view.rememberedScrollValues;
if (view && values) {
scrollView.scrollTo(+values.left || null, +values.top || null, animate);
}
});
});
};
return ionicScrollDelegate;