From 4a16038be56b285fdc2c7cbdfcd8853d65408b21 Mon Sep 17 00:00:00 2001 From: Robert Messerle Date: Tue, 22 Sep 2015 12:08:16 -0700 Subject: [PATCH] fix(tabs): addresses potential `$digest already in progress` error Closes #4743 --- src/components/tabs/js/tabsController.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/tabs/js/tabsController.js b/src/components/tabs/js/tabsController.js index dd133476807..2b6937a9ffd 100644 --- a/src/components/tabs/js/tabsController.js +++ b/src/components/tabs/js/tabsController.js @@ -249,7 +249,6 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp handleResizeWhenVisible.watcher(); handleResizeWhenVisible.watcher = null; - // we have to trigger our own $apply so that the DOM bindings will update handleWindowResize(); } }, false); @@ -335,11 +334,11 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp * Update size calculations when the window is resized. */ function handleWindowResize () { - $scope.$apply(function () { - ctrl.lastSelectedIndex = ctrl.selectedIndex; - ctrl.offsetLeft = fixOffset(ctrl.offsetLeft); - $mdUtil.nextTick(ctrl.updateInkBarStyles, false); - $mdUtil.nextTick(updatePagination); + ctrl.lastSelectedIndex = ctrl.selectedIndex; + ctrl.offsetLeft = fixOffset(ctrl.offsetLeft); + $mdUtil.nextTick(function () { + ctrl.updateInkBarStyles(); + updatePagination(); }); } @@ -487,7 +486,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp */ function shouldPaginate () { if (ctrl.noPagination || !loaded) return false; - var canvasWidth = Math.min($element.prop('clientWidth'), ctrl.maxTabWidth); + var canvasWidth = $element.prop('clientWidth'); angular.forEach(elements.dummies, function (tab) { canvasWidth -= tab.offsetWidth; }); return canvasWidth < 0; } @@ -590,7 +589,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp var tab = elements.tabs[ index ], left = tab.offsetLeft, right = tab.offsetWidth + left; - ctrl.offsetLeft = Math.max(ctrl.offsetLeft, fixOffset(right - elements.canvas.clientWidth)); + ctrl.offsetLeft = Math.max(ctrl.offsetLeft, fixOffset(right - elements.canvas.clientWidth + 32 * 2)); ctrl.offsetLeft = Math.min(ctrl.offsetLeft, fixOffset(left)); }