PDA

View Full Version : An Override to disable/enable the PullRefresh plugin



Bunchofstring
7 Dec 2012, 2:24 PM
My only gripe with this otherwise sweet plugin is that disabling it has no effect. This is common with plugins (including some that I've written), but I thought it might be good if it could be toggled on and off. In my latest project, I accomplish this with the following override:

Ext.define('Ext.plugin.PullRefreshToggleable',{
override:'Ext.plugin.PullRefresh',

//Hide/show the visual component based on if the plugin is disabled/enabled
setDisabled:function(isHidden){
this.setHidden(isHidden);
this.callParent(arguments);
},

//Only let handlers do their thing if the plugin is enabled
onScrollChange:function(){
if(!this.isDisabled()){
this.callParent(arguments);
}
},
onBounceTop:function(){
if(!this.isDisabled()){
this.callParent(arguments);
}
},
onScrollerDragEnd:function(){
if(!this.isDisabled()){
this.callParent(arguments);
}
}
});
This way, a developer can use plugin.setDisabled() as you might expect. plugin.disable() and plugin.enable() should work too, but I haven't tested that. If people like it, maybe someone could add it to the *official* code?

mitchellsimoens
9 Dec 2012, 7:48 AM
Thanks for the contribution.