@@ -17,9 +17,25 @@ import {
1717import { TemplatePortal , PortalHostDirective , Dir , LayoutDirection } from '../core' ;
1818import 'rxjs/add/operator/map' ;
1919
20+ /**
21+ * These position states are used internally as animation states for the tab body. Setting the
22+ * position state to left, right, or center will transition the tab body from its current
23+ * position to its respective state. If there is not current position (void, in the case of a new
24+ * tab body), then there will be no transition animation to its state.
25+ *
26+ * In the case of a new tab body that should immediately be centered with an animating transition,
27+ * then left-origin-center or right-origin-center can be used, which will use left or right as its
28+ * psuedo-prior state.
29+ */
2030export type MdTabBodyPositionState =
2131 'left' | 'center' | 'right' | 'left-origin-center' | 'right-origin-center' ;
2232
33+ /**
34+ * The origin state is an internally used state that is set on a new tab body indicating if it
35+ * began to the left or right of the prior selected index. For example, if the selected index was
36+ * set to 1, and a new tab is created and selected at index 2, then the tab body would have an
37+ * origin of right because its index was greater than the prior selected index.
38+ */
2339export type MdTabBodyOriginState = 'left' | 'right' ;
2440
2541@Component ( {
@@ -44,29 +60,26 @@ export type MdTabBodyOriginState = 'left' | 'right';
4460 animate ( '500ms cubic-bezier(0.35, 0, 0.25, 1)' )
4561 ] )
4662 ] )
47- ] ,
48- host : {
49- 'md-tab-body-active' : "'this._position == 'center'"
50- }
63+ ]
5164} )
5265export class MdTabBody implements OnInit {
5366 /** The portal host inside of this container into which the tab body content will be loaded. */
5467 @ViewChild ( PortalHostDirective ) _portalHost : PortalHostDirective ;
5568
5669 /** Event emitted when the tab begins to animate towards the center as the active tab. */
5770 @Output ( )
58- onTabBodyCentering : EventEmitter < number > = new EventEmitter < number > ( ) ;
71+ onCentering : EventEmitter < number > = new EventEmitter < number > ( ) ;
5972
6073 /** Event emitted when the tab completes its animation towards the center. */
6174 @Output ( )
62- onTabBodyCentered : EventEmitter < void > = new EventEmitter < void > ( true ) ;
75+ onCentered : EventEmitter < void > = new EventEmitter < void > ( true ) ;
6376
6477 /** The tab body content to display. */
65- @Input ( 'md-tab-body- content' ) _content : TemplatePortal ;
78+ @Input ( 'content' ) _content : TemplatePortal ;
6679
6780 /** The shifted index position of the tab body, where zero represents the active center tab. */
6881 _position : MdTabBodyPositionState ;
69- @Input ( 'md-tab-body- position' ) set position ( position : number ) {
82+ @Input ( 'position' ) set position ( position : number ) {
7083 if ( position < 0 ) {
7184 this . _position = this . _getLayoutDirection ( ) == 'ltr' ? 'left' : 'right' ;
7285 } else if ( position > 0 ) {
@@ -78,11 +91,11 @@ export class MdTabBody implements OnInit {
7891
7992 /** The origin position from which this tab should appear when it is centered into view. */
8093 _origin : MdTabBodyOriginState ;
81- @Input ( 'md-tab-body- origin' ) set origin ( origin : number ) {
94+ @Input ( 'origin' ) set origin ( origin : number ) {
8295 if ( origin == null ) { return ; }
8396
84- if ( ( this . _getLayoutDirection ( ) == 'ltr' && origin <= 0 ) ||
85- ( this . _getLayoutDirection ( ) == 'rtl' && origin > 0 ) ) {
97+ const dir = this . _getLayoutDirection ( ) ;
98+ if ( ( dir == 'ltr' && origin <= 0 ) || ( dir == 'rtl' && origin > 0 ) ) {
8699 this . _origin = 'left' ;
87100 } else {
88101 this . _origin = 'right' ;
@@ -113,7 +126,7 @@ export class MdTabBody implements OnInit {
113126
114127 _onTranslateTabStarted ( e : AnimationTransitionEvent ) {
115128 if ( this . _isCenterPosition ( e . toState ) ) {
116- this . onTabBodyCentering . emit ( this . _elementRef . nativeElement . clientHeight ) ;
129+ this . onCentering . emit ( this . _elementRef . nativeElement . clientHeight ) ;
117130 }
118131 }
119132
@@ -125,7 +138,7 @@ export class MdTabBody implements OnInit {
125138
126139 // If the transition to the center is complete, emit an event.
127140 if ( this . _isCenterPosition ( e . toState ) && this . _isCenterPosition ( this . _position ) ) {
128- this . onTabBodyCentered . emit ( ) ;
141+ this . onCentered . emit ( ) ;
129142 }
130143 }
131144
0 commit comments