DOCJSLIB Version 4.0: The Scroller Code - www.docjavascript.com
The Scroller Code
var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;
var holdingImage = document.images["holdspace"];
var canvasLeft = docjslib_getImageXfromLeft(holdingImage);
var canvasTop = docjslib_getImageYfromTop(holdingImage);
var canvasWidth = docjslib_getImageWidth(holdingImage);
var canvasHeight = docjslib_getImageHeight(holdingImage);
var Gtimer = "";
var upperPage = "";
var lowerPage = "";
var arBody = new Array();
function onElementLoad(element, doThat, theseParameters) {
if (NS4) eval(element).onLoad = eval(doThat)
else eval(doThat + theseParameters);
}
function moveUp() {
docjslib_moveVertically(firstPage, -Gincrement);
docjslib_moveVertically(secondPage, -Gincrement);
if (docjslib_getElementTop(lowerPage) <= 0) {
docjslib_moveVertically(upperPage,
docjslib_getElementHeight(upperPage) * 2);
// (The above two lines should be joined as one line.
// They have been split for formatting purposes.)
rotateThePages();
}
}
function rotateThePages() {
if (upperPage == firstPage) {
upperPage = secondPage;
lowerPage = firstPage;
return true;
}
upperPage = firstPage;
lowerPage = secondPage;
return true;
}
function scrollPages() {
Gtimer = setInterval("moveUp()", Ginterval);
}
function stopScrolling() {
clearInterval(Gtimer);
}
function launchScroller() {
docjslib_setElementTop(secondPage,
docjslib_getElementHeight(secondPage));
// (The above two lines should be joined as one line.
// They have been split for formatting purposes.)
scrollPages();
}
function fillSecondPage() {
secondPage = new Layer(canvasWidth - GleftPadding,canvas);
secondPage.clip.width = canvasWidth - GleftPadding;
secondPage.src = Gsrc;
}
function makeSecondPage() {
if (NS4) fillSecondPage();
docjslib_setElementLeft(secondPage, GleftPadding);
secondPage.onmouseover = stopScrolling;
secondPage.onmouseout = scrollPages;
lowerPage = secondPage;
docjslib_setElementVisibility(secondPage, true);
onElementLoad(secondPage, "launchScroller", "()");
}
function fillFirstPage() {
firstPage = new Layer(canvasWidth - GleftPadding, canvas);
firstPage.clip.width = canvasWidth - GleftPadding;
firstPage.src = Gsrc;
}
function showAndScroll() {
if (NS4) fillFirstPage();
docjslib_setElementLeft(firstPage, GleftPadding);
docjslib_setElementTop(firstPage, 0);
docjslib_setElementVisibility(firstPage, true);
upperPage = firstPage;
firstPage.onmouseover = stopScrolling;
firstPage.onmouseout = scrollPages;
onElementLoad(firstPage, "makeSecondPage", "()");
}
function fillAllPages() {
var text = '<DIV ID="canvas" STYLE="position:absolute">';
text += '<DIV ID="firstPage" STYLE="position:absolute">'
+ arBody[0].innerHTML + '</DIV>';
// (The above two lines should be joined as one line.
// They have been split for formatting purposes.)
text += '<DIV ID="secondPage" STYLE="position:absolute">'
+ arBody[0].innerHTML + '</DIV>';
// (The above two lines should be joined as one line.
// They have been split for formatting purposes.)
text += '</DIV>';
document.body.insertAdjacentHTML("BeforeEnd", text);
}
function makeCanvas() {
if (IE4) {fillAllPages();}
else {canvas = new Layer(canvasWidth);}
docjslib_createClipRegionAt00(canvas, canvasWidth, canvasHeight);
docjslib_setElementWidth(canvas, canvasWidth);
docjslib_setElementHeight(canvas, canvasHeight);
docjslib_setElementLeft(canvas, canvasLeft);
docjslib_setElementTop(canvas, canvasTop);
docjslib_setElementBgColor(canvas, GcanvasColor);
docjslib_setElementVisibility(canvas, true);
}
function fillCanvas() {
if (IE4) {arBody =
document.frames("scroll").document.all.tags("BODY");};
// (The above two lines should be joined as one line.
// They have been split for formatting purposes.)
makeCanvas();
setTimeout("showAndScroll()", Gdelay);
}
function startCanvas() {
if (NS4) {fillCanvas();}
else {document.all.tags("IFRAME").item("scroll").src = Gsrc;}
}
window.onload = startCanvas;
Produced by Yehuda Shiran and Tomer Shiran
Created: January 4, 1999
Revised: January 4, 1999
URL: https://www.webreference.com/js/column33/code1.html