欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

延時(shí)重復(fù)執(zhí)行函數(shù) lLoopRun.js

 更新時(shí)間:2007年05月08日 00:00:00   作者:  
公司的一個(gè)項(xiàng)目中,有許多地方需要延時(shí)執(zhí)行一些可重復(fù)性的函數(shù)(動(dòng)作),就寫了下面這段函數(shù)。
呵呵,不知道取什么意思更為確切些,就定為了:LoopRun,意為“重復(fù)執(zhí)行” 
function lLoopRun(sFuncLoop,sFuncEnd,nDelay) {
  var vintervalId = null;
  var runString  = sFuncLoop;
  var stopString  = sFuncEnd;
  var delayTime  = nDelay;
  //var nCount = 0;
  this._doLoop = function (){
    if (vintervalId && !eval(stopString)){
      eval(runString);
      //nCount++;
    } else {
      window.clearInterval(vintervalId);
      vintervalId = null;
    }
  }
  window.clearInterval(vintervalId);
  vintervalId = window.setInterval(this._doLoop,delayTime);
}

參數(shù)說明:
sFuncLoop >> 字符串型,需要重復(fù)執(zhí)行的Javascript函數(shù)或語句(多個(gè)函數(shù)或語句請(qǐng)用;分隔)
sFuncEnd >> 字符串型,用于中止重復(fù)執(zhí)行動(dòng)作(sFuncLoop)的Javascript函數(shù)或語句
nDelay >> 數(shù)字型,重復(fù)執(zhí)行的時(shí)間間隔(毫秒數(shù))
應(yīng)用實(shí)例:
水平往復(fù)運(yùn)動(dòng): http://cnlei.iecn.net/mycode/lLoopRun/index.html
自動(dòng)伸縮大小: http://cnlei.iecn.net/mycode/lLoopRun/index2.html
垂直往復(fù)運(yùn)動(dòng): http://cnlei.iecn.net/mycode/lLoopRun/index3.html
漸變顯示(圖片): http://cnlei.iecn.net/mycode/lLoopRun/index4.html

以上只是幾個(gè)簡(jiǎn)單的應(yīng)用實(shí)例,具體應(yīng)用時(shí)關(guān)鍵還得看sFuncLoop和sFuncEnd這兩個(gè)參數(shù)所代表的函數(shù)寫得是否好,例如給實(shí)例一中的運(yùn)動(dòng)圖片加上緩沖運(yùn)行的效果的話,就需要在sFuncLoop所代表的函數(shù)中加上相應(yīng)的實(shí)現(xiàn)代碼:)

相關(guān)文章

最新評(píng)論