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

Commit

Permalink
fix(tabs): new tab animation broken by code to support IE11
Browse files Browse the repository at this point in the history
Fixes #11689
  • Loading branch information
Splaktar committed Apr 19, 2019
1 parent 16cea88 commit bf00756
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
13 changes: 6 additions & 7 deletions src/components/tabs/demoDynamicTabs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
previous = null;
$scope.tabs = tabs;
$scope.selectedIndex = 0;
$scope.$watch('selectedIndex', function(current, old) {
$scope.$watch('selectedIndex', function(newVal, oldVal) {
previous = selected;
selected = tabs[current];
if (old + 1 && (old !== current)) {
$log.debug('Goodbye ' + previous.title + '!');
selected = tabs[newVal];
if (oldVal + 1 && !angular.equals(oldVal, newVal)) {
$log.log('Goodbye ' + previous.title + '!');
}
if (current + 1) {
$log.debug('Hello ' + selected.title + '!');
if (newVal + 1 > 0) {
$log.log('Hello ' + selected.title + '!');
}
});
$scope.addTab = function(title, view) {
Expand All @@ -52,4 +52,3 @@
};
}
})();

6 changes: 4 additions & 2 deletions src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
* @param {string=} label Optional attribute to specify a simple string as the tab label
* @param {boolean=} ng-disabled If present and expression evaluates to truthy, disabled tab
* selection.
* @param {string=} md-tab-class Optional attribute to specify a class that will be applied to the tab's button
* @param {string=} md-tab-class Optional attribute to specify a class that will be applied to the
* tab's button
* @param {expression=} md-on-deselect Expression to be evaluated after the tab has been
* de-selected.
* @param {expression=} md-on-select Expression to be evaluated after the tab has been selected.
Expand All @@ -36,7 +37,8 @@
* @usage
*
* <hljs lang="html">
* <md-tab label="My Tab" md-tab-class="my-content-tab" ng-disabled md-on-select="onSelect()" md-on-deselect="onDeselect()">
* <md-tab label="My Tab" md-tab-class="my-content-tab" ng-disabled md-on-select="onSelect()"
* md-on-deselect="onDeselect()">
* <h3>My Tab content</h3>
* </md-tab>
*
Expand Down
23 changes: 13 additions & 10 deletions src/components/tabs/js/tabsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
* @param {string|number} left
*/
function handleOffsetChange (left) {
var elements = getElements();
var newValue = ((ctrl.shouldCenterTabs || isRtl() ? '' : '-') + left + 'px');

// Fix double-negative which can happen with RTL support
newValue = newValue.replace('--', '');

angular.element(elements.paging).css($mdConstant.CSS.TRANSFORM, 'translate(' + newValue + ', 0)');
angular.element(getElements().paging).css($mdConstant.CSS.TRANSFORM,
'translate(' + newValue + ', 0)');
$scope.$broadcast('$mdTabsPaginationChanged');
}

Expand Down Expand Up @@ -439,11 +439,11 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
* Create an entry in the tabs array for a new tab at the specified index.
* @param {Object} tabData tab to insert
* @param {number} index location to insert the new tab
* @returns {*}
* @returns {Object} the inserted tab
*/
function insertTab (tabData, index) {
var hasLoaded = loaded;
var proto = {
var proto = {
getIndex: function () { return ctrl.tabs.indexOf(tab); },
isActive: function () { return this.getIndex() === ctrl.selectedIndex; },
isLeft: function () { return this.getIndex() < ctrl.selectedIndex; },
Expand All @@ -455,24 +455,27 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
},
id: $mdUtil.nextUid(),
hasContent: !!(tabData.template && tabData.template.trim())
},
tab = angular.extend(proto, tabData);
};
var tab = angular.extend(proto, tabData);

if (angular.isDefined(index)) {
ctrl.tabs.splice(index, 0, tab);
} else {
ctrl.tabs.push(tab);
}

processQueue();
updateHasContent();

$mdUtil.nextTick(function () {
updatePagination();
setAriaControls(tab);

// if autoselect is enabled, select the newly added tab
if (hasLoaded && ctrl.autoselect) $mdUtil.nextTick(function () {
$mdUtil.nextTick(function () { select(ctrl.tabs.indexOf(tab)); });
});
if (hasLoaded && ctrl.autoselect) {
$mdUtil.nextTick(function () {
$mdUtil.nextTick(function () { select(ctrl.tabs.indexOf(tab)); });
});
}
});
return tab;
}
Expand Down

0 comments on commit bf00756

Please sign in to comment.