【问题标题】:Angular Material Dialog change position on window scrollAngular Material Dialog 在窗口滚动时更改位置
【发布时间】:2019-08-05 19:50:23
【问题描述】:

我有一个来自材料的对话框,我需要他始终与某个领域相关。我已经完成了他从现场相对开始,但是当我向下滚动窗口(我需要它滚动)时,对话框出现并且不重新定位,或者保持固定在初始位置

我试图了解来自 cdk 的 scrollstrategy 是否适用于选项重新定位,但我无法使其工作。

并且不要展示它是如何工作的

const dialogRef = this.dialog.open(FilterProspectsComponent, {
            width: '650px',
            // position:{
            //  top: '295px',
            //  left: '180px'
            // },
            autoFocus: false,
            scrollStrategy: this.overlay.scrollStrategies.reposition(),
            data:{}
        });
        let referenceInput = document.querySelector('input.form-filter');
        // dialogRef.updatePosition({ top: `${referenceInput.getBoundingClientRect().top+45}px`, left: `${referenceInput.getBoundingClientRect().left}px` });
        dialogRef.afterClosed().subscribe(result => {
          console.log('The dialog was closed');
        });

我希望对话框保持不变

【问题讨论】:

    标签: angular angular-material angular8


    【解决方案1】:

    所以,我是用app文件夹中的styles.scss做的,只是去掉了cdk覆盖容器中的固定位置

    .cdk-overlay-container {
       position: unset;
    }
    

    所以,我很快就会提出一个关于滚动策略重新定位的问题,它不起作用或者我没有完全理解它的功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-26
      • 1970-01-01
      • 2019-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-05
      • 2013-08-17
      相关资源
      最近更新 更多