As promised, I updated the script to use optional staggering, it was a simple matter to add more peace time as an option:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Trembling Message Script - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.jc {
position:relative;
}
</style>
<script type="text/javascript">
/* Trembling message script- © Dynamic Drive (www.dynamicdrive.com)
For 100's more DHTML scripts, and TOS, visit http://www.dynamicdrive.com
This notice must remain for legal use.
Modified in http://www.dynamicdrive.com/forums for optional pausing,
DOCTYPE compliance & to overcome weak browser/CPU interaction in FF
Modifications ©2008 by: John Davenport Scheuer - username:jscheuer1 */
jiggleit.pauseFactor=1.5; // Seconds (approx) the on and the off states will be, use 0 for no on/off, decimals allowed
jiggleit.randomJigs=1; // Random jigglers if more than one? 1=randomly staggered (requires pause enabled), 0=in unison
jiggleit.peaceTime=3; // Seconds to extend the off state by if pause enabled, use 0 for equal on and off periods
/////////////// Stop Editing ///////////////
jiggleit.ar=[];
function jiggleit(num){
var p=jiggleit.peaceTime*1000, f=Math.ceil(jiggleit.pauseFactor*1000/80);
jiggleit.ar[this.id=num]=this;
this.el=jiggleit.el('jiggle'+num);
this.to=80;
this.p=(this.p=jiggleit.randomJigs*2*num)&&f? this.p+f : f;
this.jig=function(){
var c=this; if(c.p){c.t=c.t? ++c.t : 1;
if(c.t%c.p==0){c.to=c.p*80+p;c.t=0;} else c.to=80;}
c.el.style.left=parseInt(c.el.style.left)==1? '-1px' : '1px';
setTimeout("jiggleit.ar["+c.id+"].jig()", c.to);
};
setTimeout("jiggleit.ar["+num+"].jig()", (this.p-f)*30+f);
};
jiggleit.el=function(id){
return document.all? document.all[id] : document.getElementById(id);
};
jiggleit.init=function(){
var i=0; while(jiggleit.el('jiggle'+i))
i++; if(i--) for (i; i > -1; --i)
new jiggleit(i);
}
if(document.all||document.getElementById)
window.onload=jiggleit.init;
</script>
</head>
<body>
<span id="jiggle0" class="jc"><b>Looking for JavaScripts? Visit <a href="http://javascriptkit.com">JavaScript Kit!</a></b></span><br>
<span id="jiggle1" class="jc"><b>Another</b></span><br>
<span id="jiggle2" class="jc"><b>More</b></span><br>
</body>
</html>
Bookmarks