Components: Add offset properties to menu API

Created on 1 Nov 2016  路  7Comments  路  Source: angular/components

Should support x-offset and y-offset.

P5 materiamenu feature

Most helpful comment

Any updates here?

All 7 comments

It would be nice to have another option to use md-menu as context menu. This would require an absolut positioning or?

@kara is there an ETA on this feature yet?

@kara

The following approach works by implementing in menu-trigger.ts file using x-offset only -
@Input() xOffset: string;
and in _getPosition() method add the following code snippet

 return this._overlay.position()
  .connectedTo(this._element,
      {originX: posX, originY: originY}, {overlayX: posX, overlayY: overlayY})
  .withFallbackPosition(
      {originX: fallbackX, originY: originY},
      {overlayX: fallbackX, overlayY: overlayY})
  .withFallbackPosition(
      {originX: posX, originY: fallbackOriginY},
      {overlayX: posX, overlayY: fallbackOverlayY})
  .withFallbackPosition(
      {originX: fallbackX, originY: fallbackOriginY},
      {overlayX: fallbackX, overlayY: fallbackOverlayY})
  .withOffsetX(xOffset);

In HTML we can pass the x-offset as

  <md-toolbar>
      <button md-icon-button xOffset="20" [mdMenuTriggerFor]="posYMenu"                                     
                aria-label="Open y-positioned menu">
          <md-icon>more_vert</md-icon>
      </button>
  </md-toolbar>

The error handling associated with the input fields can be handled in menu-errors.ts.

Please let me know if the approach is right so that I can start work on this feature including the y-offset and update the necessary test cases.

@kara @jelbourn Please review the PR and let me know your inputs on this.

Thanks

Can anyone tell me how i can do offset of menu items now? i need display menu items between button but i cant.
When y-offset will be provided?

Any updates here?

Not to be redundant but certainly hope this is being considered!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kara picture kara  路  3Comments

vitaly-t picture vitaly-t  路  3Comments

julianobrasil picture julianobrasil  路  3Comments

constantinlucian picture constantinlucian  路  3Comments

vanor89 picture vanor89  路  3Comments