Solved

Javascript animating div resize

Posted on 2015-01-13
3
124 Views
Last Modified: 2015-01-22
Hi Experts

I was trying to resize a div through animation, and I could fairly say that I've made it, however looking at the code, it sounds somehow lame and too many lines. Can we write it in a more professional way, like reducing the code lines ?

A workable example is attached for ease of reference, and here's an explanation of the variables:

objCtrl: a reference to an object to be resized (can be a div or panel)
blnSH: a Boolean variable indicate whether we should handle visibility.
intWS: starting object width
intHS: starting object height
intWE: object width
intHE: object height
dblWN: the new width value
dblHN: the new height value
dblWV: its the width value to be added or subtracted on interval
dblHV: its the height value to be added or subtracted on interval.

Many thanks indeed.
Default.aspx
0
Comment
Question by:Faraj1969
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
louisfr earned 500 total points
ID: 40549198
Did you try using a transition effect? http://www.w3schools.com/Css/css3_transitions.asp

There's also this page about transitions and animations using javascript: http://css-tricks.com/controlling-css-animations-transitions-javascript/
0
 

Author Comment

by:Faraj1969
ID: 40560748
Hi, I'm requested to make the project compatible with CSS 2, therfore first link doesn't help. I've reviewed the second one when I started writing the script, but it didn't really help either. Thanks.
0
 

Author Closing Comment

by:Faraj1969
ID: 40564359
Thanks for the efforts.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now