随机位移

master
chen 2021-11-24 11:35:11 +08:00
parent 19624b2ed7
commit 8072863a87
2 changed files with 28 additions and 32 deletions

View File

@ -80,50 +80,46 @@ function peopleAction(id,aevent){
} }
// 随机位移 // 随机位移
function moveEv(id){ function moveEv(id){
// upMove(id); upMove(id);
downMove(id); // downMove(id);
// var typeMove = Math.floor(Math.random()*4); var typeMove = Math.floor(Math.random()*4);
// switch (typeMove){ switch (typeMove){
// case 0: case 0:
// upMove(id); upMove(id);
// break; break;
// case 1: case 1:
// downMove(id); downMove(id);
// break; break;
// case 2: case 2:
// leftMove(id); leftMove(id);
// break; break;
// case 3: case 3:
// rightMove(id); rightMove(id);
// break; break;
// } }
} }
// 上 // 上
function upMove(id){ function upMove(id){
var odivu = document.getElementById(`${id}`); var odivu = document.getElementById(`${id}`);
var upTimer = setInterval(()=>{ var upTimer = setInterval(()=>{
if(odivu.style.top <='1%' || odivu.style.top<30){ if(parseInt(odivu.style.top) <=10){
// console.log('关闭了上走');
clearInterval(upTimer); clearInterval(upTimer);
downMove(id); downMove(id);
} else { } else {
// console.log('上走进来了'); $(`#${id}`).animate({top:`${Math.floor(Math.random()*76)}%`,left:`${Math.floor(Math.random()*76)}%`},Math.floor(Math.random()*40000+10000));
$(`#${id}`).animate({top:'0%'},20000);
// odivu.style.top = odivu.offsetTop-speed+'px';
} }
},100) },10)
} }
// 下 // 下
function downMove(id){ function downMove(id){
var odivd = document.getElementById(`${id}`); var odivd = document.getElementById(`${id}`);
downTimer = setInterval(()=>{ var downTimer = setInterval(()=>{
if(odivd.style.top >='76%'){ if(parseInt(odivd.style.top) >=86){
clearInterval(downTimer); clearInterval(downTimer);
upMove(id); upMove(id);
} else { } else {
$(`#${id}`).animate({top:'80%'},10000); $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
// odivd.style.top = odivd.offsetTop+speed+'px';
} }
},10) },10)
} }
@ -131,11 +127,11 @@ function downMove(id){
function leftMove(id){ function leftMove(id){
var odivl = document.getElementById(`${id}`); var odivl = document.getElementById(`${id}`);
leftTimer = setInterval(()=>{ leftTimer = setInterval(()=>{
if(odivl.offsetLeft == 0){ if(odivl.offsetLeft < 10){
clearInterval(leftTimer); clearInterval(leftTimer);
rightMove(id); rightMove(id);
} else { } 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) },10)
} }
@ -143,11 +139,11 @@ function leftMove(id){
function rightMove(id){ function rightMove(id){
var odivr = document.getElementById(`${id}`); var odivr = document.getElementById(`${id}`);
rightTimer = setInterval(()=>{ rightTimer = setInterval(()=>{
if(odivr.offsetLeft > 1600){ if(odivr.offsetLeft >= 86){
clearInterval(rightTimer); clearInterval(rightTimer);
leftMove(id); leftMove(id);
} else { } 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) },10)
} }

View File

@ -222,7 +222,7 @@ function receiveMessage(event)
//关闭领舞说话 //关闭领舞说话
setTimeout(()=>{ setTimeout(()=>{
$('.speak-pink').fadeOut(); $('.speak-pink').fadeOut();
},3000) },1000)
} }
// 领舞说切歌 // 领舞说切歌
if(leader.text=="切歌"){ if(leader.text=="切歌"){