mui.ready后主动触发下拉刷新,导致pulldownRefresh回调执行两次
分析的过程如下
页面中有以下代码
mui.init({
pullRefresh: {
container: '#refreshArea',
down: {
callback: pulldownRefresh
}
}
});
function pulldownRefresh() {
norma.info('pull down Refreshing');
}
mui.plusReady(function() {
norma.info('list plusReady ok');
setTimeout(function() {
//此处主动触发
mui('#refreshArea').pullRefresh().pulldownLoading();
},
1000);
});
接下来跳到mui.js代码段一
pulldownLoading: function() {
a.plusReady(function() {
plus.webview.currentWebview().setBounce({
offset: {
//注意:如果这里非零值会触发一个dragBounce事件,请看下面mui.js代码段二
top: this.options.down.height + "px"
}
})
}.bind(this));
var b = a.options.pullRefresh.down.callback;
//这里执行了一次pulldownRefresh回调
b && b.call(this)
}
接下来在跳到mui.js代码段二
_initPulldownRefreshEvent: function() {
var b = this;
b.topPocket && b.options.webviewId && a.plusReady(function() {
var a = plus.webview.getWebviewById(b.options.webviewId);
if (a) {
b.options.webview = a;
var c = b.options.down,
d = c.height;
a.addEventListener("dragBounce", function(d) {
//注意:事实上这里的b.pulldown在第一次到达时并未定义,
//然后执行b._initPulldownRefresh(), d.status,此时之后b.pulldown才定义了
//进入case dragEndAfterChangeOffset
switch (b.pulldown ? b.pullPocket.classList.add(f) : b._initPulldownRefresh(), d.status) {
case "beforeChangeOffset":
b._setCaption(c.contentdown);
break;
case "afterChangeOffset":
b._setCaption(c.contentover);
break;
case "dragEndAfterChangeOffset":{
//这里又再执行了一次pullRefresh callback
a.evalJS("mui&&mui.options.pullRefresh.down.callback()"), b._setCaption(c.contentrefresh)
}
}
}, !1), a.setBounce({
position: {
top: 2 * d + "px"
},
changeoffset: {
top: d + "px"
}
})
}
})
}
所以执行了两次pulldownRefresh回调
有什么解决方案么??
是BUG吗?,还是使用方法不对???
附件:BUG重现代码压缩包