PDA

View Full Version : Conveyor belt -repeat function?



hilldomain
12-17-2005, 08:32 AM
I was wondering what part of the conveyor belt script makes the pictures loop like that- I want to pik it apart and learn a little.

Iiro
12-17-2005, 08:42 AM
What do you mean? I can't understand.

jscheuer1
12-17-2005, 09:25 AM
The basic 'trick' used to make this slideshow continuously looping is that the data for the content (from the array at the top of the script, where you enter your images) is written to two absolutely positioned divisions:


cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide

The left coordinates are then constantly shifted. The one that is not visible, at any given moment, is moved all the way to the 'rear' of the one that is being displayed. When the current one moves off screen the other is already following behind it:


if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

hilldomain
12-17-2005, 02:36 PM
If I understand you correctly you are just doubling the content and they follow each other? I was trying to create a similar effect with another script but I think it wouldnt work doubling the content it would make the page load slower. Thanks.

this is the code I am trying to alter- not similar at all. There is a reset feature but I just want it to loop the content and keep scrolling. I got it to pause (really stop) on mouse over and start again on mouseout.
I beleive I have to create something that will recognize where the scroller layer is at and when it reaches a particular place- tell it to return to the original coordinates- which means I have to define the original coordinates as variables i guess.

I am really not a programmer or scriptor. If anyone can point me in the right direction to learn more that would be appreciated.

CODE
function P7_HScroller(el,dr,tx,ox,spd) { //v1.7 by PVII
var g,gg,fr,sp,pa='',slw=true,m=false,w,ww,lx,rx;tx=parseInt(tx);
if((g=MM_findObj(el))!=null){gg=(document.layers)?g:g.style;}else{return;}
if(dr=="Stop"){if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}

if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& !window.opera){pa="px";}
if(navigator.userAgent.indexOf("NT")>-1 || navigator.userAgent.indexOf("Windows 2000")>-1){slw=false;}
//speed settings?
if(spd=="Slow"){sp=(slw)?2:1;fr=(slw)?40:30;}else if(spd=="Medium"){sp=(slw)?4:1;fr=(slw)?40:10;
}else{sp=(slw)?8:4;fr=(slw)?40:10;}if(spd=="Warp"){sp=5000;}var xx = parseInt(gg.left);if(isNaN(xx)){
if(g.currentStyle){xx=parseInt(g.currentStyle.left);}else if(document.defaultView&&document.defaultView.getComputedStyle){
xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}else{xx=0;}}

if(document.all || document.getElementById){w=parseInt(g.offsetWidth);if(!w){w=parseInt(g.style.pixelWidth);}
if(g.hasChildNodes){for(wx=0;wx<g.childNodes.length;wx++){ww=parseInt(g.childNodes[wx].offsetWidth);
if(ww>w){w=ww;}}}}else if(document.layers){w=parseInt(g.clip.width);}lx=tx-w+parseInt(ox);rx=tx;
if(dr=="Right"){if(xx>lx){m=true;xx-=sp;if(xx<lx){xx=lx;}}}
if(dr=="Left"){if(xx<rx){m=true;xx+=sp;if(xx>rx){xx=rx;}}}
if(dr=="Reset"){gg.left=tx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=false;}
if(m){gg.left=xx+pa;if(g.toMove){clearTimeout(g.p7Magic);}g.toMove=true;
eval("g.p7Magic=setTimeout(\"P7_HScroller('"+el+"','"+dr+"',"+tx+","+ox+",'"+spd+"')\","+fr+")");
}else{g.toMove=false;}
}

jscheuer1
12-17-2005, 04:37 PM
I was trying to create a similar effect with another script but I think it wouldnt work doubling the content it would make the page load slower. Thanks.

Double text won't add much to page load time unless it is a really huge amount of text. Images, will load much faster the second time, as they are cached and, if not yet visible, can take their time anyway.

irishchef
12-17-2005, 05:33 PM
can anyone explain what I am doing wrong? I am trying to put the falling snowflakes on our web homepage. All I see are falling Square boxes with little no image of the flakes??
I have saved the snowflake gif to my home files folder which is where I would normally save any images!
If someone could email me on
info@thechefshop.net
I would be very grateful
Thanks
Vincent