Cascading Menu scripts

G

gregory stevenson

I am looking for a simple cascading menu javascript.One where it lives on
the left side of the screen, listed vertically and when you select a menu
item the list expands to show the sub menu items within that catagory.

This is the only decent one I've been able to find.
http://www.bravenet.com/resources/scripts/script.php?script_id=92&cat_name=

If you check out the demo you'll notice it's very slow. It has a speed
variable but it only seems to make it slower.

Another example of close to what I'm trying to accomplish (my first
inspiration):
http://www.ataonline.com/about/media/index.asp

If anyone knows how to speed up the first one, or knows of another SIMPLE
expanding cascading script please let me know. I'm trying to make this as
cross browser as possible as well. I know it's a lot to ask on a no budget
project, but thought I'd ask anyways.

Thanks,

Steven LaPha Jr.
 
L

Lasse Reichstein Nielsen

gregory stevenson said:

I would be worried using it. I can see a few bad methods used, e.g.,
setting the obj.style.top without a unit, which *will* fail in most
browsers in standards mode.
If you check out the demo you'll notice it's very slow. It has a speed
variable but it only seems to make it slower.
Yes

If anyone knows how to speed up the first one, or knows of another SIMPLE
expanding cascading script please let me know.

The speed is used as the second argument of the setTimeout, and
defaults to 0, so that's as fast as it gets.

What you can do, is to change by how many pixles it moves per timeout.
I.e., the line
obj.style.top = parseInt(obj.style.top)-1;
can be changed to
obj.style.top = Math.max(parseInt(obj.style.top,10)-5,0) + "px";
A line furter down reads
nowv--;
Change that to
nowv-=5;
and it moves five times as fast when it closes. There is probably an equivalent
code for moving down.

/L
 
G

gregory stevenson

Ok here's what I got,
Only problem is now the menu boxes overlap when compressed, and have an
extra space when expanded. Not too big of a problem, but probably solvable.
It IS faster though, much more managable.
Now that many have high speed networks, and faster computers who wants to
wait for a slow menu that acts as if it's on a 486?

------------------------clipped script------------------------
function epull_down(nr,to,nowv)
{
name = "down" + (nr-1);
obj = document.getElementById(name).style.clip =
"rect(0,"+width+","+(+nowv+1)+",0)";
for (i=nr;i<self_menu.length;i++)
{
name = "down" + i;
obj = document.getElementById(name);
obj.style.top =Math.max(parseInt(obj.style.top,10)+5,0)+"px";
}
nowv+=5;
if(nowv < to) timerID =
setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
else timerID = "";
}

function epull_up(nr,to,nowv)
{
name = "down" + (nr-1);
obj = document.getElementById(name).style.clip =
"rect(0,"+width+","+nowv+",0)";
for (i=nr;i<self_menu.length;i++)
{
name = "down" + i;
obj = document.getElementById(name);
obj.style.top = Math.max(parseInt(obj.style.top,10)-5,0)+"px";
}
nowv-=5;
if(nowv > to) timerID =
setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
else timerID = "";


-------------------------end cliped script---------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top