Skip to content

Commit

Permalink
fix(tabs): addresses potential $digest already in progress error
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Messerle committed Sep 22, 2015
1 parent 1a0fc6b commit 4a16038
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
});
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit 4a16038

Please sign in to comment.