diff --git a/js/custom.js b/js/custom.js index de853a6..1529eb5 100644 --- a/js/custom.js +++ b/js/custom.js @@ -17,16 +17,16 @@ var winWidth = $(window).width(); var winheight = $(window).height(); //控制速度1px var speed = 1; -var upTimer = null,downTimer = null,leftTimer = null,rightTimer = null; -var suiDanTimer = null; var startIndex = 0; +// 领舞关闭时间 +var dancingTime = 6000; +// 6秒钟检测移动位置 +var runTime = 6000; +// 随机移动的定时器 +var upTimer = null; // 集体舞ji function allDancing(dangcing){ if(dangcing!=''){ - // clearInterval(upTimer); - // clearInterval(downTimer); - // clearInterval(leftTimer); - // clearInterval(rightTimer); actionArr.forEach((item,index)=>{ var haveDan = $(`.people-img`).is(`.${item}`); if(haveDan){ @@ -41,7 +41,7 @@ function allDancing(dangcing){ startIndex = 0; var allPeople = $('.dance-floor').find('.people-img').length; $(`.people-img`).removeClass(dangcing); - suiDanTimer = setInterval(()=>{ + var suiDanTimer = setInterval(()=>{ if(startIndex==allPeople){ clearInterval(suiDanTimer); } else { @@ -55,7 +55,6 @@ function allDancing(dangcing){ // 随机舞 function randomDancing(id){ actionArr.forEach((item,index)=>{ - // var chooseIdex = Math.floor(Math.random()*num); var haveDan = $(`.data${id} .people-img`).is(`.${item}`); if(haveDan){ $(`.data${id} .people-img`).removeClass(item); @@ -68,7 +67,6 @@ function randomDancing(id){ // 个人动作舞 function peopleAction(id,aevent){ actionArr.forEach((item,index)=>{ - // var chooseIdex = Math.floor(Math.random()*num); var haveDan = $(`#${id} .people-img`).is(`.${item}`); if(haveDan){ $(`#${id} .people-img`).removeClass(item); @@ -78,74 +76,58 @@ 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; - } - -} // 上 function upMove(id){ var odivu = document.getElementById(`${id}`); - var upTimer = setInterval(()=>{ - if(parseInt(odivu.style.top) <=10){ - clearInterval(upTimer); - downMove(id); - } else { - $(`#${id}`).animate({top:`${Math.floor(Math.random()*76)}%`,left:`${Math.floor(Math.random()*76)}%`},Math.floor(Math.random()*40000+10000)); - } - },10) -} -// 下 -function downMove(id){ - var odivd = document.getElementById(`${id}`); - var downTimer = setInterval(()=>{ - if(parseInt(odivd.style.top) >=86){ - clearInterval(downTimer); - upMove(id); - } else { + upTimer = setInterval(()=>{ + // if(parseInt(odivu.style.top) <=10){ + // // clearInterval(upTimer); + // // downMove(id); + // $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); + // } else { $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); - } - },10) + // } + },runTime) } -// 左 -function leftMove(id){ - var odivl = document.getElementById(`${id}`); - leftTimer = setInterval(()=>{ - if(odivl.offsetLeft < 10){ - clearInterval(leftTimer); - rightMove(id); - } else { - $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); - } - },10) -} -// 右 -function rightMove(id){ - var odivr = document.getElementById(`${id}`); - rightTimer = setInterval(()=>{ - if(odivr.offsetLeft >= 86){ - clearInterval(rightTimer); - leftMove(id); - } else { - $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); - } - },10) +// // 下 +// function downMove(id){ +// var odivd = document.getElementById(`${id}`); +// var downTimer = setInterval(()=>{ +// if(parseInt(odivd.style.top) >=86){ +// clearInterval(downTimer); +// upMove(id); +// } else { +// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); +// } +// },10) +// } +// // 左 +// function leftMove(id){ +// var odivl = document.getElementById(`${id}`); +// var leftTimer = setInterval(()=>{ +// if(odivl.offsetLeft < 10){ +// clearInterval(leftTimer); +// rightMove(id); +// } else { +// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); +// } +// },10) +// } +// // 右 +// function rightMove(id){ +// var odivr = document.getElementById(`${id}`); +// var rightTimer = setInterval(()=>{ +// if(odivr.offsetLeft >= 86){ +// clearInterval(rightTimer); +// leftMove(id); +// } else { +// $(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000)); +// } +// },10) +// } +// 随机位移 +function moveEv(id){ + upMove(id); } // 关闭说话 function closeSay(index){ @@ -232,7 +214,7 @@ function dancerRandom(){ $(`.leading-dancer`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]); } }) - },4000) + },dancingTime) } $(function(){ dancerRandom();