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

Commit 8ccf67e

Browse files
author
Robert Messerle
committed
fix(tabs): properly sets initial styles for inkbar when using centered
tabs
1 parent e6c757c commit 8ccf67e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/tabs/js/tabsController.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,14 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
594594
totalWidth = elements.paging.offsetWidth,
595595
tab = elements.tabs[index],
596596
left = tab.offsetLeft,
597-
right = totalWidth - left - tab.offsetWidth;
597+
right = totalWidth - left - tab.offsetWidth,
598+
tabWidth;
599+
if (ctrl.shouldCenterTabs) {
600+
tabWidth = Array.prototype.slice.call(elements.tabs).reduce(function (value, element) {
601+
return value + element.offsetWidth;
602+
}, 0);
603+
if (totalWidth > tabWidth) $timeout(updateInkBarStyles, 0, false);
604+
}
598605
updateInkBarClassName();
599606
angular.element(elements.inkBar).css({ left: left + 'px', right: right + 'px' });
600607
}

0 commit comments

Comments
 (0)