@angular/cdk/overlay#ConnectedPosition TypeScript Examples

The following examples show how to use @angular/cdk/overlay#ConnectedPosition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: navbar.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
dropdownDirections: {
    [key: string]: (AppendToBodyDirection | ConnectedPosition)[];
  } = {
    left: [
      {
        originX: 'end',
        originY: 'top',
        overlayX: 'start',
        overlayY: 'top',
      },
    ],
    top: ['rightDown'],
  };
Example #2
Source File: navbar.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
subMenuDirections: ConnectedPosition[] = [
    {
      originX: 'end',
      originY: 'top',
      overlayX: 'start',
      overlayY: 'top',
      offsetY: -4,
    },
  ];
Example #3
Source File: np-popover.directive.ts    From np-ui-lib with MIT License 6 votes vote down vote up
ngAfterViewInit(): void {
    this.elementRef.nativeElement.className = `${this.elementRef.nativeElement.className} np-popover-target`.trim();
    const position: ConnectedPosition[] = this.utility.getPosition(
      this.placement
    );
    const positionStrategy = this.overlayPositionBuilder
      .flexibleConnectedTo(this.elementRef)
      .withPositions(position);
    if (this.openOnClick) {
      this.overlayRef = this.overlay.create({
        positionStrategy,
        hasBackdrop: this.hasBackDrop,
        backdropClass: this.backDropClass,
      });
      this.overlayRef.backdropClick().subscribe(() => {
        if (this.closeOnClickOutside) {
          this._close();
        }
      });
    } else {
      this.overlayRef = this.overlay.create({
        positionStrategy,
      });
    }
  }
Example #4
Source File: np-tooltip.directive.ts    From np-ui-lib with MIT License 6 votes vote down vote up
ngAfterViewInit(): void {
    this.elementRef.nativeElement.className = `${this.elementRef.nativeElement.className} np-tooltip-target`.trim();
    const position: ConnectedPosition[] = this.utility.getPosition(
      this.placement
    );
    const positionStrategy = this.overlayPositionBuilder
      .flexibleConnectedTo(this.elementRef)
      .withPositions(position);
    this.overlayRef = this.overlay.create({
      positionStrategy,
      scrollStrategy: this.overlay.scrollStrategies.reposition(),
    });

    if (this.tooltipOnFocus) {
      this.focusListener = this._show.bind(this);
      this.blurListener = this._hide.bind(this);
      this.elementRef.nativeElement.addEventListener(
        "focus",
        this.focusListener
      );
      this.elementRef.nativeElement.addEventListener("blur", this.blurListener);
    } else {
      this.mouseEnterListener = this._show.bind(this);
      this.mouseLeaveListener = this._hide.bind(this);
      this.elementRef.nativeElement.addEventListener(
        "mouseover",
        this.mouseEnterListener
      );
      this.elementRef.nativeElement.addEventListener(
        "mouseout",
        this.mouseLeaveListener
      );
    }
  }
Example #5
Source File: np-constants.ts    From np-ui-lib with MIT License 6 votes vote down vote up
TopBottomOverlayPositions: ConnectedPosition[] = [
  {
    originX: "start",
    originY: "bottom",
    overlayX: "start",
    overlayY: "top",
  },
  {
    originX: "start",
    originY: "top",
    overlayX: "start",
    overlayY: "bottom",
  },
]
Example #6
Source File: tooltip.directive.ts    From sba-angular with MIT License 6 votes vote down vote up
position(): ConnectedPosition {
    switch (this.placement) {
      case "bottom":
        return {
          originX: "center",
          originY: "bottom",
          overlayX: "center",
          overlayY: "top",
          offsetY: 8
        };
      case "right":
        return {
          originX: "end",
          originY: "center",
          overlayX: "start",
          overlayY: "center",
          offsetX: 8
        };
      case "left":
        return {
          originX: "start",
          originY: "center",
          overlayX: "end",
          overlayY: "center",
          offsetX: -8
        };
      default:
        return {
          originX: "center",
          originY: "top",
          overlayX: "center",
          overlayY: "bottom",
          offsetY: -8
        };
    }
  }
Example #7
Source File: ngx-mat-timepicker.component.ts    From ngx-mat-timepicker with MIT License 6 votes vote down vote up
overlayPositions: ConnectedPosition[] = [
        {
            originX: "center",
            originY: "bottom",
            overlayX: "center",
            overlayY: "top",
            offsetY: 0
        },
        {
            originX: "center",
            originY: "top",
            overlayX: "center",
            overlayY: "bottom",
            offsetY: 0
        }
    ];
Example #8
Source File: router-outlet-context.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
OVERLAY_POSITION_SOUTH: ConnectedPosition = {originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top'}
Example #9
Source File: router-outlet-settings.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
OVERLAY_POSITION_SOUTH: ConnectedPosition = {originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top'}
Example #10
Source File: np-utility.service.ts    From np-ui-lib with MIT License 5 votes vote down vote up
getPosition(placement: string): ConnectedPosition[] {
    let result: ConnectedPosition[];
    switch (placement) {
      case "left": {
        result = [
          {
            originX: "start",
            originY: "center",
            overlayX: "end",
            overlayY: "center",
            offsetX: -5,
          },
        ];
        break;
      }
      case "right": {
        result = [
          {
            originX: "end",
            originY: "center",
            overlayX: "start",
            overlayY: "center",
            offsetX: 5,
          },
        ];
        break;
      }
      case "top": {
        result = [
          {
            originX: "center",
            originY: "top",
            overlayX: "center",
            overlayY: "bottom",
            offsetY: -5,
          },
        ];
        break;
      }
      case "bottom": {
        result = [
          {
            originX: "center",
            originY: "bottom",
            overlayX: "center",
            overlayY: "top",
            offsetY: 5,
          },
        ];
        break;
      }
      default: {
        result = [
          {
            originX: "center",
            originY: "bottom",
            overlayX: "center",
            overlayY: "top",
            offsetY: 5,
          },
          {
            originX: "center",
            originY: "top",
            overlayX: "center",
            overlayY: "bottom",
            offsetY: -5,
          },
          {
            originX: "start",
            originY: "center",
            overlayX: "end",
            overlayY: "center",
            offsetX: -5,
          },
          {
            originX: "end",
            originY: "center",
            overlayX: "start",
            overlayY: "center",
            offsetX: 5,
          },
        ];
      }
    }
    return result;
  }