gpt4 book ai didi

angular - 在 Angular cdk 叠加层上获取事件位置?

转载 作者:行者123 更新时间:2023-12-02 10:00:09 24 4
gpt4 key购买 nike

Is there a way to get in the attached component to an overlay the active position ? For exaple I say to a tooltip to open above but this cannot be done and the overlay will open it below. I want to add an arrow pointing to my element from the tooltip and I need to now if the overlay is above/below the element to position the arrow correctly

最佳答案

ConnectedPositionStrategy(已弃用)具有 onPositionChange 属性,并且FlexibleConnectedPositionStrategy 具有 positionChanges 属性,在创建覆盖层之前我们无法订阅此可观察量,因此,解决方案是在创建覆盖层之后订阅:

const positionStrategy = this.overlay
.position()
.flexibleConnectedTo(this.selectHeader)
.withPositions([
{
originX: 'start',
originY: 'bottom',
overlayX: 'start',
overlayY: 'top',
},
{
originX: 'start',
originY: 'top',
overlayX: 'start',
overlayY: 'bottom',
},
]);
this.panelOverlay = this.overlay.create({positionStrategy});
positionStrategy.positionChanges.subscribe(pos => console.log(pos));

关于angular - 在 Angular cdk 叠加层上获取事件位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51457951/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com