我在其中一个视图中使用了卡片布局。卡片布局中有6张卡片。我使用图像点击在卡片之间切换。由于卡需要一段时间从一个切换到另一个,我需要在切换时添加一个加载掩码,即,当我点击图像时,应该出现加载掩码,一旦渲染下一张卡,就应该删除加载掩码。有谁能建议我解决我面临的装载面具问题?
答案 0 :(得分: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
[EDITED]
所以你可以在加载中覆盖Store to 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);
}});