This is now working. It uses the mouse position to go up or down and control the speed....
To give the impression of a continuous scroll we divided the height by 2 and repeated the content twice. So when it resets it is in the same position..
take a look at the right bar here:
http://www.savvior.com/8sharp/pmw/
Code:
<script language="JavaScript1.2">
<!--
/***********************************************
* IFRAME Scroller script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Specify speed of scroll. Larger=faster (ie: 5)
var scrollspeed=cache=2;
//Specify intial delay before scroller starts scrolling (in miliseconds):
var initialdelay=500;
// all of the following stuff is just to get the mouse(x,y)
// in a browser-compatible way....
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
// Main function to retrieve mouse x-y pos.s
// (get the mouse x, y coordinates and set the scrollspeed var accordingly)
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
//document.Show.MouseX.value = tempX;
//document.Show.MouseY.value = tempY;
if(tempX >= 0 && tempX <= 158 && tempY >= 0 && tempY <= 530)
bInDiv = true;
else
bInDiv = false;
//document.Show2.inDiv.value = bInDiv;
//document.Show2.yOffset.value = tempY - 265;
//if (bInDiv)
scrollspeed = (8 * ((tempY - 265) / 265 ));
return true
}
// end mouse x,y stuff
//
// attach listener (different for each browser)
if (window.addEventListener)
window.addEventListener("load", initializeScroller, false);
else if (window.attachEvent)
window.attachEvent("onload", initializeScroller);
else
window.onload=initializeScroller;
function initializeScroller(){
// get the object reference for the div
dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer");
// set the div vertical position
dataobj.style.top="5px";
// do function after 1/2 second
setTimeout("getdataheight()", initialdelay);
}
function getdataheight(){
// get the object's height (half)
thelength=dataobj.offsetHeight/2-2;
if (thelength==0)
setTimeout("getdataheight()",10);
else
scrollDiv();
}
function scrollDiv(){
// set the vertical position of the div
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px";
// if the position is smaller than the height then reset
if (scrollspeed > 0) {
if (parseInt(dataobj.style.top)<thelength*(-1))
dataobj.style.top="5px";
}
else {
if (parseInt(dataobj.style.top)>0)
dataobj.style.top = (parseInt(dataobj.style.top) - (thelength)) + "px";
}
setTimeout("scrollDiv()",40);
}
//-->
</SCRIPT>
Bookmarks