Topic awaiting preservation: Minimizing a Fade Script's Demand on a Machine |
|
---|---|
Author | Thread |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 07-22-2005 19:30
I developed this fade script for use in a site I'm working on, but I and the "boss" have noticed that it can create somewhat of a demand on a user's machine, especially if the machine is a slower one. (The Big Man says his laptop gets pretty bogged down.) |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 07-25-2005 23:05 |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 07-25-2005 23:16
I'd try rewriting it using setInterval instead of setTimeout. Then you have one timer that handles all the fading each time it loops through. Right now you are firing a ton of Timeouts which can have a negative effect. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 07-25-2005 23:20
Something like so code: function fadeImage(imageName) { this.image = document.getElementById(imageName); this.state = 0 //0 nothing 1, fading in, 2 fading out this.fadeIn = new function() { // do fade in } this.fadeOut = new function() { // do fade out } this.increment = new function() { switch(this.state) { case 0: // do I start a new fade? case 1: // continue fading } } } Anyway I hope this helps.
|
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 07-25-2005 23:21 |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 07-26-2005 00:35
** bored at work ** |
Paranoid (IV) Mad Scientist From: Inside THE BOX |
posted 08-01-2005 21:34
quote:
|