Jump to content

sliding <div>


watagal

Recommended Posts

Greetings again,I have my forms (registration, login, etc) in <div> containers. I can hide/show them just fine by clicking on an anchored link at the top of my page. The forms appear directly below the link.I want to now slide them down into view and slide them up out of view (overlapping the current HTML page content). I found the following code at ( http://w3schools.invisionzone.com/index.php?showtopic=9500 ):

function shiftMe(object, direction, pixels) {    if (pixels == 0) return;    var obj = document.getElementById(object);	// if (obj.style.marginLeft == "") obj.style.marginLeft="0px";    if (obj.style.marginTop == "") obj.style.marginTop="0px";	// var marginLeftVal = obj.style.marginLeft;// var marginLeftInt = new Array();// marginLeftInt = marginLeftVal.split('p');    var marginTopVal = obj.style.marginTop;    var marginToptInt = new Array();    marginTopInt = marginTopVal.split('p');		// if (direction == "r")    marginLeftInt[0]--;// if (direction == "l")    marginLeftInt[0]++;    if (direction == "u")    marginTopInt[0]--;    if (direction == "d")    marginTopInt[0]++;	// obj.style.marginLeft = marginLeftInt[0]+"px";    obj.style.marginTop=marginTopInt[0]+"px";	    pixels--;    timer = setTimeout('shiftMe("'+object+'","'+direction+'",'+pixels+')',1);}

I can get the original code demo to work fine, but when I modify it to slide the <div> up/down - I got nothing. Can someone point me in the right direction?TIA, Gal

Link to comment
Share on other sites

ok, I've got some movement by adding some code to actually turn on the display of the <div>:

obj.style.display = "block";

But this doesn't slide it into place - rather popping it on.ideas?Gal

Link to comment
Share on other sites

Try increasing the timeout. It might be going too quickly.timer = setTimeout('shiftMe("'+object+'","'+direction+'",'+pixels+')',20);If that's doing the same thing, post the modified code you're using.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...