Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert a pause

Status
Not open for further replies.

fuli42

Technical User
Jul 9, 2002
74
HU
Is it possible to insert a pause (say 4 secs.) into a roller script, if one condition is true?
The scroller script does a lot of things, besides scrolling, it changes images on another layer - so before scrolling down and displaying the next image, it should wait a little.(But only, if the layer that it scrolls, contains links to images).
I've been experimenting with adding setTimeout, but the scroller still goes on, only it waits to execute what is inside it, and it just caused error messages.

Thank you very much!
 
Here is the scroller script, but it is only a part of the whole, and some lines are in Hungarian, sorry!

It is quite flexible, you can set direction, speed, stop it, set the layer to be scrolled.

One way to slow it would be to set in scrollTimer instead of 1, a higher number. But then, the movement would be too jagged. The best solution would be, if the just after the testing for the existance of image links on the layer, you could insert a pause.

If you need the whole code:


and
Thank you all!!!!

// scrolling script starts -->

k = -1;
function gorog(ir, seb, loop, reteg) {
loop = true;
irany = "fel";
sebesseg = 1;
scrolltimer = null;
ret = reteg;
if (document.layers) {
var page = eval(document.layers[ret]);
}
else {
if (document.getElementById) {
var page= eval("document.getElementById(ret).style");
}
else {
if (document.all) {
var page = eval(document.all.ret.style);
}
}
}
irany = ir;
sebesseg = parseInt(seb);
var y_pos = parseInt(page.top);
var x_pos = parseInt(page.left);
// if there are links to images on the layer, they have to be rotated
var tombnev = reteg + "kepek";
//checks, if there are image links on the layer
if ((tombnev == "kapcsol98kepek") || (tombnev == "madridkepek") || (tombnev == "szimp99kepek") || (tombnev == "szimpoz97kepek") || (tombnev == "kiallit96kepek") || (tombnev == "usakepek")) {
var selector = (eval(y_pos)-140)/40*-1;
var egesz = Math.floor(selector) + 1;
var egeszelotti = eval(egesz) -1;
var egeszutani = eval(egesz) +1;
tombnevreal = eval(tombnev);
tombhosszreal = eval(tombnevreal.length);
var j = eval(egesz) *5;
if ((tombhosszreal -6 < j ) && (irany = &quot;le&quot;)){
// loop = false, the scroll changesdirection, it goes up now (irany = direction, fel = up)
irany = &quot;fel&quot;;
}
if ((k != j) && (tombhosszreal -6 > j )){
var tombnev = reteg + &quot;kepek&quot;;
tombnevarr = eval(tombnev);
var adott = reteg +&quot;belso&quot; + egesz;
var adottelotti = reteg +&quot;belso&quot; + egeszelotti;
var adottutani = reteg +&quot;belso&quot; + egeszutani;
// this part is just for highlighting the selected link
WM_swapLayerBgcolor(adott,'#ccffff solid 1px','red');
// the kepreszab function displays the images, on another layer
kepreszab(tombnevarr[j],tombnevarr[j+1],tombnevarr[j+2],tombnevarr[j+3]);
WM_swapLayerBgcolor(adottelotti,'0px','');
WM_swapLayerBgcolor(adottutani,'0px','');
}
k=j;}
// if there are no images to rotate, the scroll continues here
if (loop == true) {
if (irany == &quot;le&quot;) {
page.top = (y_pos - (sebesseg));
} else {
if (irany == &quot;fel&quot; && y_pos < 130) {
page.top = (y_pos + (sebesseg));
} else {
if (irany == &quot;bal&quot; && x_pos > -800) {
page.left = (x_pos - (sebesseg));
} else {
if (irany == &quot;jobb&quot; && x_pos < 260) {
page.left = (x_pos + (sebesseg));
} else {
if (irany == &quot;top&quot;) {
page.top = 10;
}
}
}
}
}
scrolltimer = setTimeout(&quot;gorog(irany,sebesseg,true,ret)&quot;, 1);
}
}
function stopgorog() {
loop = false;
clearTimeout(scrolltimer);
}
// scrolling script ends -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top