[英]Ext Window is not coming in center after browser resizing
瀏覽器調整大小后,我的窗口沒有出現在中心。 調整瀏覽器大小時,窗口的一半消失了
var Win,
ViewPort = Ext.getBody(),
winWidth = ViewPort.getWidth(),
winHeight = ViewPort.getHeight();
Win = new Ext.IframeWindow({
id: 'H1',
modal: true,
resizable: true,
title: 'H1',
closable: true,
constrain : true,
});
Win.width = (winWidth / 100) * 90,
Win.height = (winHeight / 100) * 90,
當我按一定比例給出寬度和高度時
Win.width = '80%',
Win.height = '90%',
在這種情況下會很好。 但由於窗口上的數據和布局調整,我不希望這樣做。
您可以嘗試以下代碼片段:-
通過使用窗口ID:
Ext.getBody().el.dom.onresize = function() { if(Ext.getCmp('your_window_id')) { Ext.getCmp('your_window_id').center(); } }
通過使用窗口itemId:
Ext.getBody().el.dom.onresize = function() { if(Ext.ComponentQuery.query('#your_window_id')[0]) { Ext.ComponentQuery.query('#your_window_id')[0].center(); } }
希望這對您有所幫助:)
在這種情況下,您需要獲取調整大小后的瀏覽器的新視口(按照您的代碼),然后必須設置新的寬度和高度才能獲勝。
這是您可以使用的方法
window.onresize=function(obj){
var viewport = Ext.getBody();
var H1Window = Ext.getCmp('H1');
var H1WindowWidth = viewport.getWidth();
var H1WindowHeight = viewport.getHeight();
if(H1Window){
H1Window.setWidth((bioMarkerWindowWidth / 100) * 90);
H1Window.setHeight((bioMarkerWindowHeight / 100) * 90);
}
}
看一下anchorTo方法。 這應該工作:
win.anchorTo(Ext.getBody(), win.defaultAlign);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.