richie-c
01-16-2008, 10:28 PM
Can anyone help with this code... its based on this here..
http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm
updated by the same guy and posted on another forum some time ago...
I'm just getting started with javascript, I have the menu in place it works fine, same as the example if you check the dynamic drive link above.
What I want is a delay on when the menu relocates itself, so it scrolls up/down with the page, when the scrolling stops it sits there for a couple of seconds, then relocates.. main reason is to get rid of the jagging effect you get when using a mouse wheel.
I've spent hours trying various things.. but haven’t had any luck, any help would be much appreciated.
Cheers Rich
-----------------------------------------------
function FloatMenu()
{
//Enter "frombottom" or "fromtop"
var verticalpos="fromtop";
var Xloc = 0;
Yloc = 0;
var ns = (navigator.appName.indexOf("Netscape") != -1);
function SetMenu(id)
{
var GetElements=document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
if(document.layers)GetElements.style=GetElements;
GetElements.sP=function(x,y){this.style.right=x+"px";this.style.top=y+"px";};
GetElements.x = Xloc;
if (verticalpos=="fromtop"){
GetElements.y = Yloc;
}
if (verticalpos!=="fromtop"){
GetElements.y = ns ? pageYOffset + innerHeight : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop + document.documentElement.clientHeight : document.body.scrollTop + document.body.clientHeight;
GetElements.y -= Yloc;
}
return GetElements;
}//SetMenu(id)
window.LoCate_XY=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop : document.body.scrollTop;
ftlObj.y += (pY - Yloc - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("LoCate_XY()", 10);
}
else{
var pY = ns ? pageYOffset + innerHeight : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop + document.documentElement.clientHeight : document.body.scrollTop + document.body.clientHeight;
var delay = py - ftlObj.y;
if (delay > 200){
ftlObj.y += (pY - Yloc - ftlObj.y)/8;
delay += (pY - Yloc - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("LoCate_XY()", 10);
}
}//window.LoCate_XY=function()
ftlObj = SetMenu("Floater");
LoCate_XY();
}//FloatMenu();
http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm
updated by the same guy and posted on another forum some time ago...
I'm just getting started with javascript, I have the menu in place it works fine, same as the example if you check the dynamic drive link above.
What I want is a delay on when the menu relocates itself, so it scrolls up/down with the page, when the scrolling stops it sits there for a couple of seconds, then relocates.. main reason is to get rid of the jagging effect you get when using a mouse wheel.
I've spent hours trying various things.. but haven’t had any luck, any help would be much appreciated.
Cheers Rich
-----------------------------------------------
function FloatMenu()
{
//Enter "frombottom" or "fromtop"
var verticalpos="fromtop";
var Xloc = 0;
Yloc = 0;
var ns = (navigator.appName.indexOf("Netscape") != -1);
function SetMenu(id)
{
var GetElements=document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
if(document.layers)GetElements.style=GetElements;
GetElements.sP=function(x,y){this.style.right=x+"px";this.style.top=y+"px";};
GetElements.x = Xloc;
if (verticalpos=="fromtop"){
GetElements.y = Yloc;
}
if (verticalpos!=="fromtop"){
GetElements.y = ns ? pageYOffset + innerHeight : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop + document.documentElement.clientHeight : document.body.scrollTop + document.body.clientHeight;
GetElements.y -= Yloc;
}
return GetElements;
}//SetMenu(id)
window.LoCate_XY=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop : document.body.scrollTop;
ftlObj.y += (pY - Yloc - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("LoCate_XY()", 10);
}
else{
var pY = ns ? pageYOffset + innerHeight : !window.opera && document.documentElement && document.documentElement.clientHeight ? document.documentElement.scrollTop + document.documentElement.clientHeight : document.body.scrollTop + document.body.clientHeight;
var delay = py - ftlObj.y;
if (delay > 200){
ftlObj.y += (pY - Yloc - ftlObj.y)/8;
delay += (pY - Yloc - ftlObj.y)/8;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("LoCate_XY()", 10);
}
}//window.LoCate_XY=function()
ftlObj = SetMenu("Floater");
LoCate_XY();
}//FloatMenu();