This commit is contained in:
libccy 2017-03-25 12:58:06 +08:00
parent 9d37e3f361
commit c892dd60b4
1 changed files with 28 additions and 15 deletions

View File

@ -5263,10 +5263,21 @@
this.style.backgroundImage='url("'+lib.assetURL+img+'")';
},
HTMLDivElement.prototype.listen=function(func){
this.addEventListener(lib.config.touchscreen?'touchend':'click',function(e){
if(_status.dragged) return;
if(lib.config.touchscreen){
this.addEventListener('touchend',function(e){
if(!_status.dragged){
func.call(this,e);
})
}
});
this.addEventListener('click',function(e){
if(!_status.touchconfirmed){
func.call(this,e);
}
});
}
else{
this.addEventListener('click',func);
}
return this;
};
HTMLDivElement.prototype.listenTransition=function(func,time){
@ -6148,15 +6159,16 @@
}
if(!lib.config.touchscreen){
document.addEventListener('mousewheel',ui.click.windowmousewheel,{passive:true});
document.onmousemove=ui.click.windowmousemove;
document.onmousedown=ui.click.windowmousedown;
document.onmouseup=ui.click.windowmouseup;
document.oncontextmenu=ui.click.right;
document.addEventListener('mousemove',ui.click.windowmousemove);
document.addEventListener('mousedown',ui.click.windowmousedown);
document.addEventListener('mouseup',ui.click.windowmouseup);
document.addEventListener('contextmenu',ui.click.right);
}
else{
document.ontouchstart=ui.click.windowtouchstart;
document.ontouchend=ui.click.windowtouchend;
document.ontouchmove=ui.click.windowtouchmove;
document.addEventListener('touchstart',ui.click.touchconfirm);
document.addEventListener('touchstart',ui.click.windowtouchstart);
document.addEventListener('touchend',ui.click.windowtouchend);
document.addEventListener('touchmove',ui.click.windowtouchmove);
}
if(!lib.device&&!lib.node){
window.onbeforeunload=function(){
@ -33430,10 +33442,7 @@
var node=ui.create.div(right?ui.system2:ui.system1);
node.innerHTML=str;
if(func){
node.addEventListener(lib.config.touchscreen?'touchend':'click',function(e){
if(_status.dragged) return;
func.call(this,e);
});
node.listen(func);
}
if(lib.config.button_press){
node.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',function(e){
@ -34660,6 +34669,10 @@
if(_status.dragged) return;
game.swapPlayer(this.link);
},
touchconfirm:function(){
_status.touchconfirmed=true;
document.removeEventListener('touchstart',ui.click.touchconfirm);
},
windowtouchstart:function(e){
if(window.inSplash) return;
if(e.touches[0]&&lib.config.swipe&&e.touches.length<2){