aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes enlarging image with a constant speed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "enlarging image with a constant speed" Watch "enlarging image with a constant speed" New topic
Author

enlarging image with a constant speed

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
How to provide delay in Javascript? I know about setTimeOut function. But what I mean is, enlarging a image slowly or something like that. Is there any easy way to do this? I am trying to do the same by setTimeOut function like this:



I think, it should work. But unknowingly alert(imgObj.height); returns undefined. Why I am not able to pass image object properly from one function to another?

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
you should be using

obj.style.height = yourVar + "px";

Eric
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
For some reason, style also didn't work. It is not identifying image object as image object at all.
I declare variable globally to assign image object and avoid using the passing of image object to setTimeout function..
Here is the edited code snippet..


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
this is bad anyway:

for(var i=currHeight; i>=50; i = i-5) {setTimeout("setImageSize('"+i+"', '"+i+"')",5);}

You are doing a for loop, all of this 5 seconds will be fired at basically the same time if your code worked.

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The way you want to code it would be something like this:



Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enlarging image with a constant speed