我在我的一个视图中使用卡片布局。卡片布局中有 6 张卡片。我使用图像点击在卡片之间切换。由于卡片从一张切换到另一张需要一些时间,因此我需要在切换时添加加载遮罩,即,当我单击图像时,加载遮罩应该出现,并且一旦渲染下一张卡片,加载遮罩就应该被移除. 任何人都可以建议我解决我面临的加载掩码问题吗?
问问题
703 次
1 回答
1
为什么切换需要时间?是因为商店负载吗?如果是因为商店您可以在 beforeLoad 中显示掩码并在 load 事件中隐藏。像这样的东西:
Ext.define('MyApp.store.MyStore', {
...
myMask: null,
listeners: {
beforeload: function(store, operation, options){
this.myMask = new Ext.LoadMask(Ext.getBody(), {
cls: "loader",
msg: "Loading..."
});
this.myMask.show();
},
load: function(store, records, success, operation, options){
this.myMask.hide();
}
});
我不知道你是如何做这个应用程序的。但是如果这没有帮助,您也可以创建一个带有蒙版的对象并在单击后始终显示,您可以隐藏在视图的“绘制”事件中:http: //docs.sencha.com/touch/2.2。 0/#!/api/Ext.navigation.View-event-painted
[编辑]
因此,您可以在加载时将 Store 覆盖为 aways show de mask。这里的代码:
Ext.define('MyAppName.store.App', {
override: 'Ext.data.Store',
timeOut: null,
// List of stores that run in background (dont show mask)
backgroundStores: [
'StoreOne',
'StoreTwo'
],
constructor: function(config){
this.callParent(arguments);
this.on('beforeload', 'onBeforeLoad', this);
this.on('load', 'onAfterLoad', this);
},
onBeforeLoad: function(store, operation, options){
// runing in background
if(this.backgroundStores.indexOf(store._storeId) != -1){
return;
}
var re = new RegExp("MyAppName");
// Fix a feature of sencha that do some request from store off app
if(store._model == undefined || store._model.$className == undefined || re.exec(store._model.$className) == null){
return;
}
MyAppName.app.config.mask.show(); // this is my mask defined in App.js
// timout
this.timeOut = setTimeout(function() {
Ext.Msg.alert("Erro", "Could not connect to the server");
MyAppName.app.config.mask.hide();
}, 30000);
},
onAfterLoad: function(store, records, success, operation, options){
if(this.backgroundStores.indexOf(store._storeId) != -1){
return;
}
var re = new RegExp("MyAppName");
if(store._model == undefined || store._model.$className == undefined || re.exec(store._model.$className) == null){
return;
}
MyAppName.app.config.mask.hide();
window.clearInterval(this.timeOut);
}});
于 2013-04-16T17:51:23.497 回答