我觉得这不是最有效,最有效的做事方式:
line.stop(true, true).show('slide', {direction: whichway}, speed-150, function() {
title.stop(true, true).fadeIn(speed-200, function() {
sub.stop(true, true).show('slide', {direction: whichway}, speed-50, function() {
subtext.stop(true, true).show();
paragraph.stop(true, true).slideDown(speed);
});
});
});
哪条路/速度是动态的,但除此之外,所有东西都必须同步并排队。有没有更有效的方法呢?
答案 0 :(得分:0)
使用case / switch语句。像这样:
function ani(step) {
switch(step) {
case 1:
line.stop(true, true).show('slide', {direction: whichway}, speed-150, function() {ani(2)});
break;
case 2
title.stop(true, true).fadeIn(speed-200, function() { ani(3)});
break;
...
default: ani(1)
}
}