0

我想将具有所有者元素的 wj-popup 居中到所有者的中心。这意味着所有者元素的中心必须是弹出窗口的水平中心。我没有找到任何有关此的信息(仅关于没有所有者元素的弹出窗口,默认情况下居中)。我怎样才能做到这一点?

在此处输入图像描述

4

1 回答 1

0

当前版本的 wijmo5 (v5.20162.211) 不允许这样做,但这里描述了一些解决方法: http ://wijmo.com/topic/how-to-center-wj-popup-with-owner-element-by -its-owner-2/#post-79683

另外,由于我使用了一些不允许此工作的 npm ui 组件和 angular2,因此我必须捕获鼠标事件并像这样修改函数:

setPopupPosition(event:any, element:any) {
    let mouseX = event.clientX;
    let popupWidth = element.popup.hostElement.clientWidth;
    let popupPosition = mouseX - popupWidth / 2;
    element.popup.hostElement.style.left = (popupPosition < 0 ? 0 : popupPosition) + "px";
}

element.popup - 在弹出组件中使用弹出的@ViewChild 声明。

和 HTML:

<button(click)="setPopupPosition($event, profileFilterPopover)">ButtonName</button>
<profile-filter-popover #profileFilterPopover [owner]="showProfileFilterButton" [reportId]="reportId"
                                [cubeId]="cubeId"></profile-filter-popover>

其中 profileFilterPopover 是弹出窗口的 id

于 2016-10-05T15:25:02.290 回答