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

Commit 556be5f

Browse files
author
Robert Messerle
committed
fix(tabs): improves performance by reducing the number of digests caused by tabs
Related to #3101
1 parent 7314e12 commit 556be5f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
3131
ctrl.shouldCenterTabs = shouldCenterTabs();
3232

3333
//-- define public methods
34+
ctrl.updatePagination = $mdUtil.debounce(updatePagination, 100);
3435
ctrl.redirectFocus = redirectFocus;
3536
ctrl.attachRipple = attachRipple;
3637
ctrl.shouldStretchTabs = shouldStretchTabs;
@@ -79,7 +80,7 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
7980
function bindEvents () {
8081
angular.element($window).on('resize', handleWindowResize);
8182
angular.element(elements.paging).on('DOMSubtreeModified', ctrl.updateInkBarStyles);
82-
angular.element(elements.paging).on('DOMSubtreeModified', updatePagination);
83+
angular.element(elements.paging).on('DOMSubtreeModified', ctrl.updatePagination);
8384
}
8485

8586
function configureWatchers () {
@@ -569,11 +570,9 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
569570
oldIndex = ctrl.lastSelectedIndex,
570571
ink = angular.element(elements.inkBar);
571572
if (!angular.isNumber(oldIndex)) return;
572-
if (newIndex < oldIndex) {
573-
ink.addClass('md-left').removeClass('md-right');
574-
} else if (newIndex > oldIndex) {
575-
ink.addClass('md-right').removeClass('md-left');
576-
}
573+
ink
574+
.toggleClass('md-left', newIndex < oldIndex)
575+
.toggleClass('md-right', newIndex > oldIndex);
577576
}
578577

579578
/**

0 commit comments

Comments
 (0)