This commit is contained in:
libccy 2017-02-11 09:33:02 +08:00
parent 146bae518f
commit d398bb9041
5 changed files with 34 additions and 44 deletions

View File

@ -62,7 +62,7 @@
listenEnd:function(node){ listenEnd:function(node){
if(!node._listeningEnd){ if(!node._listeningEnd){
node._listeningEnd=true; node._listeningEnd=true;
node.addEventListener('webkitTransitionEnd',function(){ node.listenTransition(function(){
delete node._listeningEnd; delete node._listeningEnd;
if(node._onEndMoveDelete){ if(node._onEndMoveDelete){
node.moveDelete(node._onEndMoveDelete); node.moveDelete(node._onEndMoveDelete);
@ -3947,21 +3947,17 @@
}) })
return this; return this;
}; };
HTMLDivElement.prototype.listenTransition=function(func){ HTMLDivElement.prototype.listenTransition=function(func,time){
if(!Array.isArray(this._transitionlist)){
this._transitionList=[];
}
var id=get.id();
var that=this; var that=this;
var done=false;
var callback=function(){ var callback=function(){
if(that._transitionList.contains(id)){ if(!done){
that._transitionList.remove(id);
func.call(that); func.call(that);
done=true;
} }
}; };
this._transitionList.push(id);
this.addEventListener('webkitTransitionEnd',callback); this.addEventListener('webkitTransitionEnd',callback);
setTimeout(callback,1000); setTimeout(callback,time||1000);
}; };
HTMLDivElement.prototype.setPosition=function(){ HTMLDivElement.prototype.setPosition=function(){
var position; var position;
@ -5224,7 +5220,6 @@
if(!mode[lib.config.mode]){ if(!mode[lib.config.mode]){
window.inSplash=true; window.inSplash=true;
var clickedNode=false; var clickedNode=false;
var proceeded=false;
var clickNode=function(){ var clickNode=function(){
if(clickedNode) return; if(clickedNode) return;
this.classList.add('clicked'); this.classList.add('clicked');
@ -5234,13 +5229,9 @@
splash.delete(1000); splash.delete(1000);
delete window.inSplash; delete window.inSplash;
var proceed2=function(){ this.listenTransition(function(){
if(proceeded) return;
proceeded=true;
lib.init.js(lib.assetURL+'mode',lib.config.mode,proceed); lib.init.js(lib.assetURL+'mode',lib.config.mode,proceed);
}; },500);
this.addEventListener('webkitTransitionEnd',proceed2);
setTimeout(proceed2,500);
} }
var downNode=function(){ var downNode=function(){
this.classList.add('glow'); this.classList.add('glow');
@ -8352,7 +8343,7 @@
if(lib.config.sync_speed&&cards[0]&&cards[0].clone){ if(lib.config.sync_speed&&cards[0]&&cards[0].clone){
var waitingForTransition=get.time(); var waitingForTransition=get.time();
event.waitingForTransition=waitingForTransition; event.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){ cards[0].clone.listenTransition(function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume(); game.resume();
} }
@ -8592,7 +8583,7 @@
if(lib.config.sync_speed&&cards[0]&&cards[0].clone){ if(lib.config.sync_speed&&cards[0]&&cards[0].clone){
var waitingForTransition=get.time(); var waitingForTransition=get.time();
event.waitingForTransition=waitingForTransition; event.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){ cards[0].clone.listenTransition(function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume(); game.resume();
} }
@ -8817,7 +8808,7 @@
if(event.delay!=false){ if(event.delay!=false){
var waitingForTransition=get.time(); var waitingForTransition=get.time();
event.waitingForTransition=waitingForTransition; event.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){ cards[0].clone.listenTransition(function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume(); game.resume();
} }
@ -8828,7 +8819,7 @@
delete event.getParent().discardTransition; delete event.getParent().discardTransition;
var waitingForTransition=get.time(); var waitingForTransition=get.time();
event.getParent().waitingForTransition=waitingForTransition; event.getParent().waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){ cards[0].clone.listenTransition(function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume(); game.resume();
} }
@ -13231,7 +13222,7 @@
} }
node.show(); node.show();
node.addEventListener('webkitTransitionEnd',function(){ node.listenTransition(function(){
node.style.transitionDuration='0.5s'; node.style.transitionDuration='0.5s';
ui.refresh(node); ui.refresh(node);
node.delete(); node.delete();
@ -13297,10 +13288,10 @@
node1.style.transform=''; node1.style.transform='';
node1.removeEventListener('webkitTransitionEnd',onEnd); node1.removeEventListener('webkitTransitionEnd',onEnd);
} }
node1.addEventListener('webkitTransitionEnd',onEnd); node1.listenTransition(onEnd);
},300); },300);
}; };
node1.addEventListener('webkitTransitionEnd',onEnd01); node1.listenTransition(onEnd01);
setTimeout(function(){ setTimeout(function(){
var left0=-targets.length*52-(targets.length-1)*8; var left0=-targets.length*52-(targets.length-1)*8;
@ -13345,10 +13336,10 @@
node2.style.transform=''; node2.style.transform='';
node2.removeEventListener('webkitTransitionEnd',onEnd); node2.removeEventListener('webkitTransitionEnd',onEnd);
} }
node2.addEventListener('webkitTransitionEnd',onEnd); node2.listenTransition(onEnd);
},200); },200);
}; };
node2.addEventListener('webkitTransitionEnd',onEnd02); node2.listenTransition(onEnd02);
}(targets[i],cards[i],i)) }(targets[i],cards[i],i))
} }
},200); },200);
@ -13390,10 +13381,10 @@
node1.style.transform=''; node1.style.transform='';
node1.removeEventListener('webkitTransitionEnd',onEnd); node1.removeEventListener('webkitTransitionEnd',onEnd);
} }
node1.addEventListener('webkitTransitionEnd',onEnd); node1.listenTransition(onEnd);
},300); },300);
}; };
node1.addEventListener('webkitTransitionEnd',onEnd01); node1.listenTransition(onEnd01);
setTimeout(function(){ setTimeout(function(){
var node2=target.$throwxy2(card2, var node2=target.$throwxy2(card2,
'calc(50% + 10px)','calc(50% - 52px)','perspective(600px) rotateY(180deg)',true 'calc(50% + 10px)','calc(50% - 52px)','perspective(600px) rotateY(180deg)',true
@ -13425,10 +13416,10 @@
node2.style.transform=''; node2.style.transform='';
node2.removeEventListener('webkitTransitionEnd',onEnd); node2.removeEventListener('webkitTransitionEnd',onEnd);
} }
node2.addEventListener('webkitTransitionEnd',onEnd); node2.listenTransition(onEnd);
},200); },200);
}; };
node2.addEventListener('webkitTransitionEnd',onEnd02); node2.listenTransition(onEnd02);
},200); },200);
}, },
$throw:function(card,time,init){ $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.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.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 dx=player.offsetLeft+player.offsetWidth/2-52-node.offsetLeft;
var dy=player.offsetTop+player.offsetHeight/2-52-node.offsetTop; var dy=player.offsetTop+player.offsetHeight/2-52-node.offsetTop;
if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){ if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
@ -14237,7 +14228,7 @@
this.appendChild(node); this.appendChild(node);
ui.refresh(node); ui.refresh(node);
node.classList.add('damageadded'); node.classList.add('damageadded');
node.addEventListener('webkitTransitionEnd',function(){ node.listenTransition(function(){
setTimeout(function(){ setTimeout(function(){
node.delete(); node.delete();
},200); },200);
@ -14363,7 +14354,7 @@
if(lib.config.low_performance&&card&&card.clone){ if(lib.config.low_performance&&card&&card.clone){
var waitingForTransition=get.time(); var waitingForTransition=get.time();
_status.waitingForTransition=waitingForTransition; _status.waitingForTransition=waitingForTransition;
card.clone.addEventListener('webkitTransitionEnd',function(){ card.clone.listenTransition(function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume(); game.resume();
} }
@ -19320,7 +19311,7 @@
ui.refresh(node); ui.refresh(node);
node.show(); node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)'; node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
node.addEventListener('webkitTransitionEnd',function(){ node.listenTransition(function(){
setTimeout(function(){ setTimeout(function(){
if(node.classList.contains('removing')) return; if(node.classList.contains('removing')) return;
node.delete(); node.delete();

View File

@ -743,9 +743,10 @@ table {
#arena:not(.chess):not(.mobile)>#autonode { #arena:not(.chess):not(.mobile)>#autonode {
display: none display: none
} }
#arena:not(.auto)>#autonode { #arena:not(.auto)>#autonode,
#autonode.hidden {
opacity: 0; opacity: 0;
pointer-events: none pointer-events: none;
} }
#arena.auto #me .card{ #arena.auto #me .card{
opacity: 0.5 opacity: 0.5

View File

@ -2263,8 +2263,7 @@ mode.chess={
},150); },150);
} }
}; };
// node.addEventListener('transitionEnd',onEnd); node.listenTransition(onEnd);
node.addEventListener('webkitTransitionEnd',onEnd);
}; };
var zhaomu2=function(){ var zhaomu2=function(){
if(_status.qianfan||_status.kaibao) return; if(_status.qianfan||_status.kaibao) return;
@ -2993,8 +2992,7 @@ mode.chess={
},150); },150);
} }
}; };
// node.addEventListener('transitionEnd',onEnd); node.listenTransition(onEnd);
node.addEventListener('webkitTransitionEnd',onEnd);
}; };
setTimeout(function(){ setTimeout(function(){
nodes[0].delete(); nodes[0].delete();

View File

@ -592,7 +592,7 @@ mode.story={
node.style.transition='all ease-out 0.4s'; node.style.transition='all ease-out 0.4s';
node.style.transform='perspective(1600px) rotateY(180deg) scale(1)' node.style.transform='perspective(1600px) rotateY(180deg) scale(1)'
}; };
node.addEventListener('webkitTransitionEnd',onEnd); node.listenTransition(onEnd);
} }
ui.click.scene=clickScene; ui.click.scene=clickScene;
var restoreScene=function(node,forced){ var restoreScene=function(node,forced){
@ -618,7 +618,7 @@ mode.story={
node.style.transition='all ease-out 0.4s'; node.style.transition='all ease-out 0.4s';
node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)' node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)'
}; };
node.addEventListener('webkitTransitionEnd',onEnd); node.listenTransition(onEnd);
} }
ui.click.scene2=restoreScene; ui.click.scene2=restoreScene;
var switchScene=function(){ var switchScene=function(){

View File

@ -905,7 +905,7 @@ mode.tafang={
node.style.transition='all ease-out 0.4s'; node.style.transition='all ease-out 0.4s';
node.style.transform='perspective(1600px) rotateY(180deg) scale(1)' node.style.transform='perspective(1600px) rotateY(180deg) scale(1)'
}; };
node.addEventListener('webkitTransitionEnd',onEnd); node.listenTransition(onEnd);
} }
ui.click.scene=clickScene; ui.click.scene=clickScene;
var restoreScene=function(node,forced){ var restoreScene=function(node,forced){
@ -930,7 +930,7 @@ mode.tafang={
node.style.transition='all ease-out 0.4s'; node.style.transition='all ease-out 0.4s';
node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)' node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)'
}; };
node.addEventListener('webkitTransitionEnd',onEnd); node.listenTransition(onEnd);
} }
ui.click.scene2=restoreScene; ui.click.scene2=restoreScene;
var createScene=function(name){ var createScene=function(name){