...

View Full Version : Horizontal custom scrolling



spenoir
07-06-2007, 01:15 PM
Below is my horizontal version of this article: http://www.quirksmode.org/js/layerscroll.html

If anyone would like to contribute to this horizontal scrolling script or can offer a more efficient solution, It would be great.

I personally think that it aint worth re-inventing the wheel but designers seem to think otherwise!


var clipTop = 0;
var clipRight = 500;
var clipBottom = 80;
var clipLeft = 0;
var topper = 300;
var wider = 800;
var lyrheight = 0;
var time,amount,theTime,theHeight,DHTML;

function initScroller()
{
var x = $('#scroller');
if (document.layers)
{
lyrheight = x.style.clip.bottom;
lyrheight += 80;

lyrwidth = x.style.clip.right;
lrywidth += 500;

x.style.clip.top = clipTop;
x.style.clip.left = clipLeft;
x.style.clip.right = clipRight;
x.style.clip.bottom = clipBottom;
}
else if (document.getElementById || document.all)
{
lyrheight = x.obj.offsetHeight;
lyrwidth = x.obj.offsetWidth;
x.style.clip = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
}
}

function scrollayer(layername,amt,tim)
{
var thelayer = document.getElementById(layername);
if (!thelayer) return;
amount = amt;
theTime = tim;
realscroll();
}

function realscroll()
{
clipRight += amount;
clipLeft += amount;
wider -= amount;

if (clipLeft < 0 || clipRight > lyrwidth)
{
clipRight -= amount;
clipLeft -= amount;
wider += amount;
return;
}
if (document.getElementById || document.all)
{
clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,'+clipLeft+'px)';
thelayer.style.clip = clipstring;
thelayer.style.right = wider + 'px';
}
else if (document.layers)
{
thelayer.style.clip.right = clipRight;
thelayer.style.clip.left = clipLeft;
thelayer.style.right = wider;
}
time = setTimeout('realscroll()',theTime);
}

/*
function realscroll()
{
clipTop += amount;
clipBottom += amount;
topper -= amount;

if (clipTop < 0 || clipBottom > lyrheight)
{
clipTop -= amount;
clipBottom -= amount;
topper += amount;
return;
}
if (document.getElementById || document.all)
{
clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
thelayer.style.clip = clipstring;
thelayer.style.top = topper + 'px';
}
else if (document.layers)
{
thelayer.style.clip.top = clipTop;
thelayer.style.clip.bottom = clipBottom;
thelayer.style.top = topper;
}
time = setTimeout('realscroll()',theTime);
}
*/
function stopScroll()
{
if (time) clearTimeout(time);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum