[Javascript] Image rotation.

Paul Novitski paul at novitskisoftware.com
Tue Feb 14 23:31:58 CST 2006


At 12:05 PM 2/14/2006, Shawn Milo wrote:
>If the setTimout() has already been called, is there a way to cancel 
>it, or would I have to just change a flag or something when a 
>thumbnail is clicked, and know to reverse the change?

How about this:  declare a RotationCountdown variable initialized to, 
say, 10.  Each time your primary timeout wakes up, it decrements 
RotationCountdown.  When it decrements RotationCountdown to zero, it 
sets it back to 10 and rotate the thumbnails.

Other events can set RotationCountdown as well.  Each keypress and 
mousemove sets it back to 10 to suspend rotation for N seconds after 
the last user action.  Clicking on a thumbnail halts rotation (by 
setting RotationCountdown to a negative number?), while completing a 
large image load resets it to zero to begin rotation again.

Isn't it wonderful the way the simplest bud can blossom into a mighty project?

P. 




More information about the Javascript mailing list