jQuery Spinner Plugin

In an earlier post, I put together a package of several spinner images for your Web 2.0 apps, however it was a bit lacking as far as scripting and programming goes. To make full use of the PNG “filmstrip” style spinners, you’ll need a bit of JavaScript to make them go.

If you use the exceptional jQuery JavaScript library to make your software shine, you’ll be able to easily load and run the PNG spinners with this little jquery.spinner.js plugin I put together. Included in the package is a simple HTML file detailing how to use the plugin, but the basics are as follows:

After including jquery.js (or jquery.pack.js) and jquery.spinner.js in your HTML head, set up an empty div and call the .spinner function with some simple parameters:

$(“#spinme”).spinner({ height: 48, width: 48, speed: 50, image: ’spotlight_spinner_big.png’ });

You can pass width, height, frame speed, and an image URL to set up the spinner, as well as call $.spinnerStop(); to halt the spinner.

While I’ve worked on a few jQuery plugins before, I’m not entirely sure all the programming conventions I’ve used are “correct” (like the global $.spinnerStop). That in mind, if you find any bugs or notice an issue, please let me know, and I’ll update the plugin as soon as possible. Get the plugin here.

Special thanks to the talented Rogie King for some last-minute fixes!

5 Responses to “jQuery Spinner Plugin”

  1. doesn’t seem to work in IE7

  2. phatrax: It works on IE7 for me. Make sure you are using a block element when setting up the HTML.

    This is a great and very small spinner plugin, thanks so much.

    I just have one problem: How can I get it onto the same line with some text? I want to display:

    Loading (spinner here)

    Somehow I cannot get this right with CSS, although I don’t consider myself a newbie to CSS :-(

  3. Great great plug-in! Would be nice to have better support for multiple spinner per page. Multiple spinner seems ok as long as you use the same picture. It’s kind of broken if your try to use different picture for each spinner.

  4. I’ve modified your brilliant plug-in to fully support multiple spinner per page. I also made the API jQuery UI look alike. It’s been published as part of a TWiki plug-in on http://twiki.org/cgi-bin/view/Plugins/JQueryDevPlugin.
    You can check out a demo there http://slion.net/view/Sandbox/PluginTestJQueryDevPlugin.

    Thanks a bunch ;)

  5. Here are the links again:
    http://twiki.org/cgi-bin/view/Plugins/JQueryDevPlugin
    https://slion.net/view/Sandbox/PluginTestJQueryDevPlugin

Leave a Reply