mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicScrollDelegate): rememberScrollPosition, scrollToRememberedPosition
/**
* @ngdoc method
* @name $ionicScrollDelegate#rememberScrollPosition
* @description
*
* When this scroll area is destroyed, its last scroll position will be
* saved using the given id.
*
* @param {string} id The identifier for this saved scroll position.
*/
/**
* @ngdoc method
* @name $ionicScrollDelegate#scrollToRememberedPosition
* @description
*
* If a scroll position was remembered using the given id, loads the
* remembered scroll position and scrolls there.
*
* @param {string} id The identifier for this saved scroll position.
* @param {boolean=} shouldAnimate Whether to animate the scroll.
*/
This commit is contained in:
@@ -63,6 +63,27 @@ describe('$ionicScroll Controller', function() {
|
||||
expect(ctrl.scrollView.resize).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should remember scroll position on $viewContentLoaded event', function() {
|
||||
var historyData = { rememberedScrollValues: { left: 1, top: 2 } };
|
||||
setup();
|
||||
spyOn(ctrl.scrollView, 'scrollTo');
|
||||
scope.$broadcast('$viewContentLoaded', historyData);
|
||||
timeout.flush();
|
||||
expect(ctrl.scrollView.scrollTo).toHaveBeenCalledWith(1, 2);
|
||||
|
||||
spyOn(ctrl.scrollView, 'getValues').andCallFake(function() {
|
||||
return {
|
||||
left: 33,
|
||||
top: 44
|
||||
};
|
||||
});
|
||||
scope.$broadcast('$destroy');
|
||||
expect(historyData.rememberedScrollValues).toEqual({
|
||||
left: 33,
|
||||
top: 44
|
||||
});
|
||||
});
|
||||
|
||||
it('should unbind window event listener on scope destroy', function() {
|
||||
spyOn(window, 'removeEventListener');
|
||||
spyOn(window, 'addEventListener');
|
||||
|
||||
Reference in New Issue
Block a user