Skip to content

Commit 34d663e

Browse files
dioxmioadamdbradley
authored andcommitted
feat(scroll): adding scroll-complete event to ionScroll
1 parent 20496d0 commit 34d663e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: js/angular/directive/scroll.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @param {boolean=} paging Whether to scroll with paging.
3232
* @param {expression=} on-refresh Called on pull-to-refresh, triggered by an {@link ionic.directive:ionRefresher}.
3333
* @param {expression=} on-scroll Called whenever the user scrolls.
34+
* @param {expression=} on-scroll-complete Called whenever the scrolling paging is completed.
3435
* @param {boolean=} scrollbar-x Whether to show the horizontal scrollbar. Default true.
3536
* @param {boolean=} scrollbar-y Whether to show the vertical scrollbar. Default true.
3637
* @param {boolean=} zooming Whether to support pinch-to-zoom
@@ -66,6 +67,7 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
6667
direction: '@',
6768
paging: '@',
6869
$onScroll: '&onScroll',
70+
$onScrollComplete: '&onScrollComplete',
6971
scroll: '@',
7072
scrollbarX: '@',
7173
scrollbarY: '@',
@@ -107,18 +109,26 @@ function($timeout, $controller, $ionicBind, $ionicConfig) {
107109
maxZoom: $scope.$eval($scope.maxZoom) || 3,
108110
minZoom: $scope.$eval($scope.minZoom) || 0.5,
109111
preventDefault: true,
110-
nativeScrolling: nativeScrolling
112+
nativeScrolling: nativeScrolling,
113+
scrollingComplete: onScrollComplete
111114
};
112115

113116
if (isPaging) {
114117
scrollViewOptions.speedMultiplier = 0.8;
115118
scrollViewOptions.bouncing = false;
116119
}
117120

118-
$controller('$ionicScroll', {
121+
var scrollCtrl = $controller('$ionicScroll', {
119122
$scope: $scope,
120123
scrollViewOptions: scrollViewOptions
121124
});
125+
126+
function onScrollComplete() {
127+
$scope.$onScrollComplete && $scope.$onScrollComplete({
128+
scrollTop: scrollCtrl.scrollView.__scrollTop,
129+
scrollLeft: scrollCtrl.scrollView.__scrollLeft
130+
});
131+
}
122132
}
123133
}
124134
};

0 commit comments

Comments
 (0)