[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Smooth Show/Hide Effects? Is there a way?

Posted on 2004-08-23
4
Medium Priority
?
363 Views
Last Modified: 2012-05-05
Can anyone make the show/hide effect of this script smooth?

basically I want the content to have an animated crisp, smooth and fast drop down..

script will be available in next post..
0
Comment
Question by:andreni78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:andreni78
ID: 11877855

<script>
var imgs=["http://www.opera.com/graphics/buttons/red_buy.gif","http://www.opera.com/graphics/buttons/red_dl.gif"]
function toggle(obj,nm)
{
     obj.src=obj.src==imgs[0]?imgs[1]:imgs[0];
     theDiv=document.getElementById(nm);
     theDiv.style.display=theDiv.style.display=="none"?"":"none";
}
</script>
Body:
<table border=0>
<tr>
     <td>
          <img src=http://www.opera.com/graphics/buttons/red_dl.gif onClick="toggle(this,'Arts')" border=0>
     </td>
</tr>
<tr>
     <td>
        <div id="Arts" style="position: relative; display:none;">
          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content
     </div>
     </td>
</tr>
</table>
0
 
LVL 10

Accepted Solution

by:
m8rix earned 2000 total points
ID: 11878528
<html>

<head>
<title></title>
</head>

<body>
<script>

var imgs=["http://www.opera.com/graphics/buttons/red_buy.gif","http://www.opera.com/graphics/buttons/red_dl.gif"]
function toggle(obj,nm)
{
     obj.src=obj.src==imgs[0]?imgs[1]:imgs[0];
     theDiv=document.getElementById(nm);
     theDiv.style.top=getOffsetTop(obj)+23;
     theDiv.style.left=getOffsetLeft(obj);
     theDiv.style.pixelWidth=document.body.offsetWidth-50
     theDiv.style.display=theDiv.style.display=="none"?"":"none";
     animate(theDiv.id);
}
function animate(obj){
objID = document.getElementById(obj);
objID.style.color='#D1CCC5';
objID.style.pixelHeight=1
      if (objID.style.display ==""){
            changeheight(obj);
      }
}

function changeheight(obj,height){
objID = document.getElementById(obj);
if (height==undefined){height=1;}
objID.style.pixelHeight=height
//if (height==11){alert(objID.style.innerHeight);}
if (height<300){
  setTimeout("changeheight('" + obj + "'," + (height+5) + ")",5);}
else {objID.style.color='#000000';}
}

function getOffsetLeft (el) {
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}

function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
   ot += el.offsetTop;
  return ot;
}
</script>
Body:
<table border=0>
<tr>
     <td>
          <img src=http://www.opera.com/graphics/buttons/red_dl.gif onClick="toggle(this,'Arts')" border=0 width="128" height="23">
     </td>
</tr>
<tr>
     <td>
        <div id="Arts" style="width:300;padding: 5px; position: absolute; display:none; background: #D1CCC5; overflow: hidden; height:1px;border: 1 solid #663300;color:#D1CCC5;">
          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content          Some content         Some content         Some content
         Some content
     </div>
     </td>
</tr>
</table>
</body>

</html>
0
 

Author Comment

by:andreni78
ID: 11878828
very nice work!! but.. . it's not working right on my form.. it goes down smoothly but:

1. not fast enough
2. it makes my centered webpage turn to left indent
3. my form within the <div></div> is actually longer than what this script is set to go down... so it stops abruptly...

so if you could make this script relative to it's surroundings.. that would be fantastic.. and no grays please =)

looks like u spent a lot of time writing this script.. so i'll make another post requesting fixes...
0
 
LVL 10

Expert Comment

by:m8rix
ID: 12186729
Thanks for the feedback, as you may have probably noticed I have been away for a month. Is everything in order now or do you still require some assistance?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question