mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(scroll): cleanup native scroll listeners only if activated
This commit is contained in:
10
js/angular/controller/refresherController.js
vendored
10
js/angular/controller/refresherController.js
vendored
@@ -246,14 +246,14 @@ IonicModule
|
||||
ionic.on('touchmove', handleTouchmove, scrollChild);
|
||||
ionic.on('touchend', handleTouchend, scrollChild);
|
||||
ionic.on('scroll', handleScroll, scrollParent);
|
||||
|
||||
// cleanup when done
|
||||
$scope.$on('$destroy', destroy);
|
||||
};
|
||||
|
||||
|
||||
$scope.$on('$destroy', destroy);
|
||||
|
||||
function destroy() {
|
||||
ionic.off('dragdown', handleTouchmove, scrollChild);
|
||||
ionic.off('dragend', handleTouchend, scrollChild);
|
||||
ionic.off('touchmove', handleTouchmove, scrollChild);
|
||||
ionic.off('touchend', handleTouchend, scrollChild);
|
||||
ionic.off('scroll', handleScroll, scrollParent);
|
||||
scrollParent = null;
|
||||
scrollChild = null;
|
||||
|
||||
@@ -126,4 +126,16 @@ describe('$ionicRefresh Controller', function() {
|
||||
ctrl.getRefresherDomMethods().hide();
|
||||
expect(refresher.classList.contains('invisible')).toBe(true);
|
||||
});
|
||||
|
||||
it('should cleanup when done', function() {
|
||||
setup();
|
||||
|
||||
expect(ctrl.__getScrollChild()).not.toBe(null);
|
||||
expect(ctrl.__getScrollParent()).not.toBe(null);
|
||||
|
||||
scope.$broadcast('$destroy');
|
||||
|
||||
expect(ctrl.__getScrollChild()).toBe(null);
|
||||
expect(ctrl.__getScrollParent()).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user