From 8072863a87c2af2b7eef40ef7acf768efaad8664 Mon Sep 17 00:00:00 2001 From: chen <2659004835@qq.com> Date: Wed, 24 Nov 2021 11:35:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E4=BD=8D=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/custom.js | 58 ++++++++++++++++++++++++---------------------------- js/handle.js | 2 +- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/js/custom.js b/js/custom.js index 8e7ac10..de853a6 100644 --- a/js/custom.js +++ b/js/custom.js @@ -80,50 +80,46 @@ function peopleAction(id,aevent){ } // 随机位移 function moveEv(id){ - // upMove(id); - downMove(id); - // var typeMove = Math.floor(Math.random()*4); - // switch (typeMove){ - // case 0: - // upMove(id); - // break; - // case 1: - // downMove(id); - // break; - // case 2: - // leftMove(id); - // break; - // case 3: - // rightMove(id); - // break; - // } + upMove(id); + // downMove(id); + var typeMove = Math.floor(Math.random()*4); + switch (typeMove){ + case 0: + upMove(id); + break; + case 1: + downMove(id); + break; + case 2: + leftMove(id); + break; + case 3: + rightMove(id); + break; + } } // 上 function upMove(id){ var odivu = document.getElementById(`${id}`); var upTimer = setInterval(()=>{ - if(odivu.style.top <='1%' || odivu.style.top<30){ - // console.log('关闭了上走'); + if(parseInt(odivu.style.top) <=10){ clearInterval(upTimer); downMove(id); } else { - // console.log('上走进来了'); - $(`#${id}`).animate({top:'0%'},20000); - // odivu.style.top = odivu.offsetTop-speed+'px'; + $(`#${id}`).animate({top:`${Math.floor(Math.random()*76)}%`,left:`${Math.floor(Math.random()*76)}%`},Math.floor(Math.random()*40000+10000)); } - },100) + },10) } // 下 function downMove(id){ var odivd = document.getElementById(`${id}`); - downTimer = setInterval(()=>{ - if(odivd.style.top >='76%'){ + var downTimer = setInterval(()=>{ + if(parseInt(odivd.style.top) >=86){ clearInterval(downTimer); upMove(id); } else { - $(`#${id}`).animate({top:'80%'},10000); - // odivd.style.top = odivd.offsetTop+speed+'px'; + $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); } },10) } @@ -131,11 +127,11 @@ function downMove(id){ function leftMove(id){ var odivl = document.getElementById(`${id}`); leftTimer = setInterval(()=>{ - if(odivl.offsetLeft == 0){ + if(odivl.offsetLeft < 10){ clearInterval(leftTimer); rightMove(id); } else { - odivl.style.left = odivl.offsetLeft-speed+'px'; + $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); } },10) } @@ -143,11 +139,11 @@ function leftMove(id){ function rightMove(id){ var odivr = document.getElementById(`${id}`); rightTimer = setInterval(()=>{ - if(odivr.offsetLeft > 1600){ + if(odivr.offsetLeft >= 86){ clearInterval(rightTimer); leftMove(id); } else { - odivr.style.left = odivr.offsetLeft+speed+'px'; + $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); } },10) } diff --git a/js/handle.js b/js/handle.js index 6543fad..f27aab9 100644 --- a/js/handle.js +++ b/js/handle.js @@ -222,7 +222,7 @@ function receiveMessage(event) //关闭领舞说话 setTimeout(()=>{ $('.speak-pink').fadeOut(); - },3000) + },1000) } // 领舞说切歌 if(leader.text=="切歌"){