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

feat(overlay): support custom offsets #1660

Merged
merged 1 commit into from
Nov 3, 2016
Merged

Conversation

kara
Copy link
Contributor

@kara kara commented Oct 31, 2016

This PR adds support for custom offsets for overlays. This will pave the way for correctly aligning the selected option over the trigger in the md-select component.

Fixes #879

r: @jelbourn

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 31, 2016
this._offsetX = offset.x;
this._offsetY = offset.y;
return this;
}
Copy link
Member

Choose a reason for hiding this comment

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

Thinking about it more, what do you think of having separate methods for x and y? As it is now, you have to specify both of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I like that. withOffsetX and withOffsetY, I'm guessing?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah

@kara kara force-pushed the overlay-offset branch 3 times, most recently from c2ef9e6 to 9180afc Compare October 31, 2016 21:28
@kara
Copy link
Contributor Author

kara commented Oct 31, 2016

@jelbourn Comment addressed


overlayConfig.direction = this.dir;

return overlayConfig;
}

/** Sets up the position strategy with its initial configuration. */
private _setUpPosition(): ConnectedPositionStrategy {
Copy link
Member

@jelbourn jelbourn Oct 31, 2016

Choose a reason for hiding this comment

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

It's a bit odd that there's getPosition and setUpPosition. Combine them into one method like _createPositionStrategy?

private _createPositionStrategy() {
  let pos = this.positions[0];
  let originPoint = {originX: pos.originX, originY: pos.originY};
  let overlayPoint = {overlayX: pos.overlayX, overlayY: pos.overlayY};

  return this._overlay.position()
      .connectedTo(this.origin.elementRef, originPoint, overlayPoint)
      .withDirection(this.dir)
      .withOffsetX(this.offsetX)
      .withOffsetY(this.offsetY);
}

Copy link
Member

Choose a reason for hiding this comment

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

I also just noticed that it should be originX in the first argument, not overlayX.

Copy link
Member

Choose a reason for hiding this comment

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

Also that this.positions[0] can be pulled out.

@@ -89,11 +95,23 @@ export class ConnectedPositionStrategy implements PositionStrategy {
}

/** Sets the layout direction so the overlay's position can be adjusted to match. */
setDirection(dir: 'ltr' | 'rtl') {
withDirection(dir: 'ltr' | 'rtl'): ConnectedPositionStrategy {
Copy link
Member

Choose a reason for hiding this comment

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

The return type should actually just be this (which is a cool but little-known TS feature)

@kara
Copy link
Contributor Author

kara commented Nov 1, 2016

@jelbourn Okay, ready for another pass.

@jelbourn
Copy link
Member

jelbourn commented Nov 1, 2016

LGTM

@kara kara added the action: merge The PR is ready for merge by the caretaker label Nov 1, 2016
@jelbourn jelbourn merged commit 1738d24 into angular:master Nov 3, 2016
@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.

overlay directive
3 participants