Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabs): tabs should update when tabs are added or removed #2014

Merged
merged 8 commits into from
Dec 1, 2016

Conversation

andrewseguin
Copy link
Contributor

Closes #1692

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 29, 2016

export type MdTabBodyOriginState = 'left' | 'right';

@Component({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add class comment explaining what this component is for and that it's internal-only.

state('left-origin-center', style({transform: 'translate3d(0, 0, 0)'})),
state('right-origin-center', style({transform: 'translate3d(0, 0, 0)'})),
state('center', style({transform: 'translate3d(0, 0, 0)'})),
state('right', style({transform: 'translate3d(100%, 0, 0)'})),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment for what the different states represent and maybe a high-level explanation of the animations?

])
],
host: {
'md-tab-body-active': "'this._position == 'center'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be '[class.md-tab-body-active]'?

this._origin = 'left';
} else {
this._origin = 'right';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More readable to add a variable for dir:

let dir = this._getLayoutDirection();
if ((dir == 'ltr' && origin <= 0) || (dir == 'rtl' && origin > 0)) {


/** The shifted index position of the tab body, where zero represents the active center tab. */
_position: MdTabBodyPositionState;
@Input('md-tab-body-position') set position(position: number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit the alias for all of these inputs. Just position, origin, are fine.

In general, only the selector for a directive has the md- prefix, and we should prefer using camelCase properties for binding instead of the dash-case.

@andrewseguin
Copy link
Contributor Author

Added comments to the MdTabBodyPositionState and MdTabBodyOriginState to hopefully clarify how they are used. Let me know if they're still too confusing/abstract.

@jelbourn
Copy link
Member

jelbourn commented Dec 1, 2016

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Dec 1, 2016
@tinayuangao tinayuangao merged commit dfc580d into angular:master Dec 1, 2016
@andrewseguin andrewseguin deleted the tabs-dynamictabs branch December 20, 2016 22:57
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Two-way binding for tabs only work on initializing component
4 participants