[英]Dialog position changes on orientation change in Ext JS
我想在屏幕中央显示 Ext.Dialog,这是通过使用 showBy 方法实现的,如下所示。
dialog.showBy(view.lookupReference('btn'), 'c-c');
它工作正常。 但是,当我更改 android 设备对话框中的方向时,它的位置会发生变化,并且只有一半的对话框可见。
我尝试了以下步骤。
无法通过上述任何方式实现,任何实现此目标的提示。 我正在使用 Ext JS 6.7
我会从 ExtJS 6.6 给你建议,小心它可以从 6.7 更新。
不久前我遇到了同样的问题,我发现了这个事件: https : //docs.sencha.com/extjs/6.6.0/modern/Ext.viewport.Default.html#event-orientationchange
好的,它仅在视口上,但我没有找到任何其他解决方案。
其实我做这样的事情:
Ext.Viewport.on('orientationchange', this.getController().OnOrientationChange, this.getController());
OnOrientationChange: function(viewport, orientation) {
viewport.mask();
var actualWidth = window.innerWidth;
var actualHeight = window.innerHeight;
// Orientation check due to latence can fake orientation result
if (orientation === "landscape") {
if (actualWidth < actualHeight) {
Ext.defer(this.OnOrientationChange, 100, this, [viewport, orientation]);
return;
}
}
else if (orientation === "portrait") {
if (actualWidth > actualHeight) {
Ext.defer(this.OnOrientationChange, 100, this, [viewport, orientation]);
return;
}
}
viewport.unmask();
// Xtype liste of object would by notified
var objXtypeList = ['dataview', 'carousel', 'signingarea'];
for (var i = 0, max = objXtypeList.length; i < max; i++) {
var objXtype = objXtypeList[i];
var objList = viewport.query(objXtype);
for (var j = 0, maxJ = objList.length; j < maxJ; j++) {
var obj = objList[j];
if (Ext.isFunction(obj.OnOrientationChange)) {
Ext.defer(obj.OnOrientationChange, 50, obj, [orientation]);
}
}
}
}
OnOrientationChange: function(orientation) {
// The way the object should react
}
我不知道这是否是最正确的方法,但它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.