OZONE Asylum
Forums
DHTML/Javascript
how does set time out work?
This page's ID:
27991
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Hi, I'm designing a site that is going to have an application feel to it, and to do that i wrote transitions such as fade in and fade out. Unfortunetaly I can get it to work if i use setTimeout to specific time intervals, ie after fade out after 1.5 seconds fade in, but I would like not to have to do this. I am pulling html from another page using a get request that is working, that is my _Ajax.getHTMLFrom I know it's not commented verry well but the problem is in the first function _transition.fadeInTo. The other functions do work! I thought that when you used setTimeout it would spawn a new thread therefore i could just loop untill it was done however the browser frezes. so it is skiping the transition.fade call why???? I've been banging my head on the wall for a long time! ;) THANKS! [code] _transition = {}; _transition.fadeIsDone = true; //public functions _transition.fadeInTo = function(page,fadeObjectId) { info = _Ajax.getHMLFrom(page); _transition.fade(true,fadeObjectId); // while(!_transition.fadeIsDone) ;//wait(); _transition.fadeTarget.innerHTML = info; _transition.fade(false,fadeObjectId); // while(!_transition.fadeIsDone); } _transition.fade = function(mode,fadeObjectId) { _transition.fadeIsDone = false; _transition.fadeTarget = document.getElementById(fadeObjectId); switch(mode) { case true: window.setTimeout("_transition._fade(true,100)",50); break; case false: window.setTimeout("_transition._fade(false,0)",50); break; default: } } //private functions //mode can be true, false, or TOGGLE _transition._fade = function(mode,opacity) { var fadeTarget = _transition.fadeTarget; switch(mode) { case true: fadeTarget.style.filter = "alpha(opacity="+opacity+")"; opacity-=10; if(opacity > 0) window.setTimeout("_transition._fade(true,"+opacity+")",500); //call func again else _transition.fadeIsDone = true; break; case false: fadeTarget.style.filter = "alpha(opacity="+opacity+")"; opacity+=10; if(opacity < 100) window.setTimeout("_transition._fade(false,"+opacity+")",500); else _transition.fadeIsDone = true; break; case "TOGGLE": break; default: alert("Will not fade with mode "+mode); } } [/code] [small](Edited by [url=http://www.ozoneasylum.com/user/6218]knight[/url] on 05-25-2006 12:48)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »