烟剧本时间

时间:2014-05-02 09:08:01

标签: javascript time timeout

我在我的网站上使用以下脚本:

http://demo.web3designs.com/css-jquery-animated-hot-smoke-coffee-tea-effect.htm

如何编辑它以使烟雾不连续,但每20秒才会出现一次?

这是javascript:

if(!$.browser.msie){
        var a=0;for(;a<15;a+=1){setTimeout(function b(){var a=Math.random()*1e3+5e3,c=$("<div />",{"class":"smoke",css:{opacity:0,left:Math.random()*200+80}});$(c).appendTo("#viewport");$.when($(c).animate({opacity:1},{duration:a/4,easing:"linear",queue:false,complete:function(){$(c).animate({opacity:0},{duration:a/3,easing:"linear",queue:false})}}),$(c).animate({bottom:$("#viewport").height()},{duration:a,easing:"linear",queue:false})).then(function(){$(c).remove();b()})},Math.random()*3e3)}
    }else{      
    "use strict";var a=0;for(;a<15;a+=1){setTimeout(function b(){var a=Math.random()*1e3+5e3,c=$("<div />",{"class":"smoke",css:{left:Math.random()*200+80}});$(c).appendTo("#viewport");$.when($(c).animate({},{duration:a/4,easing:"linear",queue:false,complete:function(){$(c).animate({},{duration:a/3,easing:"linear",queue:false})}}),$(c).animate({bottom:$("#viewport").height()},{duration:a,easing:"linear",queue:false})).then(function(){$(c).remove();b()})},Math.random()*3e3)}}}())

1 个答案:

答案 0 :(得分:0)

我认为$ .timer()是您正在寻找的。

http://code.google.com/p/jquery-timer/

var timer = $.timer(function() {
    // Place your code here;
});

timer.set({ time : 20000, autostart : true });