![](/img/trans.png)
[英]How to display a floating button above other components in react native?
[英]ExtJS floating panel appeared in a wrong place because other components above it takes time to display
我先显示面板A,然后在其下方显示面板B。 面板A使用JSONP来获取数据,并显示在商店负载的回调函数中。 因此显示大约需要1秒钟。
我将浮动面板C与面板B对齐。浮动面板C是这样的:
Ext.define('MyApp.view.MyWindow', {
extend: 'Ext.window.Window',
height: 334,
width: 540,
layout: {
type: 'border'
},
title: 'Run report',
initComponent: function () {
var me = this;
floatingpanel = Ext.create('Ext.panel.Panel', {
html: "something",
width: 100,
height: 50,
floating: true,
listeners: {
'show': {
fn: function () {
floatingpanel.alignTo(PanelB, "tr-tr", [left, top]);
},
scope: floatingpanel,
//delay: 1000, // to wait for other component to show
single: true
}
}
});
Ext.applyIf(me, {
items: [{
xtype: 'form',
bodyPadding: 10,
region: 'center'
}]
});
me.callParent(arguments);
}
});
然后调用floatingpanel.show()
来显示面板。 但是,它没有添加到面板B中。
如果我不使用如上所述的delay
,则浮动面板C出现在面板A中的某个位置,因为当浮动面板即将显示时,面板A尚不可用。 所以我把“延迟”。
1秒后,面板A显示为回调成功。 现在,浮动面板C在正确的位置与面板B对齐。
由于回调函数可能会在1秒钟或10秒钟内成功完成,因此很难选择延迟时间。
还有其他解决办法吗? 我尝试使用doConstrain将浮动面板C附加到面板B: floatingpanel.doConstrain(PanelB)
。 但是不知何故,它不起作用。
initComponent: function () {
var me = this;
floatingpanel = Ext.create('Ext.panel.Panel', {
html: "something",
width: 100,
height: 50,
// floating: true,
listeners: {
'show': {
fn: function () {
me.alignTo(PanelB, "tr-tr", [left, top]);
},
scope: floatingpanel,
//delay: 1000, // to wait for other component to show
single: true
}
}
});
Ext.applyIf(me, {
items: [{
xtype: 'form',
bodyPadding: 10,
region: 'center'
}]
});
me.callParent(arguments);
}
请使用上面的代码代替..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.