Compare commits
No commits in common. "571c3112e897e6520efb0b486a4e76286d33dd49" and "1880e325973b0ac8fa366f069c910faad745e644" have entirely different histories.
571c3112e8
...
1880e32597
132
js/custom.js
132
js/custom.js
|
@ -17,16 +17,16 @@ var winWidth = $(window).width();
|
||||||
var winheight = $(window).height();
|
var winheight = $(window).height();
|
||||||
//控制速度1px
|
//控制速度1px
|
||||||
var speed = 1;
|
var speed = 1;
|
||||||
|
var upTimer = null,downTimer = null,leftTimer = null,rightTimer = null;
|
||||||
|
var suiDanTimer = null;
|
||||||
var startIndex = 0;
|
var startIndex = 0;
|
||||||
// 领舞关闭时间
|
|
||||||
var dancingTime = 6000;
|
|
||||||
// 6秒钟检测移动位置
|
|
||||||
var runTime = 6000;
|
|
||||||
// 随机移动的定时器
|
|
||||||
var upTimer = null;
|
|
||||||
// 集体舞ji
|
// 集体舞ji
|
||||||
function allDancing(dangcing){
|
function allDancing(dangcing){
|
||||||
if(dangcing!=''){
|
if(dangcing!=''){
|
||||||
|
// clearInterval(upTimer);
|
||||||
|
// clearInterval(downTimer);
|
||||||
|
// clearInterval(leftTimer);
|
||||||
|
// clearInterval(rightTimer);
|
||||||
actionArr.forEach((item,index)=>{
|
actionArr.forEach((item,index)=>{
|
||||||
var haveDan = $(`.people-img`).is(`.${item}`);
|
var haveDan = $(`.people-img`).is(`.${item}`);
|
||||||
if(haveDan){
|
if(haveDan){
|
||||||
|
@ -41,7 +41,7 @@ function allDancing(dangcing){
|
||||||
startIndex = 0;
|
startIndex = 0;
|
||||||
var allPeople = $('.dance-floor').find('.people-img').length;
|
var allPeople = $('.dance-floor').find('.people-img').length;
|
||||||
$(`.people-img`).removeClass(dangcing);
|
$(`.people-img`).removeClass(dangcing);
|
||||||
var suiDanTimer = setInterval(()=>{
|
suiDanTimer = setInterval(()=>{
|
||||||
if(startIndex==allPeople){
|
if(startIndex==allPeople){
|
||||||
clearInterval(suiDanTimer);
|
clearInterval(suiDanTimer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,6 +55,7 @@ function allDancing(dangcing){
|
||||||
// 随机舞
|
// 随机舞
|
||||||
function randomDancing(id){
|
function randomDancing(id){
|
||||||
actionArr.forEach((item,index)=>{
|
actionArr.forEach((item,index)=>{
|
||||||
|
// var chooseIdex = Math.floor(Math.random()*num);
|
||||||
var haveDan = $(`.data${id} .people-img`).is(`.${item}`);
|
var haveDan = $(`.data${id} .people-img`).is(`.${item}`);
|
||||||
if(haveDan){
|
if(haveDan){
|
||||||
$(`.data${id} .people-img`).removeClass(item);
|
$(`.data${id} .people-img`).removeClass(item);
|
||||||
|
@ -67,6 +68,7 @@ function randomDancing(id){
|
||||||
// 个人动作舞
|
// 个人动作舞
|
||||||
function peopleAction(id,aevent){
|
function peopleAction(id,aevent){
|
||||||
actionArr.forEach((item,index)=>{
|
actionArr.forEach((item,index)=>{
|
||||||
|
// var chooseIdex = Math.floor(Math.random()*num);
|
||||||
var haveDan = $(`#${id} .people-img`).is(`.${item}`);
|
var haveDan = $(`#${id} .people-img`).is(`.${item}`);
|
||||||
if(haveDan){
|
if(haveDan){
|
||||||
$(`#${id} .people-img`).removeClass(item);
|
$(`#${id} .people-img`).removeClass(item);
|
||||||
|
@ -76,58 +78,74 @@ function peopleAction(id,aevent){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 上
|
|
||||||
function upMove(id){
|
|
||||||
var odivu = document.getElementById(`${id}`);
|
|
||||||
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));
|
|
||||||
// }
|
|
||||||
},runTime)
|
|
||||||
}
|
|
||||||
// // 下
|
|
||||||
// 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){
|
function moveEv(id){
|
||||||
upMove(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 {
|
||||||
|
$(`#${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}`);
|
||||||
|
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 closeSay(index){
|
function closeSay(index){
|
||||||
|
@ -214,7 +232,7 @@ function dancerRandom(){
|
||||||
$(`.leading-dancer`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]);
|
$(`.leading-dancer`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},dancingTime)
|
},4000)
|
||||||
}
|
}
|
||||||
$(function(){
|
$(function(){
|
||||||
dancerRandom();
|
dancerRandom();
|
||||||
|
|
Loading…
Reference in New Issue