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

Commit

Permalink
fix(tabs): tabs now work properly with md-dynamic-height and
Browse files Browse the repository at this point in the history
`md-align-tabs="bottom"`

Closes #4368
  • Loading branch information
Robert Messerle committed Oct 5, 2015
1 parent 4326490 commit 01b7af3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 9 additions & 2 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,17 +628,24 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
function updateHeightFromContent () {
if (!ctrl.dynamicHeight) return $element.css('height', '');
if (!ctrl.tabs.length) return queue.push(updateHeightFromContent);

var tabContent = elements.contents[ ctrl.selectedIndex ],
contentHeight = tabContent ? tabContent.offsetHeight : 0,
tabsHeight = elements.wrapper.offsetHeight,
newHeight = contentHeight + tabsHeight,
currentHeight = $element.prop('clientHeight');
currentHeight = $element.prop('offsetHeight');

if ($element.attr('md-align-tabs') === 'bottom') {
currentHeight -= tabsHeight;
newHeight -= tabsHeight;
}
if ($element.attr('md-border-bottom') !== undefined) ++currentHeight;
if (currentHeight === newHeight) return;

// Lock during animation so the user can't change tabs
locked = true;

var fromHeight = { height: currentHeight + 'px'},
var fromHeight = { height: currentHeight + 'px' },
toHeight = { height: newHeight + 'px' };

// Set the height to the current, specific pixel height to fix a bug on iOS where the height
Expand Down
14 changes: 5 additions & 9 deletions src/components/tabs/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ $tabs-tab-width: $baseline-grid * 12 !default;
$tabs-header-height: 48px !default;

@keyframes md-tab-content-hide {
0% {
opacity: 1;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
0% { opacity: 1; }
50% { opacity: 1; }
100% { opacity: 0; }
}

md-tab-data {
Expand All @@ -35,12 +29,14 @@ md-tabs {
min-height: 200 + $tabs-header-height;
}
&[md-align-tabs="bottom"] {
padding-bottom: $tabs-header-height;
md-tabs-wrapper {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: $tabs-header-height;
z-index: 2;
}
md-tabs-content-wrapper {
top: 0;
Expand Down

0 comments on commit 01b7af3

Please sign in to comment.