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