Home > Web Front-end > JS Tutorial > javascript delayed repeated execution of functions lLoopRun.js_javascript skills

javascript delayed repeated execution of functions lLoopRun.js_javascript skills

WBOY
Release: 2016-05-16 19:11:48
Original
1565 people have browsed it

function lLoopRun(sFuncLoop,sFuncEnd,nDelay) {
//written by http://fengyan.iecn.cn

//sFuncLoop >> String type, Javascript function or statement that needs to be executed repeatedly (please use; to separate multiple functions or statements)
//sFuncEnd >> String type, a Javascript function or statement used to terminate repeated execution of actions (sFuncLoop)
//nDelay >> Numeric type, time interval for repeated execution (number of milliseconds)
var vintervalId = null;
var runString = sFuncLoop;
var stopString = sFuncEnd;
var delayTime = nDelay;
//var nCount = 0;//Number of executions//For the convenience of testing, comment out this line when applying
this._doLoop = function (){
if (vintervalId && !eval(stopString)){
eval(runString);
//nCount ;//Record the number of executions//For the convenience of testing, comment out this line when applying
} else {
window.clearInterval(vintervalId);
vintervalId = null;
}
//document.getElementById("TestCount").innerHTML = nCount;//Output the number of executions//For the convenience of testing, comment out this line when applying
}
window.clearInterval(vintervalId);
vintervalId = window.setInterval(this._doLoop,delayTime);
}

A few example codes:
Horizontal reciprocating motion:



lLoopRun.js application example: horizontal reciprocating motion


#IECN {position:absolute;}



Number of executions:

0
javascript delayed repeated execution of functions lLoopRun.js_javascript skills







Auto-scaling size:

lLoopRun.js application example: automatic scaling





Number of executions: javascript delayed repeated execution of functions lLoopRun.js_javascript skills0








Vertical reciprocating motion:

lLoopRun.js application example: vertical reciprocating motion




javascript delayed repeated execution of functions lLoopRun.js_javascript skills

Number of executions: 0
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template