Demo

Size: 64
Factor: 0.25
Speed: 1.0

About

AjaxLoader library allows to create spinning activity indicators dynamically. It can be used instead of GIF image ajaxloaders. The main features of this library are the following:

How to use

AjaxLoader.js can be added to your site in three simple steps:

  1. Include ajaxloader.js (or the minified version ajaxloader.min.js for production) in your page. For example:
    <script src="../ajaxloader.js"></script>
  2. Add to your page canvas object and set id.
    <canvas id="spinner"></canvas>
  3. Create AjaxLoader object and call function show():
    var ajaxLoader = new AjaxLoader("spinner");
    ajaxLoader.show();
    You can specify options of the spinner before it's creation. For example:
    var opts = {
        size: 32,           // Width and height of the spinner
        factor: 0.25,       // Factor of thickness, density, etc.
        color: "#000",      // Color #rgb or #rrggbb
        speed: 1.0,         // Number of turns per second
        clockwise: true     // Direction of rotation
    };
    var ajaxLoader = new AjaxLoader("spinner", opts);
    ajaxLoader.show();
                    

API

<Object> AjaxLoader(id, [options])

Constructor returns AjaxLoader object.

Parameters:

Examples:

var ajaxLoader = new AjaxLoader("spinner");
var ajaxLoader = new AjaxLoader("spinner", { color: "#FF00FF" });
<void> show()

Show the spinner and begin animation. Note: keyword void uses instead of undefined.

<void> hide()

Stop animation and hide the spinner. The element still remains in the DOM and you can show spinner again.

<Number> getSize()

Returns the size of the loader. The default value is 32.

<Number> getFactor()

Returns the thickness of the loader. The default value is 0.25.

<Number> getSpeed()

Returns the number of turns per second. The default value is 1.0.

<String> getColor()

Returns hexadecimal color of the loader. The default value is "#000" (black).

<String> getClockwise()

Returns direction of the rotation. The default value is true.

<void> setSize(value)

Sets the size of the loader.

Parameters:
<void> setFactor(value)

Sets the thickness of the loader.

Parameters:
<void> setSpeed(value)

Sets turns count of the loader per second. Recommended to set the value in the range 0..3.0

Parameters:
<void> setColor(value)

Sets hexadecimal color of the loader.

Parameters:
<void> setClockwise(value)

Sets direction of the rotation of your loader.

Parameters:

Supported browsers

AjaxLoader supports the following browsers:

Release History

Version 0.1 (14.04.2013)

Contacts

If you find any bugs or have some suggestions, please use the GitHub issue tracker.
You can also leave a comment. Follow me to GitHub.
If you have any questions write me to musicvano@gmail.com
For grateful users and those who want to support the development of this project:

License

Copyright (c) 2013 by Ivan Muzyka

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Discussion

comments powered by Disqus