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

Commit 1a4eede

Browse files
committed
fix(tabs): min-width not respected on IE11. fix right/left padding
tab-items should have 12px right/left padding instead of 24px - this is to align with the spec and more of the label visible on mobile remove unused calcPagingWidth() convert all translate3d to translate for better IE11 support Fixes #10406
1 parent 5aef450 commit 1a4eede

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
236236
// Fix double-negative which can happen with RTL support
237237
newValue = newValue.replace('--', '');
238238

239-
angular.element(elements.paging).css($mdConstant.CSS.TRANSFORM, 'translate3d(' + newValue + ', 0, 0)');
239+
angular.element(elements.paging).css($mdConstant.CSS.TRANSFORM, 'translate(' + newValue + ', 0)');
240240
$scope.$broadcast('$mdTabsPaginationChanged');
241241
}
242242

@@ -620,14 +620,6 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
620620
ctrl.shouldPaginate = shouldPaginate();
621621
}
622622

623-
/**
624-
* Calculates the width of the pagination wrapper by summing the widths of the dummy tabs.
625-
* @returns {number} the width of the pagination wrapper in pixels
626-
*/
627-
function calcPagingWidth () {
628-
return calcTabsWidth(getElements().tabs);
629-
}
630-
631623
/**
632624
* @param {Array<HTMLElement>} tabs tab item elements for use in computing total width
633625
* @returns {number} the width of the tabs in the specified array in pixels
@@ -647,9 +639,8 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
647639
}
648640

649641
/**
650-
* @returns {number} either the max width as constrained by the container or the max width from an
651-
* old version of the Material Design spec.
652-
* TODO update max tab width to equal the spec in 1.2.
642+
* @returns {number} either the max width as constrained by the container or the max width from
643+
* the 2017 version of the Material Design spec.
653644
*/
654645
function getMaxTabWidth() {
655646
var elements = getElements(),
@@ -663,24 +654,6 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
663654
return Math.max(0, Math.min(containerWidth - 1, specMax));
664655
}
665656

666-
/**
667-
* @returns {number} the min width from an old version of the Material Design spec. This returns
668-
* a larger min width if the container width is larger than 600px.
669-
* TODO update min tab width to equal the spec in 1.2.
670-
*/
671-
function getMinTabWidth() {
672-
var elements = getElements(),
673-
containerWidth = elements.canvas.clientWidth,
674-
xsBreakpoint = 600,
675-
676-
// See https://material.io/design/components/tabs.html#spec which has been updated to 90px.
677-
specMin = containerWidth > xsBreakpoint ? 160 : 72;
678-
679-
// Do the spec minimum, or the canvas width; whichever is *smaller* (tabs larger than the canvas
680-
// width can break the pagination) but not less than 0
681-
return Math.max(0, Math.min(containerWidth - 1, specMin));
682-
}
683-
684657
/**
685658
* Re-orders the tabs and updates the selected and focus indexes to their new positions.
686659
* This is triggered by `tabDirective.js` when the user's tabs have been re-ordered.

src/components/tabs/tabs.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ md-tabs-wrapper {
7676
display: block;
7777
position: relative;
7878
// transform is needed for iOS Safari to prevent content from disappearing on scroll
79-
transform: translate3d(0, 0, 0);
79+
transform: translate(0, 0);
8080
md-prev-button, md-next-button {
8181
height: 100%;
8282
width: $tabs-paginator-width;
@@ -103,7 +103,7 @@ md-tabs-wrapper {
103103
position: absolute;
104104
top: 50%;
105105
left: 50%;
106-
transform: translate3d(-50%, -50%, 0);
106+
transform: translate(-50%, -50%);
107107
}
108108

109109
// For RTL tabs, rotate the buttons
@@ -121,7 +121,7 @@ md-tabs-wrapper {
121121

122122
// In regular mode, we need to flip the chevron icon to point the other way
123123
md-icon {
124-
transform: translate3d(-50%, -50%, 0) rotate(180deg);
124+
transform: translate(-50%, -50%) rotate(180deg);
125125
}
126126
}
127127
&.md-stretch-tabs {
@@ -167,11 +167,14 @@ md-pagination-wrapper {
167167
transition: transform $swift-ease-in-out-duration $swift-ease-in-out-timing-function;
168168
position: absolute;
169169
@include rtl-prop(left, right, 0, auto);
170-
transform: translate3d(0, 0, 0);
170+
transform: translate(0, 0);
171171
&.md-center-tabs {
172172
position: relative;
173173
justify-content: center;
174174
}
175+
md-tab-item {
176+
min-width: 72px;
177+
}
175178
}
176179

177180
md-tabs-content-wrapper {
@@ -194,7 +197,7 @@ md-tab-content {
194197
transition: transform $swift-ease-in-out-duration $swift-ease-in-out-timing-function;
195198
overflow: auto;
196199
// transform is needed for iOS Safari to prevent content from disappearing on scroll
197-
transform: translate3d(0, 0, 0);
200+
transform: translate(0, 0);
198201
&.md-no-scroll {
199202
bottom: auto;
200203
overflow: hidden;
@@ -259,7 +262,7 @@ md-tab {
259262
font-size: 14px;
260263
text-align: center;
261264
line-height: $tabs-header-height - 24;
262-
padding: 12px 24px;
265+
padding: 12px;
263266
transition: background-color 0.35s $swift-ease-in-out-timing-function;
264267
cursor: pointer;
265268
white-space: nowrap;

0 commit comments

Comments
 (0)