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

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

 更新時間:2007年05月08日 00:00:00   作者:  
公司的一個項目中,有許多地方需要延時執(zhí)行一些可重復性的函數(shù)(動作),就寫了下面這段函數(shù)。
呵呵,不知道取什么意思更為確切些,就定為了:LoopRun,意為“重復執(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 >> 字符串型,需要重復執(zhí)行的Javascript函數(shù)或語句(多個函數(shù)或語句請用;分隔)
sFuncEnd >> 字符串型,用于中止重復執(zhí)行動作(sFuncLoop)的Javascript函數(shù)或語句
nDelay >> 數(shù)字型,重復執(zhí)行的時間間隔(毫秒數(shù))
應用實例:
水平往復運動: http://cnlei.iecn.net/mycode/lLoopRun/index.html
自動伸縮大小: http://cnlei.iecn.net/mycode/lLoopRun/index2.html
垂直往復運動: http://cnlei.iecn.net/mycode/lLoopRun/index3.html
漸變顯示(圖片): http://cnlei.iecn.net/mycode/lLoopRun/index4.html

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

相關(guān)文章

最新評論