mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(ionInfiniteScroll): remove listener on $destroy
This commit is contained in:
10
js/ext/angular/src/directive/ionicContent.js
vendored
10
js/ext/angular/src/directive/ionicContent.js
vendored
@@ -353,9 +353,15 @@ function($timeout, $controller, $ionicBind) {
|
||||
}, 0, false);
|
||||
infiniteScrollCtrl.isLoading = false;
|
||||
});
|
||||
$scope.$on('$destroy', function() {
|
||||
scrollCtrl.$element.off('scroll', checkBounds);
|
||||
});
|
||||
|
||||
scrollCtrl.$element.on('scroll', ionic.animationFrameThrottle(checkInfiniteBounds));
|
||||
setTimeout(checkInfiniteBounds);
|
||||
var checkBounds = ionic.animationFrameThrottle(checkInfiniteBounds);
|
||||
|
||||
//Check bounds on start, after scrollView is fully rendered
|
||||
setTimeout(checkBounds);
|
||||
scrollCtrl.$element.on('scroll', checkBounds);
|
||||
|
||||
function checkInfiniteBounds() {
|
||||
if (infiniteScrollCtrl.isLoading) return;
|
||||
|
||||
@@ -61,6 +61,14 @@ describe('ionicInfiniteScroll directive', function() {
|
||||
expect(ctrl.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
it('should unbind scroll event on destroy', function() {
|
||||
var el = setup();
|
||||
spyOn(el.controller('$ionicScroll').$element, 'off');
|
||||
el.scope().$destroy();
|
||||
expect(el.controller('$ionicScroll').$element.off).toHaveBeenCalledWith('scroll', jasmine.any(Function));
|
||||
|
||||
});
|
||||
|
||||
describe('icon', function() {
|
||||
it('should have default icon ion-loading-d', function() {
|
||||
var el = setup();
|
||||
|
||||
Reference in New Issue
Block a user