最近我被要求做这个特效。
http://mobile.bebitalia.com/home.do
但它是用scriptaculus编写的,我需要用jquery来实现它。
我找到了这个例子,但它只完成了一半
你能帮我在淡入完成后做淡出效果吗?
发布于 2011-04-15 03:10:26
我正在组装一把小提琴,但您可以尝试使用与您给出的示例类似的标记
// Translated from scriptaculus
// http://mobile.bebitalia.com/home.do
function hideCube() {
$('#gctu1w_bg').show('slow');
$('.cube').each(function(index, element) {
var sleepTime = Math.floor(Math.random() * 2000);
var t = setTimeout(function() {
var d = Math.floor(Math.random() * 2000);
$(element).fadeTo(d, 0);
}, sleepTime);
});
}
$(function() {
$('.cube').each(function(index, element) {
var sleepTime = Math.floor(Math.random() * 2000);
var t = setTimeout(function() {
var d = Math.floor(Math.random() * 1000);
$(element).fadeTo(d, 0.99);
}, sleepTime);
});
var h = setTimeout(hideCube, 4000);
});发布于 2011-04-15 02:17:41
这是一个很好的解决方案:
fadeInout = {
init: function() {
v = $("#blocks > li").css('visibility', 'hidden'),
cur = 0,
rem = 0;
for (var j, x, i = v.length; i;
j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
//other startup code
return this;
},
fades: function() {
this.fadein();
},
fadein: function() {
v.eq(cur++).css('visibility', 'visible').hide().fadeIn();
if (cur != v.length) setTimeout(fadeInout.fadein, 50);
else setTimeout(fadeInout.fadeout, 100);
},
fadeout: function() {
v.eq(rem++).css('visibility', 'none').fadeOut().show();
if (rem != v.length) setTimeout(fadeInout.fadeout, 50);
}
}
fadeInout.init().fades();下面的小提琴展示了这一点:http://jsfiddle.net/maniator/rcts4/
https://stackoverflow.com/questions/5667375
复制相似问题