extjs - 相对于约束容器的中心和顶部定位受约束窗口

标签 extjs extjs4 extjs4.2

我们需要相对于容器的顶部和中心定位一个受约束的窗口(如 example )。但在配置中我们只找到了 x 和 y,这需要计算每个文档更改的中心。

没有其他方法可以存档吗?

最佳答案

你可以使用

alignTo() docs

alignTo(element, [position], [offsets], [animate] )

Aligns the element with another element relative to the specified anchor points. If the other element is the document it aligns it to the viewport. The position parameter is optional, and can be specified in any one of the following formats:

Blank: Defaults to aligning the element's top-left corner to the target's bottom-left corner ("tl-bl"). One anchor (deprecated): The passed anchor position is used as the target element's anchor point. The element being aligned will position its top-left corner (tl) to that point. This method has been deprecated in favor of the newer two anchor syntax below. Two anchors: If two values from the table below are passed separated by a dash, the first value is used as the element's anchor point, and the second value is used as the target's anchor point. In addition to the anchor points, the position parameter also supports the "?" character. If "?" is passed at the end of the position string, the element will attempt to align as specified, but the position will be adjusted to constrain to the viewport if necessary. Note that the element being aligned might be swapped to align to a different position than that specified in order to enforce the viewport constraints. Following are all of the supported anchor positions... for more info see the docs

anchorTo() docs

anchorTo(element, [position], [offsets], [animate], [monitorScroll], [callback])

Anchors an element to another element and realigns it when the window is resized.

编辑

如果您在早期状态下执行此操作,定位可能会失败。我会尝试使用 Ext.Function.createDelayed 来添加对齐延迟。尝试使用 10-50 之间的延迟。

示例:

Ext.Function.createDelayed(windowRef.anchorTo,50)(Ext.getBody(),'t-t',[-100,0]);

关于extjs - 相对于约束容器的中心和顶部定位受约束窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20074598/

相关文章:

Extjs 将网格面板添加到 Accordion 内容

grid - extjs 网格 - 如何使列宽 100%

javascript - ExtJs 4 上的 TreeNode 单击事件

extjs - 使用 extjs 4 的相对路径

javascript - 我怎样才能让 Ext JS 窗体和它的工具栏之间的边距消失?

extjs4 - 如何在Extjs 4面板中添加Amchart图表?

javascript - EXTJS 在 Ext.window.Window 中显示 View

javascript - 组合框不会显示加载的商店数据

extjs - 如何将(现有)面板添加到 Tree ItemClick 上的区域中

javascript - 获取ExtJS中数据存储的某个值