mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicScrollDelegate): add getScrollView(), getScrollPosition()
Closes #1117
This commit is contained in:
@@ -94,6 +94,14 @@ angular.module('ionic.ui.scroll')
|
||||
* @param {boolean=} shouldAnimate Whether the scroll should animate.
|
||||
*/
|
||||
'scrollBy',
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $ionicScrollDelegate#getScrollPosition
|
||||
* @returns {object} The scroll position of this view, with the following properties:
|
||||
* - `{number}` `left` The distance the user has scrolled from the left (starts at 0).
|
||||
* - `{number}` `top` The distance the user has scrolled from the top (starts at 0).
|
||||
*/
|
||||
'getScrollPosition',
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $ionicScrollDelegate#anchorScroll
|
||||
@@ -105,6 +113,12 @@ angular.module('ionic.ui.scroll')
|
||||
* @param {boolean=} shouldAnimate Whether the scroll should animate.
|
||||
*/
|
||||
'anchorScroll',
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $ionicScrollDelegate.#getScrollView
|
||||
* @returns {object} The scrollView associated with this delegate.
|
||||
*/
|
||||
'getScrollView',
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name $ionicScrollDelegate#rememberScrollPosition
|
||||
@@ -272,6 +286,14 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca
|
||||
|
||||
this._rememberScrollId = null;
|
||||
|
||||
this.getScrollView = function() {
|
||||
return this.scrollView;
|
||||
};
|
||||
|
||||
this.getScrollPosition = function() {
|
||||
return this.scrollView.getValues();
|
||||
};
|
||||
|
||||
this.resize = function() {
|
||||
return $timeout(resize);
|
||||
};
|
||||
|
||||
@@ -219,6 +219,17 @@ describe('$ionicScroll Controller', function() {
|
||||
expect(ctrl.scrollView.resize).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('.getScrollView', function() {
|
||||
setup();
|
||||
expect(ctrl.getScrollView()).toBe(ctrl.scrollView);
|
||||
});
|
||||
it('.getScrollPosition', function() {
|
||||
setup();
|
||||
var values = {};
|
||||
spyOn(ctrl.scrollView, 'getValues').andReturn(values);
|
||||
expect(ctrl.getScrollPosition()).toBe(values);
|
||||
});
|
||||
|
||||
[false, true].forEach(function(shouldAnimate) {
|
||||
describe('with animate='+shouldAnimate, function() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user