diff --git a/game/game.js b/game/game.js index 32f757d2a..01fa8ba29 100644 --- a/game/game.js +++ b/game/game.js @@ -62,7 +62,7 @@ listenEnd:function(node){ if(!node._listeningEnd){ node._listeningEnd=true; - node.addEventListener('webkitTransitionEnd',function(){ + node.listenTransition(function(){ delete node._listeningEnd; if(node._onEndMoveDelete){ node.moveDelete(node._onEndMoveDelete); @@ -3947,21 +3947,17 @@ }) return this; }; - HTMLDivElement.prototype.listenTransition=function(func){ - if(!Array.isArray(this._transitionlist)){ - this._transitionList=[]; - } - var id=get.id(); + HTMLDivElement.prototype.listenTransition=function(func,time){ var that=this; + var done=false; var callback=function(){ - if(that._transitionList.contains(id)){ - that._transitionList.remove(id); + if(!done){ func.call(that); + done=true; } }; - this._transitionList.push(id); this.addEventListener('webkitTransitionEnd',callback); - setTimeout(callback,1000); + setTimeout(callback,time||1000); }; HTMLDivElement.prototype.setPosition=function(){ var position; @@ -5224,7 +5220,6 @@ if(!mode[lib.config.mode]){ window.inSplash=true; var clickedNode=false; - var proceeded=false; var clickNode=function(){ if(clickedNode) return; this.classList.add('clicked'); @@ -5234,13 +5229,9 @@ splash.delete(1000); delete window.inSplash; - var proceed2=function(){ - if(proceeded) return; - proceeded=true; + this.listenTransition(function(){ lib.init.js(lib.assetURL+'mode',lib.config.mode,proceed); - }; - this.addEventListener('webkitTransitionEnd',proceed2); - setTimeout(proceed2,500); + },500); } var downNode=function(){ this.classList.add('glow'); @@ -8352,7 +8343,7 @@ if(lib.config.sync_speed&&cards[0]&&cards[0].clone){ var waitingForTransition=get.time(); event.waitingForTransition=waitingForTransition; - cards[0].clone.addEventListener('webkitTransitionEnd',function(){ + cards[0].clone.listenTransition(function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } @@ -8592,7 +8583,7 @@ if(lib.config.sync_speed&&cards[0]&&cards[0].clone){ var waitingForTransition=get.time(); event.waitingForTransition=waitingForTransition; - cards[0].clone.addEventListener('webkitTransitionEnd',function(){ + cards[0].clone.listenTransition(function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } @@ -8817,7 +8808,7 @@ if(event.delay!=false){ var waitingForTransition=get.time(); event.waitingForTransition=waitingForTransition; - cards[0].clone.addEventListener('webkitTransitionEnd',function(){ + cards[0].clone.listenTransition(function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } @@ -8828,7 +8819,7 @@ delete event.getParent().discardTransition; var waitingForTransition=get.time(); event.getParent().waitingForTransition=waitingForTransition; - cards[0].clone.addEventListener('webkitTransitionEnd',function(){ + cards[0].clone.listenTransition(function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } @@ -13231,7 +13222,7 @@ } node.show(); - node.addEventListener('webkitTransitionEnd',function(){ + node.listenTransition(function(){ node.style.transitionDuration='0.5s'; ui.refresh(node); node.delete(); @@ -13297,10 +13288,10 @@ node1.style.transform=''; node1.removeEventListener('webkitTransitionEnd',onEnd); } - node1.addEventListener('webkitTransitionEnd',onEnd); + node1.listenTransition(onEnd); },300); }; - node1.addEventListener('webkitTransitionEnd',onEnd01); + node1.listenTransition(onEnd01); setTimeout(function(){ var left0=-targets.length*52-(targets.length-1)*8; @@ -13345,10 +13336,10 @@ node2.style.transform=''; node2.removeEventListener('webkitTransitionEnd',onEnd); } - node2.addEventListener('webkitTransitionEnd',onEnd); + node2.listenTransition(onEnd); },200); }; - node2.addEventListener('webkitTransitionEnd',onEnd02); + node2.listenTransition(onEnd02); }(targets[i],cards[i],i)) } },200); @@ -13390,10 +13381,10 @@ node1.style.transform=''; node1.removeEventListener('webkitTransitionEnd',onEnd); } - node1.addEventListener('webkitTransitionEnd',onEnd); + node1.listenTransition(onEnd); },300); }; - node1.addEventListener('webkitTransitionEnd',onEnd01); + node1.listenTransition(onEnd01); setTimeout(function(){ var node2=target.$throwxy2(card2, 'calc(50% + 10px)','calc(50% - 52px)','perspective(600px) rotateY(180deg)',true @@ -13425,10 +13416,10 @@ node2.style.transform=''; node2.removeEventListener('webkitTransitionEnd',onEnd); } - node2.addEventListener('webkitTransitionEnd',onEnd); + node2.listenTransition(onEnd); },200); }; - node2.addEventListener('webkitTransitionEnd',onEnd02); + node2.listenTransition(onEnd02); },200); }, $throw:function(card,time,init){ @@ -13847,7 +13838,7 @@ // node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)'; // node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)'; - node.addEventListener('webkitTransitionEnd',function(){ + node.listenTransition(function(){ var dx=player.offsetLeft+player.offsetWidth/2-52-node.offsetLeft; var dy=player.offsetTop+player.offsetHeight/2-52-node.offsetTop; if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){ @@ -14237,7 +14228,7 @@ this.appendChild(node); ui.refresh(node); node.classList.add('damageadded'); - node.addEventListener('webkitTransitionEnd',function(){ + node.listenTransition(function(){ setTimeout(function(){ node.delete(); },200); @@ -14363,7 +14354,7 @@ if(lib.config.low_performance&&card&&card.clone){ var waitingForTransition=get.time(); _status.waitingForTransition=waitingForTransition; - card.clone.addEventListener('webkitTransitionEnd',function(){ + card.clone.listenTransition(function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } @@ -19320,7 +19311,7 @@ ui.refresh(node); node.show(); node.style.transform='rotate('+(-deg)+'deg) scaleY(1)'; - node.addEventListener('webkitTransitionEnd',function(){ + node.listenTransition(function(){ setTimeout(function(){ if(node.classList.contains('removing')) return; node.delete(); diff --git a/layout/default/layout.css b/layout/default/layout.css index 4841cc2a9..6deb71c99 100644 --- a/layout/default/layout.css +++ b/layout/default/layout.css @@ -743,9 +743,10 @@ table { #arena:not(.chess):not(.mobile)>#autonode { display: none } -#arena:not(.auto)>#autonode { +#arena:not(.auto)>#autonode, +#autonode.hidden { opacity: 0; - pointer-events: none + pointer-events: none; } #arena.auto #me .card{ opacity: 0.5 diff --git a/mode/chess.js b/mode/chess.js index 8f1a3e72c..494ebf543 100644 --- a/mode/chess.js +++ b/mode/chess.js @@ -2263,8 +2263,7 @@ mode.chess={ },150); } }; - // node.addEventListener('transitionEnd',onEnd); - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); }; var zhaomu2=function(){ if(_status.qianfan||_status.kaibao) return; @@ -2993,8 +2992,7 @@ mode.chess={ },150); } }; - // node.addEventListener('transitionEnd',onEnd); - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); }; setTimeout(function(){ nodes[0].delete(); diff --git a/mode/story.js b/mode/story.js index 8d497a7db..fc3b99cd1 100644 --- a/mode/story.js +++ b/mode/story.js @@ -592,7 +592,7 @@ mode.story={ node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(180deg) scale(1)' }; - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); } ui.click.scene=clickScene; var restoreScene=function(node,forced){ @@ -618,7 +618,7 @@ mode.story={ node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)' }; - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); } ui.click.scene2=restoreScene; var switchScene=function(){ diff --git a/mode/tafang.js b/mode/tafang.js index b72f95496..e77f05216 100644 --- a/mode/tafang.js +++ b/mode/tafang.js @@ -905,7 +905,7 @@ mode.tafang={ node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(180deg) scale(1)' }; - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); } ui.click.scene=clickScene; var restoreScene=function(node,forced){ @@ -930,7 +930,7 @@ mode.tafang={ node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)' }; - node.addEventListener('webkitTransitionEnd',onEnd); + node.listenTransition(onEnd); } ui.click.scene2=restoreScene; var createScene=function(name){