我能以某种方式检测 Angular cdk overlay 何时更改其位置吗?

Can I somehow detect when Angular cdk overlay changes it's position?

我有 Angular CDK Overlay 弹出窗口,当我向下滚动页面时,叠加层会向上移动(因为它有重新定位滚动策略)。

当叠加层向上或向下移动时,我能否以某种方式触发事件?

当我这样做时,我能够从覆盖参考配置访问更改。它看起来像这样:

export class MyClass {
  constructor(private overlayRef: OverlayRef) {}

  ngOnInit() {
    const config = this.overlayRef.getConfig();
    // positionChanges is private so this bypasses the error
    const changes = (config.positionStrategy as any)['positionChanges']

    changes.subscribe((change: ConnectedOverlayPositionChange) => {
      // Do something when the position changes
    });
  }
}