最佳答案
我试图建立一个加载指示器与图像精灵,我想出了这个功能
function setBgPosition() {
var c = 0;
var numbers = [0, -120, -240, -360, -480, -600, -720];
function run() {
Ext.get('common-spinner').setStyle('background-position', numbers[c++] + 'px 0px');
if (c<numbers.length)
{
setTimeout(run, 200);
}else
{
setBgPosition();
}
}
setTimeout(run, 200);
}
输出是这样的
我必须使用 setBgposition () ; 在 else 中保持这个循环运行,所以现在我的问题是,一旦我想[装载完成] ,如何停止这个循环?