DOM Throbber

Download

for modern JavaScript interpreters

KHI End User License Agreement:

I’m sure you don’t like reading these stupid things any more than I like writing them, so we’ll keep it short and sweet:

  1. This software is provided to you, for your own personal, private use, without any kind of warranty or promise of support whatsoever.
  2. You are licensed to use this software, not to distribute it or sell it. I ask that you please not mirror any files which I have not explicitly relinquished my exclusive copyright to anywhere without prior authorization.

Sound cool to you?

After spending a great deal of time attempting to implement a flicker-free Aqua style throbbing UI element in both the script.aculo.us and mootools frameworks it became obvious that neither products’ developers really wanted anyone to do this. Add to that the fact that they both introduce ridiculous amounts of bloat, doing it yourself becomes a no-brainer.

A brief summary of my Throbber class’ configuration options, all of which are optional and most can be specified at either instantiation or runtime:

  • frameDelay: Milliseconds between frames. Defaults to 30.
  • frequency: Cosine oscillation frequency. Defaults to 3.
  • limit: Total number of cycles. 0 will yield infinite oscillation.
  • sampleRate: Number of sample points per wave period. Defaults to 15; higher rates are usually overkill.
  • origOpacity: Initial element opacity. Defaults to whatever's current at the start of oscillation.
  • targetOpacity: The opacity level the oscillation should stop at. Defaults to whatever's current at the start of oscillation.
  • maxOpacity: The highest level of opacity the element should be drawn at during oscillation. Defaults to 100%.
  • minOpacity: The lowest level of opacity the element should be drawn at during oscillation. Defaults to 0%.
  • stillborn: Set to true on instantiation if you want to start the throb manually in response to a DOM or AJAX event.