so for past +12 hrs been trying to figure out how to recursively call an animation function.(因此在过去的12个小时内,我们一直在试图弄清楚如何递归调用动画函数。)
here's what i've been trying to do, i want the "rain-effect" of colors dropping in, highlighting each cell.(这就是我一直在尝试的工作,我希望颜色的“雨水效果”滴入其中,突出显示每个单元格。)
While all tds(columns) must highlight randomly starting from 0th row, and do it such that each column doesn't get highlight color right after.(虽然所有tds(columns)必须从第0行开始随机突出显示,并且这样做以确保每一列都不会在其后立即获得突出显示颜色。)
here's a codepen link https://codepen.io/fahadpnw/pen/MWWRdNG (the animation is "pre-start" ie, without pressing the start button.(这是一个codepen链接https://codepen.io/fahadpnw/pen/MWWRdNG (动画是“预开始”的,即无需按下开始按钮。)
however, in browser it crashes after a while, has a memory leak + i'm really trying to figure out how to call these such that instead of a single color flowing / raining down, i could have multiple... and each at a different pace/speed..(但是,在浏览器中,它会在一段时间后崩溃,并发生内存泄漏+我真的是想弄清楚如何调用这些方法,以使我可以有多个...而不是单个颜色飘落/下雨。不同的速度/速度)
function animateTable(firstSpot) {
var randomColor = theColors[Math.floor(Math.random() * theColors.length)];
var firstAnimation;
var secondAnimation;
firstSpot.each(function (index, val) {
var col = $(this).attr("data-column")
var row = $(this).attr("data-row")
console.log("data-column", col, "data-row", row);
// $(this).delay(Math.random() * (2000)) + 200;
$(this).delay(index * 700).css('background-color', 'white')
firstAnimation = $(this).animate({ backgroundColor: randomColor }).delay(300)
secondAnimation = firstAnimation.animate({ backgroundColor: "white" }, function () {
var some = $("#table").find(` [data-row='` + row + `'] + [data-column='` + col + `'] `)
var bg = some[0].style.backgroundColor
console.log(bg)
var secondSpot
console.log("res", !arr.includes(getFirstSpot));
console.log("arr is ", arr)
if (index == 4) {
do {
secondSpot = getFirstSpot()
console.log("4th index - do spot")
$(this).after(animateTable(secondSpot))
} while (getFirstSpot == firstSpot[0]) {
if (arr.length > 9) {
arr.length = 0
}
}
}
//$(this).after(animateTable(table))
});
});
ask by Fahad Bilal translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…