PDA

View Full Version : PullToRefresh - strange behaviour



s.t.a.s
5 Apr 2012, 5:05 AM
I've tried to add PullToRefresh functionality in my list (with auto paging but it's another thread). All is Ok but it behaves very strange. As I remember, in iOS function for reloading data in the list (there it's UITableView component) calls when you release list and PullToRefresh animation finishes only after data was fully loaded.
But I see that in Sencha Touch 2.0 PullToRefresh animation is a fake because refreshFn is called when animation has already finished and user thinks that all data has been refreshed.
May be it's a bug, I don't know exactly, but as I see problem (may be) in implementation of "loadStore" method in PullRefresh.js:


loadStore: function() {
var me = this,
list = me.getList(),
scroller = list.getScrollable().getScroller();


me.setViewState('loading');
me.isReleased = false;


Ext.defer(function() {
scroller.on({
scrollend: function() {
if (me.getRefreshFn()) {
me.getRefreshFn().call(me, me);
} else {
me.fetchLatest();
}
me.resetRefreshState();
},
delay: 100,
single: true,
scope: me
});
scroller.minPosition.y = 0;
scroller.scrollTo(null, 0, true);
}, 500, me);


}


For what this "defer" - I don't know. If to replace this "defer"-part, all is OK and refreshFn will be calling before finish of animation. Here is my variant:



loadStore: function() {
var me = this,
list = me.getList(),
scroller = list.getScrollable().getScroller();


me.setViewState('loading');
me.isReleased = false;


if (me.getRefreshFn()) {
me.getRefreshFn().call(me, me);
} else {
me.fetchLatest();
}
me.resetRefreshState();
scroller.minPosition.y = 0;
scroller.scrollTo(null, 0, true);
}


What do you think, it is correct?

s.t.a.s
6 Apr 2012, 2:38 AM
Any ideas?