If I want to display the load mask on tab panel between tab change in Sencha Touch 2. What would be the right approach ?
I want to show a loading mask when a tab button get pressed, and hide it as soon as the panel is displayed correctly.
Ext.define("MyProject.view.Main", {
extend: 'Ext.tab.Panel',
requires: [
'Ext.TitleBar','Ext.MessageBox'
],
config: {
fullscreen: true,
tabBarPosition: 'bottom',
layout: {
type: 'card',
animation: 'fade' //false, fade, flip, pop, scroll, slide
},
items: [
{
xtype: 'panel1',
masked: {
xtype:'loadmask',
message:'Chargement...'
},
listeners: {
painted: function(container, value, oldValue, eOpts) {
//Ext.Msg.alert('Test', 'painted');
this.setMasked(false);
}
}
},
{
xtype: 'panel2',
masked: {
xtype:'loadmask',
message:'Chargement...'
},
listeners: {
painted: function(container, value, oldValue, eOpts) {
//Ext.Msg.alert('Test', 'painted');
this.setMasked(false);
}
}
},
Problem is that the event is trapped, but since I show the mask on the child item creation, the mask isn't showing. I'd need an event like onActiveItemChanged but fired BEFORE and not AFTER. Anyone has an idea on how could I implement that ?
UPDATE : I almost made it with addition of code found on Sencha Touch forum. Added at main view (tab panel) level :
listeners: {
delegate : 'tabbar > tab',
tap : function() {
Ext.Viewport.setMasked({ xtype: 'loadmask', message: 'Loading...', indicator:true});
}
}
And then, on each item I add in the tab pannel :
xtype: 'panel1',
listeners: {
painted: function(container, value, oldValue, eOpts) {
Ext.Viewport.setMask('false');
}
}
But the problem now is that since I override the default "tap" event listener, it always stays on the same tab and never display the others even if we click on a button. Yet, the new tab's painted event gets fired.