Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): remove window resize listener on $destroy
Browse files Browse the repository at this point in the history
Closes #254
  • Loading branch information
ThomasBurleson committed Sep 9, 2014
1 parent 738bb42 commit 4b887f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/base/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var Constant = {
EVENTS : {
TABS_CHANGED : '$materialTabsChanged',
FOCUS_CHANGED : '$materialFocusChanged',
WINDOW_RESIZE : 'resize'
WINDOW_RESIZE : 'resize',
SCOPE_DESTROY : '$destroy'
}
};
8 changes: 7 additions & 1 deletion src/components/tabs/js/tabsDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ function TabsDirective($q, $window, $timeout, $compile, $materialEffects, $$rAF,
$$rAF( updateInk );
};

var onWindowResize = $$rAF.debounce( updateAll );
var onWindowRelease = function() {
angular.element($window).off('resize', onWindowResize);
};

angular.element($window).on( Constant.EVENTS.WINDOW_RESIZE, onWindowResize);
scope.$on( Constant.EVENTS.TABS_CHANGED, updateAll );
angular.element($window).on( Constant.EVENTS.WINDOW_RESIZE, $$rAF.debounce( updateAll ));
scope.$on( Constant.EVENTS.SCOPE_DESTROY,onWindowRelease );

transcludeHeaderItems();
transcludeContentItems();
Expand Down

0 comments on commit 4b887f1

Please sign in to comment.