It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Sliding Menus fix

Sliding Menus fix

Postby howegraphics on Fri Jan 22, 2010 11:50 am

I virtually know no javascript, but have been trying to create some sliding menus. 4 Menus along the bottom of the screen that on mouse over, a sub menu slides up from them.

I managed to get them to work to slide up, but then when I put the code in to slide back down again it started spazzing out!

Can anyone help at all? Here's my javascript code.

Code: Select all
<script type="text/javascript">

var curVisible;
var oldObject;
var pusher;
var pushBack;
var inMotion = false;

function reveal(obj) {

   if(curVisible != null) {
      oldObject = curVisible;
   }

   if(!inMotion) {
      curVisible = obj;      
      pusher = -100;
      pushBack = 40;
      document.getElementById(obj).style.visibility = "visible";
      document.getElementById(obj).style.bottom = pusher+"px";
      animateOut();
      animateIn();
   }
}

function hide() {
   animateIn();
}


function animateIn() {
   if (pushBack > -100) {
      inMotion = true;
      pushBack -=4;
      document.getElementById(oldObject).style.bottom = pushBack+"px";
      setTimeout(animateIn, 20);
   } else {
      document.getElementById(oldObject).style.visibility = "hidden";
      inMotion = false;
   }
}


function animateOut() {
   
   if(pusher < 40) {
      inMotion = true;
      pusher += 4;
      document.getElementById(curVisible).style.bottom = pusher+"px";
      setTimeout(animateOut, 20);
   } else {
      inMotion = false;
   }
}

</script>


Thanks very much. Have tried loads, but just can't seem to get it to work. It's a lot more complicated than I first thought.

Dave
howegraphics
 
Posts: 2
Joined: Fri Jan 22, 2010 11:46 am

Re: Sliding Menus fix

Postby howegraphics on Fri Jan 22, 2010 12:40 pm

OOOO Fixed It!!!!!!

Before I didn't have my order sorted out and never thought it was affect functionality, but just by putting a z-index on the sliding list so that it went behind the bottom menu it now works.

I'm guessing because maybe before because the list was getting between the mouse and the menu at the bottom so it then thought it wasn't mouse over any more or something like that? But now that it goes behind the whole bar at the bottom it works fine!!

Cheers anyway guys.
howegraphics
 
Posts: 2
Joined: Fri Jan 22, 2010 11:46 am


Who is online

Users browsing this forum: No registered users and 2 guests