diff --git a/js/angular/controller/refresherController.js b/js/angular/controller/refresherController.js index b0118483f0..2d3ade2685 100644 --- a/js/angular/controller/refresherController.js +++ b/js/angular/controller/refresherController.js @@ -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; diff --git a/test/unit/angular/controller/refreshController.unit.js b/test/unit/angular/controller/refreshController.unit.js index 9ca4a4d889..beca46ee92 100644 --- a/test/unit/angular/controller/refreshController.unit.js +++ b/test/unit/angular/controller/refreshController.unit.js @@ -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); + }); });