Solved

Resize with animation of a DIV layer

Posted on 2006-06-28
7
868 Views
Last Modified: 2013-11-19
I have a div that starts off as hidden. I want it to slide in to a fixed size on click.

It is used in a graph, the size-in is for effect.

Where t is the finished size for top
where w is the finished size for width
and h is the finished size for height.


<div id="Layer1" style="position:absolute; left:102px; top:<cfoutput>#t#</cfoutput>px; width:<cfoutput>#w#</cfoutput>px; height:<cfoutput>#h#</cfoutput>px; z-index:1; visibility:hidden;">
 <table width="100%" height="100%">
  <tr>
    <td class="expired">&nbsp;</td>
  </tr>
</table>
</div>

at the moment I snap it in by using
<a href="#" onClick="Layer1.style.visibility='visible';"><img name="transperantcfm_r1_c2" src="fireworksimages/transperant.cfm_r1_c2.gif" width="420" height="19" border="0" alt=""></a>

any ideas???
0
Comment
Question by:kleigh
[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
  • 4
  • 3
7 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 17007183
Any questions???
0
 

Author Comment

by:kleigh
ID: 17011173
i'm sorry... the question is? How do I show and resize a DIV on click with some annimation effects?
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 17013660
The starting point is already good.
But you need a function for the move initialization and a second function for move steps.
You call the initialization function like this:

<a href="#" onClick="startMove('Layer1',100,200,300);return false;"><img name="transperantcfm_r1_c2" src="fireworksimages/transperant.cfm_r1_c2.gif" width="420" height="19" border="0" alt=""></a>

The initialization function looks like this:
<script>
var theDiv, dTop, dWidth, dHeight, tStep;
var xStep = 10;
var xFact = 10;
function startMove(divID,t,w,h){
  theDiv = document.getElementById(divID);
  dTop = t;
  dWidth = w;
  dHeight = h;
  theDiv.style.visibility="visible";
  tStep = setTimeout("doMove()", xStep);
}

// and this is the stepper move function:

function doMove(){
  var xT = dTop - theDiv.offsetTop;
  var xW = dWidth - theDiv.offsetWidth;
  var xH = dHeight - theDiv.offsetHeight;
  if(xT+xW+xH!=0){
    theDiv.style.top = theDiv.offsetTop+(xT/xFact);
    theDiv.style.width = theDiv.offsetWidth+(xW/xFact);
    theDiv.style.height = theDiv.offsetHeight+(xH/xFact);
    tStep = setTimeout("doMove()", xStep);
  }
}
</script>


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kleigh
ID: 17018061
Zvonko:
I must be missing something.
I tried your script an there is no annimation? it just snaps in.

here is how i wrote it, and i am sure i messed something up

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../CSS/NewMessageCenterSKIN.css" rel="stylesheet" type="text/css" />


<script>
var theDiv, dTop, dWidth, dHeight, tStep;
var xStep = 10;
var xFact = 10;
function startMove(divID,t,w,h){
  theDiv = document.getElementById(divID);
  dTop = 500;
  dWidth = 500;
  dHeight = 500;
  theDiv.style.visibility="visible";
  tStep = setTimeout("doMove()", xStep);
}

// and this is the stepper move function:

function doMove(){
  var xT = dTop - theDiv.offsetTop;
  var xW = dWidth - theDiv.offsetWidth;
  var xH = dHeight - theDiv.offsetHeight;
  if(xT+xW+xH!=0){
    theDiv.style.top = theDiv.offsetTop+(xT/xFact);
    theDiv.style.width = theDiv.offsetWidth+(xW/xFact);
    theDiv.style.height = theDiv.offsetHeight+(xH/xFact);
    tStep = setTimeout("doMove()", xStep);
  }
}
</script>
</head>

<body>
<div id="Layer1" style="position:absolute; left:102px; top:200px; width:200px; height:200px; z-index:1; visibility:hidden;">
 <table width="100%" height="100%">
  <tr>
    <td class="expired">&nbsp;</td>
  </tr>
</table>
</div>

<a href="#" onClick="startMove('Layer1',300,500,300);return false;">test</a>

</body>
</html>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17018179
I see it sliding, but of course first after inserting some visible text:
<td class="expired">&nbsp;Here Some Text</td>

0
 

Author Comment

by:kleigh
ID: 17018408
Silly Me.... Thanks a lot.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17018423
You are welcome.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Javascript Regex 7 20
Timer on div 5 24
replacing inline javascript with jquery 4 46
Table doesn't show the lines! 3 24
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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)

733 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