@@ -17,9 +17,25 @@ import {
17
17
import { TemplatePortal , PortalHostDirective , Dir , LayoutDirection } from '../core' ;
18
18
import 'rxjs/add/operator/map' ;
19
19
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
+ */
20
30
export type MdTabBodyPositionState =
21
31
'left' | 'center' | 'right' | 'left-origin-center' | 'right-origin-center' ;
22
32
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
+ */
23
39
export type MdTabBodyOriginState = 'left' | 'right' ;
24
40
25
41
@Component ( {
@@ -44,29 +60,26 @@ export type MdTabBodyOriginState = 'left' | 'right';
44
60
animate ( '500ms cubic-bezier(0.35, 0, 0.25, 1)' )
45
61
] )
46
62
] )
47
- ] ,
48
- host : {
49
- 'md-tab-body-active' : "'this._position == 'center'"
50
- }
63
+ ]
51
64
} )
52
65
export class MdTabBody implements OnInit {
53
66
/** The portal host inside of this container into which the tab body content will be loaded. */
54
67
@ViewChild ( PortalHostDirective ) _portalHost : PortalHostDirective ;
55
68
56
69
/** Event emitted when the tab begins to animate towards the center as the active tab. */
57
70
@Output ( )
58
- onTabBodyCentering : EventEmitter < number > = new EventEmitter < number > ( ) ;
71
+ onCentering : EventEmitter < number > = new EventEmitter < number > ( ) ;
59
72
60
73
/** Event emitted when the tab completes its animation towards the center. */
61
74
@Output ( )
62
- onTabBodyCentered : EventEmitter < void > = new EventEmitter < void > ( true ) ;
75
+ onCentered : EventEmitter < void > = new EventEmitter < void > ( true ) ;
63
76
64
77
/** The tab body content to display. */
65
- @Input ( 'md-tab-body- content' ) _content : TemplatePortal ;
78
+ @Input ( 'content' ) _content : TemplatePortal ;
66
79
67
80
/** The shifted index position of the tab body, where zero represents the active center tab. */
68
81
_position : MdTabBodyPositionState ;
69
- @Input ( 'md-tab-body- position' ) set position ( position : number ) {
82
+ @Input ( 'position' ) set position ( position : number ) {
70
83
if ( position < 0 ) {
71
84
this . _position = this . _getLayoutDirection ( ) == 'ltr' ? 'left' : 'right' ;
72
85
} else if ( position > 0 ) {
@@ -78,11 +91,11 @@ export class MdTabBody implements OnInit {
78
91
79
92
/** The origin position from which this tab should appear when it is centered into view. */
80
93
_origin : MdTabBodyOriginState ;
81
- @Input ( 'md-tab-body- origin' ) set origin ( origin : number ) {
94
+ @Input ( 'origin' ) set origin ( origin : number ) {
82
95
if ( origin == null ) { return ; }
83
96
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 ) ) {
86
99
this . _origin = 'left' ;
87
100
} else {
88
101
this . _origin = 'right' ;
@@ -113,7 +126,7 @@ export class MdTabBody implements OnInit {
113
126
114
127
_onTranslateTabStarted ( e : AnimationTransitionEvent ) {
115
128
if ( this . _isCenterPosition ( e . toState ) ) {
116
- this . onTabBodyCentering . emit ( this . _elementRef . nativeElement . clientHeight ) ;
129
+ this . onCentering . emit ( this . _elementRef . nativeElement . clientHeight ) ;
117
130
}
118
131
}
119
132
@@ -125,7 +138,7 @@ export class MdTabBody implements OnInit {
125
138
126
139
// If the transition to the center is complete, emit an event.
127
140
if ( this . _isCenterPosition ( e . toState ) && this . _isCenterPosition ( this . _position ) ) {
128
- this . onTabBodyCentered . emit ( ) ;
141
+ this . onCentered . emit ( ) ;
129
142
}
130
143
}
131
144
0 commit comments