|
6 | 6 | * @ngInject
|
7 | 7 | */
|
8 | 8 | function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipple,
|
9 |
| - $mdUtil, $animate, $attrs, $compile, $mdTheming) { |
| 9 | + $mdUtil, $animateCss, $attrs, $compile, $mdTheming) { |
10 | 10 | // define private properties
|
11 | 11 | var ctrl = this,
|
12 | 12 | locked = false,
|
@@ -635,17 +635,41 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
|
635 | 635 | newHeight = contentHeight + tabsHeight,
|
636 | 636 | currentHeight = $element.prop('clientHeight');
|
637 | 637 | if (currentHeight === newHeight) return;
|
| 638 | + |
| 639 | + // Lock during animation so the user can't change tabs |
638 | 640 | locked = true;
|
639 |
| - $animate |
640 |
| - .animate( |
641 |
| - $element, |
642 |
| - { height: currentHeight + 'px' }, |
643 |
| - { height: newHeight + 'px' } |
644 |
| - ) |
645 |
| - .then(function () { |
646 |
| - $element.css('height', ''); |
647 |
| - locked = false; |
648 |
| - }); |
| 641 | + |
| 642 | + var fromHeight = { height: currentHeight + 'px'}, |
| 643 | + toHeight = { height: newHeight + 'px' }; |
| 644 | + |
| 645 | + // Set the height to the current, specific pixel height to fix a bug on iOS where the height |
| 646 | + // first animates to 0, then back to the proper height causing a visual glitch |
| 647 | + $element.css(fromHeight); |
| 648 | + |
| 649 | + // Animate the height from the old to the new |
| 650 | + $animateCss($element, { |
| 651 | + from: fromHeight, |
| 652 | + to: toHeight, |
| 653 | + easing: 'cubic-bezier(0.35, 0, 0.25, 1)', |
| 654 | + duration: 0.5 |
| 655 | + }).start().done(function () { |
| 656 | + // Then (to fix the same iOS issue as above), disable transitions and remove the specific |
| 657 | + // pixel height so the height can size with browser width/content changes, etc. |
| 658 | + $element.css({ |
| 659 | + transition: 'none', |
| 660 | + height: '' |
| 661 | + }); |
| 662 | + |
| 663 | + // In the next tick, re-allow transitions (if we do it all at once, $element.css is "smart" |
| 664 | + // enough to batch it for us instead of doing it immediately, which undoes the original |
| 665 | + // transition: none) |
| 666 | + $mdUtil.nextTick(function() { |
| 667 | + $element.css('transition', ''); |
| 668 | + }); |
| 669 | + |
| 670 | + // And unlock so tab changes can occur |
| 671 | + locked = false; |
| 672 | + }); |
649 | 673 | }
|
650 | 674 |
|
651 | 675 | /**
|
|
0 commit comments