MCPcopy Create free account
hub / github.com/angular/components / _subscribeToPositions

Function _subscribeToPositions

src/material/menu/menu-trigger-base.ts:385–396  ·  view source on GitHub ↗

* Listens to changes in the position of the overlay and sets the correct classes * on the menu based on the new position. This ensures the animation origin is always * correct, even if a fallback position is used for the overlay.

(menu: MatMenuPanel, position: FlexibleConnectedPositionStrategy)

Source from the content-addressed store, hash-verified

383 * correct, even if a fallback position is used for the overlay.
384 */
385 private _subscribeToPositions(menu: MatMenuPanel, position: FlexibleConnectedPositionStrategy) {
386 if (menu.setPositionClasses) {
387 position.positionChanges.subscribe(change => {
388 this._ngZone.run(() => {
389 const posX: MenuPositionX =
390 change.connectionPair.overlayX === 'start' ? 'after' : 'before';
391 const posY: MenuPositionY = change.connectionPair.overlayY === 'top' ? 'below' : 'above';
392 menu.setPositionClasses!(posX, posY);
393 });
394 });
395 }
396 }
397
398 /**
399 * Sets the appropriate positions on a position strategy

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected