|
发表于 2016-11-9 16:54:36
|
显示全部楼层
1 白屏问题
原因:返回按钮点击过快导致的!而不是重复点击返回按钮导致的!
处理:所有关闭操作增加延迟300-500ms;
修改UI2/system/components/justep/common/utils.js,修改attachDoubleClickExitApp方法;
attachDoubleClickExitApp:function(conditionFn){
var exitDtd = $.Deferred();
if(this.attached === true){
exitDtd.reject();
}else{
this.attached = true;
document.addEventListener("deviceready", function() {
var exitAppTicker = 0;
var _closing = false; // 正在关闭状态
var listener = function(){
if(conditionFn()){
if(exitAppTicker === 0){
exitAppTicker++;
var msg = $('<div style="display: none;z-index:99999;position: fixed;width: 100%;bottom: 25px;text-align: center;"><span style="font-size:18px;border-radius: 3px;padding: 7px;background-color: #383838;color: #F0F0F0;">再按一次退出应用</span></div>').appendTo('body');
msg.fadeIn(400).delay(2000).fadeOut(400,function(){
exitAppTicker = 0;
msg.remove();
});
}else if(exitAppTicker == 1){
exitDtd.resolve();
navigator.app.exitApp();
}
}else{
if($('html').hasClass("x-focus-in")){
$('html').removeClass("x-focus-in");
} else {
//history.back();
if (!_closing) {
_closing = true;
//console.log("attachDoubleClickExitApp: closePage begin");
try {
window.setTimeout(function() {
justep.Shell.closePage();
_closing = false;
//console.log("attachDoubleClickExitApp: closePage end");
}, 300);
} catch(error) {
_closing = false;
}
}
//else {
// console.log("attachDoubleClickExitApp: is closing!!!");
//}
}
}
};
document.addEventListener('backbutton', listener, false);
$(window).on('beforeunload', function(){
document.removeEventListener('backbutton', listener, false);
});
}, false);
}
return exitDtd.promise();
},
修改UI2/system/lib/base/modelBase.js,增加delayedClose方法,在返回按钮时候调用;
_closing : false, // 关闭状态
delayedClose: function() { // 延迟关闭
if (!this._closing) {
this._closing = true;
var self = this;
window.setTimeout(function() {
//console.log("close window.");
self.owner.close();
_closing = false;
}, 300);
}
//else {
// console.log("repeat close window.");
//}
},
2 cannot read property 'trigger' of null
现象:在滑动组件Carousel自动滑动的同时点击关闭报错!
原因:窗口被关闭后执行了页面切换效果;具体是contents.js的slide方法出错!595行;
处理:contents.js的slide方法中的左右滑动效果代码修改:
setTimeout(function () {
if (!that.$el) { // TODO 修正:窗口关闭后,滑动效果还未做完,会出错!
//console.log("trigger not exists");
return ;
}
that.$el.trigger('slide.container');
that.getModel().fireEvent("onResize",{source:this});
that.addRouteItem($next);
that.fireEvent('onActiveChanged', {source : this, to: pos, from: currentPos, type: type});
fn && fn();
if(toContent && toContent.fireEvent)
toContent.fireEvent('onActive', {source : that, index: pos});
}, 0);
3 cannot read property 'find' of null
现象:快速点击返回按钮关闭了页面后,然后contents组件初始化未完成时候报错!
原因:使用contents组件的页面,当再次回退到该页面就会触发contents组件的onActiveChanged事件,在该事件未执行完但是页面被关闭会出错;具体是contents.js的_optimizePerformance方法出错!93行;
处理:修改代码
_optimizePerformance:function(className){
//console.log("contents> _optimizePerformance"); // TODOEBUG
if (!this.$el) { // TODO 修正:窗口关闭后,初始化会出错!
//console.log("find not exists");
return ;
}
var $contents = this.$el.find('>.x-contents-content');
4 页面已经被关闭 编码:JUSTEP230112
原因:页面关闭后再次关闭;
处理:所有页面保证只关闭一次;关闭时候增加锁,保证只有一个关闭操作被执行;白屏问题解决,该问题自动消失! |
|