题
我有一个jQuery计时器去,它似乎弄乱2个周期之后: treethink.treethink.net/备份
现在,对不同的定时器就会缩回新闻股票,并变更为DIV正显示出再次弹出。一对夫妇的周期,你可以在上面的链接看到,一些停留更长的时间以后,再重叠,它成为一个烂摊子。我不知道为什么会这样...
下面是我的代码:
/* Retracting Ticker */
/* Initially hide all news items */
$('#ticker1').hide();
$('#ticker2').hide();
$('#ticker3').hide();
$("#ticker1").oneTime(1000,function(i) { /* Show 1 once on first pull out */
$('#ticker1').show();
});
$("#ticker1").everyTime(64500,function(i) { /* Hide 3 and show 1 everytime timer gets to certain point */
$('#ticker1').show();
});
$("#ticker1").oneTime(21500,function(i) { /* Hide 1 and show 2 once after first pull out */
$('#ticker1').hide();
$('#ticker2').show();
});
$("#ticker1").everyTime(86000,function(i) { /* Hide 1 and show 2 everytime timer gets to certain point */
$('#ticker1').hide();
$('#ticker2').show();
});
$("#ticker2").oneTime(43000,function(i) { /* Hide 2 and show 3 once after second pull out */
$('#ticker2').hide();
$('#ticker3').show();
});
$("#ticker2").everyTime(107500,function(i) { /* Hide 2 and show 3 everytime timer gets to certain point */
$('#ticker2').hide();
$('#ticker3').show();
});
$("#ticker3").oneTime(64000,function(i) { /* Hide 2 and show 3 once after second pull out */
$('#ticker3').hide();
});
$("#ticker3").everyTime(129000,function(i) { /* Hide 2 and show 3 everytime timer gets to certain point */
$('#ticker3').hide();
});
$("#ticker").oneTime(2000,function(i) { /* Do the first pull out once */
$("#ticker").animate({right: "0"}, {duration: 800 });
});
$("#ticker").oneTime(20000,function(i) { /* Do the first retract once */
$("#ticker").animate({right: "-450"}, {duration: 800});
});
$("#ticker").everyTime(21500,function(i) { /* Everytime timer gets to certain point */
$("#ticker").animate({right: "0"}, {duration: 800}); /* Pull out right away */
$("#ticker").oneTime(20000,function(i) { /* Retract once */
$("#ticker").animate({right: "-450"}, {duration: 800});
});
});
谢谢,
瓦德
解决方案
让我们忽略所有的oneTime
s因为他们不是你要乱了。
$("#ticker1").everyTime(64500,function(i) {
$('#ticker1').show();
});
$("#ticker1").everyTime(86000,function(i) {
$('#ticker1').hide();
$('#ticker2').show();
});
$("#ticker2").everyTime(107500,function(i) {
$('#ticker2').hide();
$('#ticker3').show();
});
$("#ticker3").everyTime(129000,function(i) {
$('#ticker3').hide();
});
$("#ticker").everyTime(21500,function(i) {
$("#ticker").animate({right: "0"}, {duration: 800});
$("#ticker").oneTime(20000,function(i) {
$("#ticker").animate({right: "-450"}, {duration: 800});
});
});
您有4个对象:股票,容器,和3个消息
在容器的行为是本(约,并且不计算第一拉出):每21.5秒,隐藏1.5秒,然后向后滑动出来。细,这不是问题的来源,3个消息定时器都是问题。
这是在间隔的消息行为:
ticker show (s) hide (s)
1 64.5 86
2 86 107.5
3 107.5 129
修改我有我的号码错误的,第一股票的间隔时间,但我仍然认为这个想法是一样的。最终,时间重叠。
不隶属于 StackOverflow