From d67486e81de9f0e8b78bd47b51aa113a6d16e725 Mon Sep 17 00:00:00 2001 From: Robert Pataki Date: Sun, 16 Oct 2011 16:43:08 +0100 Subject: [PATCH] - VML mode IE8 display bugs fixed - Canvas mode shape glitches fixed - Documentation updated - Minified js file updated - Second test html file removed --- .gitignore | 2 + docs/CanvasLoader.html | 553 +++++++++++++++------------- docs/classmap.js | 0 docs/heartcode-canvasloader.js.html | 336 ++++++++--------- docs/index.html | 10 +- docs/index.json | 2 +- docs/module_canvasloader.html | 8 +- docs/raw.json | 2 +- heartcode-canvasloader-2.html | 61 --- heartcode-canvasloader.html | 92 +++-- js/heartcode-canvasloader-min.js | 15 +- js/heartcode-canvasloader.js | 328 ++++++++--------- 12 files changed, 691 insertions(+), 718 deletions(-) create mode 100644 .gitignore mode change 100755 => 100644 docs/CanvasLoader.html mode change 100755 => 100644 docs/classmap.js mode change 100755 => 100644 docs/heartcode-canvasloader.js.html mode change 100755 => 100644 docs/index.html mode change 100755 => 100644 docs/index.json mode change 100755 => 100644 docs/module_canvasloader.html mode change 100755 => 100644 docs/raw.json delete mode 100644 heartcode-canvasloader-2.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/docs/CanvasLoader.html b/docs/CanvasLoader.html old mode 100755 new mode 100644 index 2dead0f..4ee14fc --- a/docs/CanvasLoader.html +++ b/docs/CanvasLoader.html @@ -15,9 +15,9 @@
-

Heartcode CanvasLoader UI Library

+

Heartcode CanvasLoader YUI Library

CanvasLoader  0.8.0

- Heartcode CanvasLoader UI Library + Heartcode CanvasLoader YUI Library > CanvasLoader > CanvasLoader @@ -84,7 +84,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum id <String> - The id of the placeholder div. + The id of the placeholder div @@ -104,7 +104,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The active shape id for rendering. + The active shape id for rendering
@@ -119,7 +119,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The canvas we use for caching. + The canvas we use for caching
@@ -134,7 +134,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The context of the cache canvas. + The context of the cache canvas
@@ -149,7 +149,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The div we draw the shapes into. + The div we draw the shapes into
@@ -164,7 +164,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The color of the loader shapes in HEX. + The color of the loader shapes in HEX
@@ -182,7 +182,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The color of the loader shapes in RGB. + The color of the loader shapes in RGB
@@ -197,7 +197,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The div we place the canvas object into. + The div we place the canvas object into
@@ -212,7 +212,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The canvas context. + The canvas context
@@ -227,7 +227,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The number of shapes drawn on the loader canvas. + The number of shapes drawn on the loader canvas
@@ -245,7 +245,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The diameter of the loader. + The diameter of the loader
@@ -255,21 +255,6 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
-
-
-
-

fading - - protected Boolean -

-
-
- The fading of the loader shapes. -
-
- - - -
@@ -278,7 +263,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The FPS of the loader animation rendering. + The FPS value of the loader animation rendering
@@ -293,7 +278,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Sets the amount of the modified shapes in percent. + The amount of the modified shapes in percent.
@@ -308,22 +293,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Tell if the canvas and its context is ready. -
-
- - - - -
-
-
-

running - - protected Boolean -

-
-
- Tell if the loader rendering is running. + Tells if the canvas and its context is ready
@@ -338,7 +308,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The type of the loader shapes. + The type of the loader shapes
@@ -356,7 +326,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- The speed of the loader animation. + The speed of the loader animation
@@ -371,7 +341,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Add a timer for the rendering. + Adds a timer for the rendering
@@ -389,57 +359,68 @@ If no id is passed in the constructor, the canvas objects are paced in the docum

Methods

-
+

addEl

+ protected - - void + Object addEl ( + + + tag + + + , + par + + + , + props + + )
- Creates a new element with the tag and applies the passed properties on it. -
- -
- - - - - - -
- -
-
-
-
-

- canvasSupport

-
- - - - - void - canvasSupport - ( - ) - - -
- Checks if the browser supports Canvas + Creates a new element with the tag and applies the passed properties on it
+
+
Parameters:
+
+ tag + <String> + + The tag to be created +
+
+ par + <String> + + The DOM element the new element will be appended to +
+
+ props + <Object> + + Additional properties passed to the new DOM element +
+
+
+
Returns: + + Object +
+
The DOM element
+
@@ -464,7 +445,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Cleans the canvas. + Cleans the canvas
@@ -517,25 +498,19 @@ If no id is passed in the constructor, the canvas objects are paced in the docum - + String getColor ( )
- Returns the loader color in a hexadecimal form. + Returns the loader color in a hexadecimal form
-
-
Returns: - -
-
String
-
@@ -560,7 +535,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Returns the number of shapes drawn on the loader canvas. + Returns the number of shapes drawn on the loader canvas
@@ -583,7 +558,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum - + Number getDiameter ( ) @@ -596,42 +571,6 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
-
-
Returns: - -
-
Number
-
- - - - -
- -
-
-
-
-

- getFading

-
- - - - - Boolean - getFading - ( - ) - - -
- Returns the fading of the loader shapes. -
- -
- - @@ -656,7 +595,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Returns the fps of the loader. + Returns the fps of the loader
@@ -686,7 +625,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Returns the modified shape range in percent. + Returns the modified shape range in percent
@@ -721,7 +660,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Return the RGB values of the passed color. + Return the RGB values of the passed color
@@ -730,9 +669,9 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
Parameters:
color - <object> + <String> - (String) The HEX color value to be converted to RGB + The HEX color value to be converted to RGB
@@ -753,25 +692,19 @@ If no id is passed in the constructor, the canvas objects are paced in the docum - + String getShape ( )
- Returns the type of the loader shapes. + Returns the type of the loader shapes
-
-
Returns: - -
-
String
-
@@ -796,7 +729,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Returns the speed of the loader animation. + Returns the speed of the loader animation
@@ -826,7 +759,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Stop the rendering of the loader animation and hides the loader. + Stops the rendering of the loader animation and hides the loader
@@ -854,14 +787,18 @@ If no id is passed in the constructor, the canvas objects are paced in the docum ( - id + parentId + + + , + loaderId )
- Initialization method. + Initialization method
@@ -869,10 +806,16 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
Parameters:
- id + parentId <object> - String The id of the placeholder div. + (String) The id of the placeholder div, where the loader will be nested into +
+
+ loaderId + <object> + + (String) The id of loader
@@ -900,7 +843,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Remove the CanvasLoader instance and all references. + Removes the CanvasLoader instance and all its references
@@ -930,7 +873,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Redraws the canvas. + Redraws the canvas
@@ -960,7 +903,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Resets the timer. + Resets the timer
@@ -975,17 +918,26 @@ If no id is passed in the constructor, the canvas objects are paced in the docum

-
+

setAttr

+ protected - - void + Object setAttr ( + + + el + + + , + props + + ) @@ -995,7 +947,29 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
+
+
Parameters:
+
+ el + <Object> + + The DOM element to add the attributes to +
+
+ props + <Object> + + The attributes +
+
+
+
Returns: + + Object +
+
The DOM element
+
@@ -1025,7 +999,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Sets hexadecimal color of the loader. + Sets hexadecimal color of the loader
@@ -1036,7 +1010,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum color <String> - The default value is '#000000'. + The default value is '#000000' @@ -1049,17 +1023,26 @@ If no id is passed in the constructor, the canvas objects are paced in the docum

-
+

setCSS

+ protected - - void + Object setCSS ( + + + el + + + , + props + + ) @@ -1069,7 +1052,29 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
+
+
Parameters:
+
+ el + <Object> + + The DOM element to be styled +
+
+ props + <Object> + + The style properties +
+
+
+
Returns: + + Object +
+
The DOM element
+
@@ -1099,7 +1104,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Sets the number of shapes drawn on the loader canvas. + Sets the number of shapes drawn on the loader canvas
@@ -1110,7 +1115,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum density <Number> - The default value is 40. + The default value is 40 @@ -1143,7 +1148,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum
- Sets the diameter of the loader. + Sets the diameter of the loader
@@ -1154,51 +1159,7 @@ If no id is passed in the constructor, the canvas objects are paced in the docum diameter <Number> - The default value is 40. - - - - - - - -
- -
-
-
-
-

- setFading

-
- - - - - void - setFading - ( - - - fading - - - ) - - -
- Sets the fading of the loader shapes. -
- -
- -
-
Parameters:
-
- fading - <Boolean> - - The default value is true. + The default value is 40
@@ -1244,7 +1205,7 @@ Using the right combination of the setSpeed and the setFPSfps <Number> - The default value is 24. + The default value is 24 @@ -1291,7 +1252,7 @@ The visually acceptable range value should be between 0.4 and 1.5. range <Number> - The default value is 1.3. + The default value is 1.3 @@ -1327,10 +1288,11 @@ The visually acceptable range value should be between 0.4 and 1.5. Sets the type of the loader shapes.

The acceptable values are:
    -
  • 'circle'
  • +
  • 'oval'
  • +
  • 'spiral'
  • 'square'
  • -
  • 'rectangle'
  • -
  • 'roundedRectangle'
  • +
  • 'rect'
  • +
  • 'roundRect'
@@ -1342,7 +1304,7 @@ The visually acceptable range value should be between 0.4 and 1.5. shape <String> - The default value is 'circle'. + The default value is 'oval' @@ -1388,7 +1350,7 @@ Using the right combination of the setFPS and the setSpeedspeed <Number> - The default value is 2. + The default value is 2 @@ -1416,7 +1378,7 @@ Using the right combination of the setFPS and the setSpeed
- Shows the rendering of the loader animation. + Shows the rendering of the loader animation
@@ -1426,6 +1388,108 @@ Using the right combination of the setFPS and the setSpeed + +
+
+
+
+

+ tick

+
+ + protected + + + void + tick + ( + ) + + +
+ Renders the loader animation +
+ +
+ + + + + + +
+ +
+
+
+
+

+ transformContext

+
+ + protected + + + void + transformContext + ( + + + x + + + + + , + y + + + , + r + + + ) + + +
+ Prepares the cache canvas for drawing +
+ +
+ +
+
Parameters:
+
+ x + <Object> + + The canvas context to be transformed +
+
+ x + <Number> + + x translation +
+
+ y + <Number> + + y translation +
+
+ r + <Number> + + Rotation radians +
+
+ + + + +
@@ -1437,40 +1501,6 @@ Using the right combination of the setFPS and the setSpeed
-
-

Events

-
-
-

- tick

-
- - protected - - - tick - - ( - ) - - - -
- Renders the loader animation. -
- -
- - - - -
- -
-
-
-
-
@@ -1518,11 +1548,9 @@ Using the right combination of the setFPS and the setSpeedcontext
  • density
  • diameter
  • -
  • fading
  • fps
  • range
  • ready
  • -
  • running
  • shape
  • speed
  • timer
  • @@ -1532,14 +1560,12 @@ Using the right combination of the setFPS and the setSpeed

    Methods

    -
    -

    Events

    - -
    @@ -1577,12 +1598,12 @@ Using the right combination of the setFPS and the setSpeed

    - Copyright © 2004 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets. + Copyright © 2011 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets.
    diff --git a/docs/classmap.js b/docs/classmap.js old mode 100755 new mode 100644 diff --git a/docs/heartcode-canvasloader.js.html b/docs/heartcode-canvasloader.js.html old mode 100755 new mode 100644 index 2371ac7..ac352f2 --- a/docs/heartcode-canvasloader.js.html +++ b/docs/heartcode-canvasloader.js.html @@ -15,9 +15,9 @@
    -

    Heartcode CanvasLoader UI Library

    +

    Heartcode CanvasLoader YUI Library

    CanvasLoader  0.8.0

    - Heartcode CanvasLoader UI Library + Heartcode CanvasLoader YUI Library > CanvasLoader > heartcode-canvasloader.js (source view) @@ -82,22 +82,28 @@ * @module CanvasLoader **/ (function (window) { + "use strict"; /** * CanvasLoader is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.<br/> * A CanvasLoader instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.<br/> * If no id is passed in the constructor, the canvas objects are paced in the document directly. * @class CanvasLoader * @constructor - * @param {String} id The id of the placeholder div. + * @param {String} id The id of the placeholder div **/ - "use strict"; var CanvasLoader = function (id) { this.initialize(id); - }, p = CanvasLoader.prototype, engine, engines = ["canvas", "vml"], shapes = ["oval", "spiral", "square", "rect", "roundRect"], colorReg = /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, + }, p = CanvasLoader.prototype, engine, engines = ["canvas", "vml"], shapes = ["oval", "spiral", "square", "rect", "roundRect"], colorReg = /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, ie8 = navigator.appVersion.indexOf("MSIE") !== -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) === 8 ? true : false, canvasSupport = !!document.createElement('canvas').getContext, /** - * Creates a new element with the tag and applies the passed properties on it. + * Creates a new element with the tag and applies the passed properties on it + * @method addEl + * @protected + * @param tag {String} The tag to be created + * @param par {String} The DOM element the new element will be appended to + * @param props {Object} Additional properties passed to the new DOM element + * @return {Object} The DOM element */ - addEl = function (tag, props, par) { + addEl = function (tag, par, props) { var el = document.createElement(tag), n; for (n in props) { el[n] = props[n]; } if(typeof(par) !== "undefined") { @@ -107,36 +113,55 @@ }, /** * Sets the css properties on the element + * @method setCSS + * @protected + * @param el {Object} The DOM element to be styled + * @param props {Object} The style properties + * @return {Object} The DOM element */ setCSS = function (el, props) { - var n; - for (n in props) { el.style[n] = props[n]; } + for (var n in props) { el.style[n] = props[n]; } return el; }, /** * Sets the attributes on the element + * @method setAttr + * @protected + * @param el {Object} The DOM element to add the attributes to + * @param props {Object} The attributes + * @return {Object} The DOM element */ setAttr = function (el, props) { - var n; - for (n in props) { el.setAttribute(n, props[n]); } + for (var n in props) { el.setAttribute(n, props[n]); } return el; }, /** - * Checks if the browser supports Canvas + * Prepares the cache canvas for drawing + * @method transformContext + * @protected + * @param x {Object} The canvas context to be transformed + * @param x {Number} x translation + * @param y {Number} y translation + * @param r {Number} Rotation radians */ - canvasSupport = function () { - return !!document.createElement('canvas').getContext; + transformContext = function(c, x, y, r) { + c.save(); + c.translate(x, y); + c.rotate(r); + c.translate(-x, -y); + c.beginPath(); }; /** - * Initialization method. + * Initialization method * @method initialize - * @param id String The id of the placeholder div. * @protected + * @param parentId (String) The id of the placeholder div, where the loader will be nested into + * @param loaderId (String) The id of loader */ p.initialize = function (parentId, loaderId) { /* - * Find the containing div by id (passed by the user). - * If the container element cannot be found we use the document body itself. + * Find the containing div by id + * If the container element cannot be found we use the document body itself */ try { // Look for the parent element @@ -150,15 +175,15 @@ } // Creates the parent div of the loader instance loaderId = typeof (loaderId) !== "undefined" ? loaderId : "canvasLoader"; - this.cont = setCSS(addEl("div", {id: loaderId}, this.mother), {border: "1px solid #ff0000", position: "absolute"}); - if (canvasSupport()) { + this.cont = addEl("div", this.mother, {id: loaderId}); + if (canvasSupport) { // For browsers with Canvas support... engine = engines[0]; // Create the canvas element - this.canvas = addEl("canvas", {}, this.cont); + this.canvas = addEl("canvas", this.cont); this.context = this.canvas.getContext("2d"); // Create the cache canvas element - this.cacheCanvas = setCSS(addEl("canvas", {}, this.cont), { display: "none" }); + this.cacheCanvas = setCSS(addEl("canvas", this.cont), { display: "none" }); this.cacheContext = this.cacheCanvas.getContext("2d"); } else { // For browsers without Canvas support... @@ -170,153 +195,147 @@ var a = ["group", "oval", "roundrect", "fill"], n; for (n in a) { CanvasLoader.vmlSheet.addRule(a[n], "behavior:url(#default#VML); position:absolute;"); } } - this.vml = addEl("group", {}, this.cont); + this.vml = addEl("group", this.cont); } // Set the RGB color object this.setColor(this.color); - // Set the instance ready - p.ready = true; - // Draw the shapes on the canvas + // Sets the instance to be ready + this.ready = true; + // Draws the shapes on the canvas this.draw(); - // Start rendering the preloader + // Starts rendering the preloader this.show(); }; ///////////////////////////////////////////////////////////////////////////////////////////// // Property declarations /** - * The div we place the canvas object into. + * The div we place the canvas object into * @property container - * @type Object * @protected + * @type Object **/ p.container = {}; /** - * The div we draw the shapes into. + * The div we draw the shapes into * @property canvas - * @type Object * @protected + * @type Object **/ p.canvas = {}; /** - * The canvas context. + * The canvas context * @property context - * @type Object * @protected + * @type Object **/ p.context = {}; /** - * The canvas we use for caching. + * The canvas we use for caching * @property cacheCanvas - * @type Object * @protected + * @type Object **/ p.cacheCanvas = {}; /** - * The context of the cache canvas. + * The context of the cache canvas * @property cacheContext - * @type Object * @protected + * @type Object **/ p.cacheContext = {}; /** - * Tell if the loader rendering is running. - * @property running - * @type Boolean - * @protected - **/ - p.running = false; - /** - * Tell if the canvas and its context is ready. + * Tells if the canvas and its context is ready * @property ready - * @type Boolean * @protected + * @type Boolean **/ p.ready = false; /** - * Add a timer for the rendering. + * Adds a timer for the rendering * @property timer - * @type Boolean * @protected + * @type Boolean **/ p.timer = {}; /** - * The active shape id for rendering. + * The active shape id for rendering * @property activeId - * @type Number * @protected + * @type Number **/ p.activeId = 0; /** - * The diameter of the loader. + * The diameter of the loader * @property diameter + * @protected * @type Number * @default 40 - * @protected **/ p.diameter = 40; /** - * Sets the diameter of the loader. + * Sets the diameter of the loader * @method setDiameter - * @param diameter {Number} The default value is 40. * @public + * @param diameter {Number} The default value is 40 **/ p.setDiameter = function (diameter) { this.diameter = Math.round(Math.abs(diameter)); this.redraw(); }; /** * Returns the diameter of the loader. * @method getDiameter - * @return Number * @public + * @return {Number} **/ p.getDiameter = function () { return this.diameter; }; /** - * The color of the loader shapes in RGB. + * The color of the loader shapes in RGB * @property colorRGB - * @type Object * @protected + * @type Object **/ p.colorRGB = {}; /** - * The color of the loader shapes in HEX. + * The color of the loader shapes in HEX * @property color + * @protected * @type String * @default "#000000" - * @protected **/ p.color = "#000000"; /** - * Sets hexadecimal color of the loader. + * Sets hexadecimal color of the loader * @method setColor - * @param color {String} The default value is '#000000'. * @public + * @param color {String} The default value is '#000000' **/ p.setColor = function (color) { this.color = colorReg.test(color) ? color : "#000000"; this.colorRGB = this.getRGB(this.color); this.redraw(); }; /** - * Returns the loader color in a hexadecimal form. + * Returns the loader color in a hexadecimal form * @method getColor - * @return String * @public + * @return {String} **/ p.getColor = function () { return this.color; }; /** - * The type of the loader shapes. + * The type of the loader shapes * @property shape + * @protected * @type String * @default "oval" - * @protected **/ p.shape = shapes[0]; /** * Sets the type of the loader shapes.<br/> * <br/><b>The acceptable values are:</b> * <ul> - * <li>'circle'</li> + * <li>'oval'</li> + * <li>'spiral'</li> * <li>'square'</li> - * <li>'rectangle'</li> - * <li>'roundedRectangle'</li> + * <li>'rect'</li> + * <li>'roundRect'</li> * </ul> * @method setShape - * @param shape {String} The default value is 'circle'. * @public + * @param shape {String} The default value is 'oval' **/ p.setShape = function (shape) { var n; @@ -325,39 +344,39 @@ } }; /** - * Returns the type of the loader shapes. + * Returns the type of the loader shapes * @method getShape - * @return String * @public + * @return {String} **/ p.getShape = function () { return this.shape; }; /** - * The number of shapes drawn on the loader canvas. + * The number of shapes drawn on the loader canvas * @property density + * @protected * @type Number * @default 40 - * @protected **/ p.density = 40; /** - * Sets the number of shapes drawn on the loader canvas. + * Sets the number of shapes drawn on the loader canvas * @method setDensity - * @param density {Number} The default value is 40. * @public + * @param density {Number} The default value is 40 **/ p.setDensity = function (density) { this.density = Math.round(Math.abs(density)); this.redraw(); }; /** - * Returns the number of shapes drawn on the loader canvas. + * Returns the number of shapes drawn on the loader canvas * @method getDensity - * @return {Number} * @public + * @return {Number} **/ p.getDensity = function () { return this.density; }; /** - * Sets the amount of the modified shapes in percent. + * The amount of the modified shapes in percent. * @property range - * @type Number * @protected + * @type Number **/ p.range = 1.3; /** @@ -366,43 +385,22 @@ * This minimum amount is 0.1 which means every shape which is out of the range is scaled and/or faded to 10% of the original values.<br/> * The visually acceptable range value should be between 0.4 and 1.5. * @method setRange - * @param range {Number} The default value is 1.3. * @public + * @param range {Number} The default value is 1.3 **/ p.setRange = function (range) { this.range = Math.abs(range); this.redraw(); }; /** - * Returns the modified shape range in percent. + * Returns the modified shape range in percent * @method getRange - * @return {Number} * @public + * @return {Number} **/ p.getRange = function () { return this.range; }; /** - * The fading of the loader shapes. - * @property fading - * @type Boolean - * @protected - **/ - p.fading = true; - /** - * Sets the fading of the loader shapes. - * @method setFading - * @param fading {Boolean} The default value is true. - * @public - **/ - p.setFading = function (fading) { this.fading = fading; this.redraw(); }; - /** - * Returns the fading of the loader shapes. - * @method getFading - * @return {Boolean} - * @public - **/ - p.getFading = function () { return this.fading; }; - /** - * The speed of the loader animation. + * The speed of the loader animation * @property speed - * @type Number * @protected + * @type Number **/ p.speed = 2; /** @@ -410,23 +408,22 @@ * This value tells the loader how many shapes to skip by each tick.<br/> * Using the right combination of the <code>setFPS</code> and the <code>setSpeed</code> methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level. * @method setSpeed - * @param speed {Number} The default value is 2. - * @seealso setFPS * @public + * @param speed {Number} The default value is 2 **/ p.setSpeed = function (speed) { this.speed = Math.round(Math.abs(speed)); this.reset(); }; /** - * Returns the speed of the loader animation. + * Returns the speed of the loader animation * @method getSpeed - * @return {Number} * @public + * @return {Number} **/ p.getSpeed = function () { return this.speed; }; /** - * The FPS of the loader animation rendering. + * The FPS value of the loader animation rendering * @property fps - * @type Number * @protected + * @type Number **/ p.fps = 24; /** @@ -434,25 +431,24 @@ * This value tells the loader how many times to refresh and modify the canvas in 1 second.<br/> * Using the right combination of the <code>setSpeed</code> and the <code>setFPS</code> methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level. * @method setFPS - * @param fps {Number} The default value is 24. - * @seealso setSpeed * @public + * @param fps {Number} The default value is 24 **/ p.setFPS = function (fps) { this.fps = Math.round(Math.abs(fps)); this.reset(); }; /** - * Returns the fps of the loader. + * Returns the fps of the loader * @method getFPS - * @return {Number} * @public + * @return {Number} **/ p.getFPS = function () { return this.fps; }; // End of Property declarations ///////////////////////////////////////////////////////////////////////////////////////////// /** - * Return the RGB values of the passed color. + * Return the RGB values of the passed color * @method getRGB - * @param color (String) The HEX color value to be converted to RGB * @protected + * @param color {String} The HEX color value to be converted to RGB */ p.getRGB = function (color) { color = color.charAt(0) === "#" ? color.substring(1, 7) : color; @@ -466,7 +462,6 @@ p.draw = function () { var i = 0, size, w, h, x, y, angle, radians, radius, animBits = Math.round(this.density * this.range), bitMod, minBitMod = 0, s, g, sh, f, d = 1000, arc = 0; if (engine === engines[0]) { - // Clean the cache canvas this.cacheContext.clearRect(0, 0, this.cacheCanvas.width, this.cacheCanvas.height); setAttr(this.canvas, {width: this.diameter, height: this.diameter}); setAttr(this.cacheCanvas, {width: this.diameter, height: this.diameter}); @@ -474,8 +469,7 @@ bitMod = i <= animBits ? 1 - ((1 - minBitMod) / animBits * i) : bitMod = minBitMod; angle = 360 - 360 / this.density * i; radians = angle / 180 * Math.PI; - this.cacheContext.save(); - if (this.fading) { this.cacheContext.fillStyle = "rgba(" + this.colorRGB.r + "," + this.colorRGB.g + "," + this.colorRGB.b + "," + bitMod.toString() + ")"; } else { this.cacheContext.fillStyle = "rgba(" + this.colorRGB.r + "," + this.colorRGB.g + "," + this.colorRGB.b + ",1)"; } + this.cacheContext.fillStyle = "rgba(" + this.colorRGB.r + "," + this.colorRGB.g + "," + this.colorRGB.b + "," + bitMod.toString() + ")"; switch (this.shape) { case shapes[0]: case shapes[1]: @@ -489,42 +483,30 @@ size = this.diameter * 0.12; x = Math.cos(radians) * (this.cacheCanvas.width * 0.5 - size) + this.cacheCanvas.width * 0.5; y = Math.sin(radians) * (this.cacheCanvas.width * 0.5 - size) + this.cacheCanvas.height * 0.5; - this.cacheContext.translate(x, y); - this.cacheContext.rotate(radians); - this.cacheContext.translate(-x, -y); - this.cacheContext.beginPath(); + transformContext(this.cacheContext, x, y, radians); this.cacheContext.fillRect(x, y - size * 0.5, size, size); break; case shapes[3]: - w = size = this.diameter * 0.3; - h = w * 0.27; - x = Math.cos(radians) * (h + (this.cacheCanvas.height - h) * 0.13) + this.cacheCanvas.width * 0.5; - y = Math.sin(radians) * (h + (this.cacheCanvas.height - h) * 0.13) + this.cacheCanvas.height * 0.5; - this.cacheContext.translate(x, y); - this.cacheContext.rotate(radians); - this.cacheContext.translate(-x, -y); - this.cacheContext.beginPath(); - this.cacheContext.fillRect(x, y - h * 0.5, w, h); - break; case shapes[4]: - w = size = this.diameter * 0.3; + w = this.diameter * 0.3; h = w * 0.27; - radius = h * 0.56; x = Math.cos(radians) * (h + (this.cacheCanvas.height - h) * 0.13) + this.cacheCanvas.width * 0.5; y = Math.sin(radians) * (h + (this.cacheCanvas.height - h) * 0.13) + this.cacheCanvas.height * 0.5; - this.cacheContext.translate(x, y); - this.cacheContext.rotate(radians); - this.cacheContext.translate(-x, -y); - this.cacheContext.beginPath(); - this.cacheContext.moveTo(x + radius, y - h * 0.5); - this.cacheContext.lineTo(x + w - radius, y - h * 0.5); - this.cacheContext.quadraticCurveTo(x + w, y - h * 0.5, x + w, y - h * 0.5 + radius); - this.cacheContext.lineTo(x + w, y - h * 0.5 + h - radius); - this.cacheContext.quadraticCurveTo(x + w, y - h * 0.5 + h, x + w - radius, y - h * 0.5 + h); - this.cacheContext.lineTo(x + radius, y - h * 0.5 + h); - this.cacheContext.quadraticCurveTo(x, y - h * 0.5 + h, x, y - h * 0.5 + h - radius); - this.cacheContext.lineTo(x, y - h * 0.5 + radius); - this.cacheContext.quadraticCurveTo(x, y - h * 0.5, x + radius, y - h * 0.5); + transformContext(this.cacheContext, x, y, radians); + if(this.shape === shapes[3]) { + this.cacheContext.fillRect(x, y - h * 0.5, w, h); + } else { + radius = h * 0.7; + this.cacheContext.moveTo(x + radius, y - h * 0.5); + this.cacheContext.lineTo(x + w - radius, y - h * 0.5); + this.cacheContext.quadraticCurveTo(x + w, y - h * 0.5, x + w, y - h * 0.5 + radius); + this.cacheContext.lineTo(x + w, y - h * 0.5 + h - radius); + this.cacheContext.quadraticCurveTo(x + w, y - h * 0.5 + h, x + w - radius, y - h * 0.5 + h); + this.cacheContext.lineTo(x + radius, y - h * 0.5 + h); + this.cacheContext.quadraticCurveTo(x, y - h * 0.5 + h, x, y - h * 0.5 + h - radius); + this.cacheContext.lineTo(x, y - h * 0.5 + radius); + this.cacheContext.quadraticCurveTo(x, y - h * 0.5, x + radius, y - h * 0.5); + } break; } this.cacheContext.closePath(); @@ -534,7 +516,7 @@ } } else { setCSS(this.cont, {width: this.diameter, height: this.diameter}); - setCSS(this.vml, {width: this.diameter, height: this.diameter}); + setCSS(this.vml, {width: this.diameter, height: this.diameter, border: "1px solid #ff0000"}); switch (this.shape) { case shapes[0]: case shapes[1]: @@ -563,29 +545,39 @@ x = d * 0.5 - size * 0.5 - size * bitMod * 0.5; y = (size - size * bitMod) * 0.5; break; + case shapes[0]: + case shapes[2]: + if (ie8) { + y = 0; + if(this.shape === shapes[2]) { + x = d * 0.5 -h * 0.5; + } + } + break; case shapes[3]: case shapes[4]: w = size * 0.95; h = w * 0.28; - x = d * 0.5 - w; - y = -h * 0.5; + if (ie8) { + x = 0; + y = d * 0.5 - h * 0.5; + } else { + x = d * 0.5 - w; + y = -h * 0.5; + } arc = this.shape === shapes[4] ? 0.6 : 0; break; } - // Adds the group (shape needed to be grouped for accurate rotation) - g = setAttr(setCSS(addEl("group", {}, this.vml), {width: d, height: d, rotation: angle}), {coordsize: d + "," + d, coordorigin: -d * 0.5 + "," + (-d * 0.5)}); - // Adds the shape - s = setCSS(addEl(sh, {stroked: false, arcSize: arc}, g), { width: w, height: h, top: y, left: x}); - // Adds the fill - f = addEl("fill", {color: this.color, opacity: bitMod}, s); + g = setAttr(setCSS(addEl("group", this.vml), {width: d, height: d, rotation: angle}), {coordsize: d + "," + d, coordorigin: -d * 0.5 + "," + (-d * 0.5)}); + s = setCSS(addEl(sh, g, {stroked: false, arcSize: arc}), { width: w, height: h, top: y, left: x}); + f = addEl("fill", s, {color: this.color, opacity: bitMod}); ++i; } } - // Render the changes on the canvas this.tick(true); }; /** - * Cleans the canvas. + * Cleans the canvas * @method clean * @protected */ @@ -593,7 +585,6 @@ if (engine === engines[0]) { this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); } else { - // Cleans the VML element from its children if (this.vml.hasChildNodes()) { while (this.vml.childNodes.length >= 1) { this.vml.removeChild(this.vml.firstChild); @@ -602,7 +593,7 @@ } }; /** - * Redraws the canvas. + * Redraws the canvas * @method redraw * @protected */ @@ -613,7 +604,7 @@ } }; /** - * Resets the timer. + * Resets the timer * @method reset * @protected */ @@ -624,8 +615,8 @@ } }; /** - * Renders the loader animation. - * @event tick + * Renders the loader animation + * @method tick * @protected */ p.tick = function (initialize) { @@ -635,10 +626,7 @@ if (this.activeId >= 360) { this.activeId -= 360; } if (engine === engines[0]) { this.context.clearRect(0, 0, this.diameter, this.diameter); - this.context.save(); - this.context.translate(this.diameter * 0.5, this.diameter * 0.5); - this.context.rotate(Math.PI / 180 * this.activeId); - this.context.translate(-this.diameter * 0.5, -this.diameter * 0.5); + transformContext(this.context, this.diameter * 0.5, this.diameter * 0.5, Math.PI / 180 * this.activeId); this.context.drawImage(this.cacheCanvas, 0, 0, this.diameter, this.diameter); this.context.restore(); } else { @@ -646,7 +634,7 @@ } }; /** - * Shows the rendering of the loader animation. + * Shows the rendering of the loader animation * @method show * @public */ @@ -658,7 +646,7 @@ } }; /** - * Stop the rendering of the loader animation and hides the loader. + * Stops the rendering of the loader animation and hides the loader * @method hide * @public */ @@ -670,7 +658,7 @@ } }; /** - * Remove the CanvasLoader instance and all references. + * Removes the CanvasLoader instance and all its references * @method kill * @public */ @@ -725,12 +713,12 @@

    - Copyright © 2004 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets. + Copyright © 2011 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets.
    diff --git a/docs/index.html b/docs/index.html old mode 100755 new mode 100644 index c9b741e..11f59ae --- a/docs/index.html +++ b/docs/index.html @@ -15,9 +15,9 @@
    -

    Heartcode CanvasLoader UI Library

    +

    Heartcode CanvasLoader YUI Library

      0.8.0

    - Heartcode CanvasLoader UI Library + Heartcode CanvasLoader YUI Library
    Search: @@ -42,7 +42,7 @@
    This is the API documentation for the - Heartcode CanvasLoader UI Library. + Heartcode CanvasLoader YUI Library.

    Choose a module name from the list for more information.

    @@ -82,13 +82,13 @@

    - Copyright © 2004 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets. + Copyright © 2011 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets.
    diff --git a/docs/index.json b/docs/index.json old mode 100755 new mode 100644 index 298cd4f..656feb7 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -[{"url": "CanvasLoader.html#property_activeId", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "activeId"}, {"url": "CanvasLoader.html#method_addEl", "access": "", "host": "CanvasLoader", "type": "method", "name": "addEl"}, {"url": "CanvasLoader.html#property_cacheCanvas", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "cacheCanvas"}, {"url": "CanvasLoader.html#property_cacheContext", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "cacheContext"}, {"url": "CanvasLoader.html#property_canvas", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "canvas"}, {"url": "CanvasLoader.html#method_canvasSupport", "access": "", "host": "CanvasLoader", "type": "method", "name": "canvasSupport"}, {"url": "CanvasLoader.html#method_clean", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "clean"}, {"url": "CanvasLoader.html#property_color", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "color"}, {"url": "CanvasLoader.html#property_colorRGB", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "colorRGB"}, {"url": "CanvasLoader.html#property_container", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "container"}, {"url": "CanvasLoader.html#property_context", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "context"}, {"url": "CanvasLoader.html#property_density", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "density"}, {"url": "CanvasLoader.html#property_diameter", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "diameter"}, {"url": "CanvasLoader.html#method_draw", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "draw"}, {"url": "CanvasLoader.html#property_fading", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "fading"}, {"url": "CanvasLoader.html#property_fps", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "fps"}, {"url": "CanvasLoader.html#method_getColor", "access": "", "host": "CanvasLoader", "type": "method", "name": "getColor"}, {"url": "CanvasLoader.html#method_getDensity", "access": "", "host": "CanvasLoader", "type": "method", "name": "getDensity"}, {"url": "CanvasLoader.html#method_getDiameter", "access": "", "host": "CanvasLoader", "type": "method", "name": "getDiameter"}, {"url": "CanvasLoader.html#method_getFading", "access": "", "host": "CanvasLoader", "type": "method", "name": "getFading"}, {"url": "CanvasLoader.html#method_getFPS", "access": "", "host": "CanvasLoader", "type": "method", "name": "getFPS"}, {"url": "CanvasLoader.html#method_getRange", "access": "", "host": "CanvasLoader", "type": "method", "name": "getRange"}, {"url": "CanvasLoader.html#method_getRGB", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "getRGB"}, {"url": "CanvasLoader.html#method_getShape", "access": "", "host": "CanvasLoader", "type": "method", "name": "getShape"}, {"url": "CanvasLoader.html#method_getSpeed", "access": "", "host": "CanvasLoader", "type": "method", "name": "getSpeed"}, {"url": "CanvasLoader.html#method_hide", "access": "", "host": "CanvasLoader", "type": "method", "name": "hide"}, {"url": "CanvasLoader.html#method_initialize", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "initialize"}, {"url": "CanvasLoader.html#method_kill", "access": "", "host": "CanvasLoader", "type": "method", "name": "kill"}, {"url": "CanvasLoader.html#property_range", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "range"}, {"url": "CanvasLoader.html#property_ready", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "ready"}, {"url": "CanvasLoader.html#method_redraw", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "redraw"}, {"url": "CanvasLoader.html#method_reset", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "reset"}, {"url": "CanvasLoader.html#property_running", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "running"}, {"url": "CanvasLoader.html#method_setAttr", "access": "", "host": "CanvasLoader", "type": "method", "name": "setAttr"}, {"url": "CanvasLoader.html#method_setColor", "access": "", "host": "CanvasLoader", "type": "method", "name": "setColor"}, {"url": "CanvasLoader.html#method_setCSS", "access": "", "host": "CanvasLoader", "type": "method", "name": "setCSS"}, {"url": "CanvasLoader.html#method_setDensity", "access": "", "host": "CanvasLoader", "type": "method", "name": "setDensity"}, {"url": "CanvasLoader.html#method_setDiameter", "access": "", "host": "CanvasLoader", "type": "method", "name": "setDiameter"}, {"url": "CanvasLoader.html#method_setFading", "access": "", "host": "CanvasLoader", "type": "method", "name": "setFading"}, {"url": "CanvasLoader.html#method_setFPS", "access": "", "host": "CanvasLoader", "type": "method", "name": "setFPS"}, {"url": "CanvasLoader.html#method_setRange", "access": "", "host": "CanvasLoader", "type": "method", "name": "setRange"}, {"url": "CanvasLoader.html#method_setShape", "access": "", "host": "CanvasLoader", "type": "method", "name": "setShape"}, {"url": "CanvasLoader.html#method_setSpeed", "access": "", "host": "CanvasLoader", "type": "method", "name": "setSpeed"}, {"url": "CanvasLoader.html#property_shape", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "shape"}, {"url": "CanvasLoader.html#method_show", "access": "", "host": "CanvasLoader", "type": "method", "name": "show"}, {"url": "CanvasLoader.html#property_speed", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "speed"}, {"url": "CanvasLoader.html#event_tick", "access": "protected", "host": "CanvasLoader", "type": "event", "name": "tick"}, {"url": "CanvasLoader.html#property_timer", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "timer"}] \ No newline at end of file +[{"url": "CanvasLoader.html#property_activeId", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "activeId"}, {"url": "CanvasLoader.html#method_addEl", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "addEl"}, {"url": "CanvasLoader.html#property_cacheCanvas", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "cacheCanvas"}, {"url": "CanvasLoader.html#property_cacheContext", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "cacheContext"}, {"url": "CanvasLoader.html#property_canvas", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "canvas"}, {"url": "CanvasLoader.html#method_clean", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "clean"}, {"url": "CanvasLoader.html#property_color", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "color"}, {"url": "CanvasLoader.html#property_colorRGB", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "colorRGB"}, {"url": "CanvasLoader.html#property_container", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "container"}, {"url": "CanvasLoader.html#property_context", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "context"}, {"url": "CanvasLoader.html#property_density", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "density"}, {"url": "CanvasLoader.html#property_diameter", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "diameter"}, {"url": "CanvasLoader.html#method_draw", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "draw"}, {"url": "CanvasLoader.html#property_fps", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "fps"}, {"url": "CanvasLoader.html#method_getColor", "access": "", "host": "CanvasLoader", "type": "method", "name": "getColor"}, {"url": "CanvasLoader.html#method_getDensity", "access": "", "host": "CanvasLoader", "type": "method", "name": "getDensity"}, {"url": "CanvasLoader.html#method_getDiameter", "access": "", "host": "CanvasLoader", "type": "method", "name": "getDiameter"}, {"url": "CanvasLoader.html#method_getFPS", "access": "", "host": "CanvasLoader", "type": "method", "name": "getFPS"}, {"url": "CanvasLoader.html#method_getRange", "access": "", "host": "CanvasLoader", "type": "method", "name": "getRange"}, {"url": "CanvasLoader.html#method_getRGB", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "getRGB"}, {"url": "CanvasLoader.html#method_getShape", "access": "", "host": "CanvasLoader", "type": "method", "name": "getShape"}, {"url": "CanvasLoader.html#method_getSpeed", "access": "", "host": "CanvasLoader", "type": "method", "name": "getSpeed"}, {"url": "CanvasLoader.html#method_hide", "access": "", "host": "CanvasLoader", "type": "method", "name": "hide"}, {"url": "CanvasLoader.html#method_initialize", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "initialize"}, {"url": "CanvasLoader.html#method_kill", "access": "", "host": "CanvasLoader", "type": "method", "name": "kill"}, {"url": "CanvasLoader.html#property_range", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "range"}, {"url": "CanvasLoader.html#property_ready", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "ready"}, {"url": "CanvasLoader.html#method_redraw", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "redraw"}, {"url": "CanvasLoader.html#method_reset", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "reset"}, {"url": "CanvasLoader.html#method_setAttr", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "setAttr"}, {"url": "CanvasLoader.html#method_setColor", "access": "", "host": "CanvasLoader", "type": "method", "name": "setColor"}, {"url": "CanvasLoader.html#method_setCSS", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "setCSS"}, {"url": "CanvasLoader.html#method_setDensity", "access": "", "host": "CanvasLoader", "type": "method", "name": "setDensity"}, {"url": "CanvasLoader.html#method_setDiameter", "access": "", "host": "CanvasLoader", "type": "method", "name": "setDiameter"}, {"url": "CanvasLoader.html#method_setFPS", "access": "", "host": "CanvasLoader", "type": "method", "name": "setFPS"}, {"url": "CanvasLoader.html#method_setRange", "access": "", "host": "CanvasLoader", "type": "method", "name": "setRange"}, {"url": "CanvasLoader.html#method_setShape", "access": "", "host": "CanvasLoader", "type": "method", "name": "setShape"}, {"url": "CanvasLoader.html#method_setSpeed", "access": "", "host": "CanvasLoader", "type": "method", "name": "setSpeed"}, {"url": "CanvasLoader.html#property_shape", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "shape"}, {"url": "CanvasLoader.html#method_show", "access": "", "host": "CanvasLoader", "type": "method", "name": "show"}, {"url": "CanvasLoader.html#property_speed", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "speed"}, {"url": "CanvasLoader.html#method_tick", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "tick"}, {"url": "CanvasLoader.html#property_timer", "access": "protected", "host": "CanvasLoader", "type": "property", "name": "timer"}, {"url": "CanvasLoader.html#method_transformContext", "access": "protected", "host": "CanvasLoader", "type": "method", "name": "transformContext"}] \ No newline at end of file diff --git a/docs/module_canvasloader.html b/docs/module_canvasloader.html old mode 100755 new mode 100644 index ea8840a..5f3969f --- a/docs/module_canvasloader.html +++ b/docs/module_canvasloader.html @@ -15,9 +15,9 @@
    -

    Heartcode CanvasLoader UI Library

    +

    Heartcode CanvasLoader YUI Library

    CanvasLoader  0.8.0

    - Heartcode CanvasLoader UI Library + Heartcode CanvasLoader YUI Library > CanvasLoader @@ -109,12 +109,12 @@ The implementation is (hopefully) very simple and doesn't require any external l

    - Copyright © 2004 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets. + Copyright © 2011 Róbert Pataki. The Heartcode CanvasLoader is released under the MIT licence. For more information and other open source stuff please visit the Heartcode blog, check out my GitHub profile and follow the Heartcode tweets.
    diff --git a/docs/raw.json b/docs/raw.json old mode 100755 new mode 100644 index 9f5edb3..83bda06 --- a/docs/raw.json +++ b/docs/raw.json @@ -1 +1 @@ -{"majorversion": 2, "classmap": {"CanvasLoader": {"name": "CanvasLoader", "constructors": [{"params": [{"type": "String", "name": "id", "description": " The id of the placeholder div."}], "description": "CanvasLoader is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.
    \r\nA CanvasLoader instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.
    \r\nIf no id is passed in the constructor, the canvas objects are paced in the document directly."}], "namespace": "", "module": "CanvasLoader", "events": {"tick": {"protected": "", "description": "Renders the loader animation.", "guessedname": "tick", "guessedtype": "function"}}, "methods": {"getRange": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the modified shape range in percent.", "guessedname": "getRange", "guessedtype": "function"}, "show": {"description": "Shows the rendering of the loader animation.", "public": "", "guessedname": "show", "guessedtype": "function"}, "setDensity": {"public": "", "params": [{"type": "Number", "name": "density", "description": " The default value is 40."}], "description": "Sets the number of shapes drawn on the loader canvas.", "guessedname": "setDensity", "guessedtype": "function"}, "getDiameter": {"public": "", "return": {"type": "", "description": "Number"}, "description": "Returns the diameter of the loader.", "guessedname": "getDiameter", "guessedtype": "function"}, "kill": {"description": "Remove the CanvasLoader instance and all references.", "public": "", "guessedname": "kill", "guessedtype": "function"}, "hide": {"description": "Stop the rendering of the loader animation and hides the loader.", "public": "", "guessedname": "hide", "guessedtype": "function"}, "addEl": {"description": "Creates a new element with the tag and applies the passed properties on it.", "guessedname": "addEl", "guessedtype": "function"}, "getShape": {"public": "", "return": {"type": "", "description": "String"}, "description": "Returns the type of the loader shapes.", "guessedname": "getShape", "guessedtype": "function"}, "setRange": {"public": "", "params": [{"type": "Number", "name": "range", "description": " The default value is 1.3."}], "description": "Sets the amount of the modified shapes in percent.
    \r\nWith this value the user can set what range of the shapes should be scaled and/or faded. The shapes that are out of this range will be scaled and/or faded with a minimum amount only.
    \r\nThis minimum amount is 0.1 which means every shape which is out of the range is scaled and/or faded to 10% of the original values.
    \r\nThe visually acceptable range value should be between 0.4 and 1.5.", "guessedname": "setRange", "guessedtype": "function"}, "getFPS": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the fps of the loader.", "guessedname": "getFPS", "guessedtype": "function"}, "draw": {"protected": "", "description": "Draw the shapes on the canvas", "guessedname": "draw", "guessedtype": "function"}, "clean": {"protected": "", "description": "Cleans the canvas.", "guessedname": "clean", "guessedtype": "function"}, "setAttr": {"description": "Sets the attributes on the element", "guessedname": "setAttr", "guessedtype": "function"}, "getColor": {"public": "", "return": {"type": "", "description": "String"}, "description": "Returns the loader color in a hexadecimal form.", "guessedname": "getColor", "guessedtype": "function"}, "getRGB": {"protected": "", "params": [{"type": "", "name": "color", "description": " (String) The HEX color value to be converted to RGB"}], "description": "Return the RGB values of the passed color.", "guessedname": "getRGB", "guessedtype": "function"}, "getDensity": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the number of shapes drawn on the loader canvas.", "guessedname": "getDensity", "guessedtype": "function"}, "initialize": {"protected": "", "params": [{"type": "", "name": "id", "description": " String The id of the placeholder div."}], "description": "Initialization method.", "guessedname": "initialize", "guessedtype": "function"}, "setCSS": {"description": "Sets the css properties on the element", "guessedname": "setCSS", "guessedtype": "function"}, "getSpeed": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the speed of the loader animation.", "guessedname": "getSpeed", "guessedtype": "function"}, "reset": {"protected": "", "description": "Resets the timer.", "guessedname": "reset", "guessedtype": "function"}, "setDiameter": {"public": "", "params": [{"type": "Number", "name": "diameter", "description": " The default value is 40."}], "description": "Sets the diameter of the loader.", "guessedname": "setDiameter", "guessedtype": "function"}, "setColor": {"public": "", "params": [{"type": "String", "name": "color", "description": " The default value is '#000000'."}], "description": "Sets hexadecimal color of the loader.", "guessedname": "setColor", "guessedtype": "function"}, "setSpeed": {"description": "Sets the speed of the loader animation.
    \r\nThis value tells the loader how many shapes to skip by each tick.
    \r\nUsing the right combination of the setFPS and the setSpeed methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level.", "params": [{"type": "Number", "name": "speed", "description": " The default value is 2."}], "guessedname": "setSpeed", "guessedtype": "function", "public": "", "seealso": "setFPS"}, "setFading": {"public": "", "params": [{"type": "Boolean", "name": "fading", "description": " The default value is true."}], "description": "Sets the fading of the loader shapes.", "guessedname": "setFading", "guessedtype": "function"}, "setFPS": {"description": "Sets the rendering frequency.
    \r\nThis value tells the loader how many times to refresh and modify the canvas in 1 second.
    \r\nUsing the right combination of the setSpeed and the setFPS methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level.", "params": [{"type": "Number", "name": "fps", "description": " The default value is 24."}], "guessedname": "setFPS", "guessedtype": "function", "public": "", "seealso": "setSpeed"}, "getFading": {"public": "", "return": {"type": "Boolean", "description": ""}, "description": "Returns the fading of the loader shapes.", "guessedname": "getFading", "guessedtype": "function"}, "redraw": {"protected": "", "description": "Redraws the canvas.", "guessedname": "redraw", "guessedtype": "function"}, "canvasSupport": {"description": "Checks if the browser supports Canvas", "guessedname": "canvasSupport", "guessedtype": "function"}, "setShape": {"public": "", "params": [{"type": "String", "name": "shape", "description": " The default value is 'circle'."}], "description": "Sets the type of the loader shapes.
    \r\n
    The acceptable values are:\r\n
      \r\n
    • 'circle'
    • \r\n
    • 'square'
    • \r\n
    • 'rectangle'
    • \r\n
    • 'roundedRectangle'
    • \r\n
    ", "guessedname": "setShape", "guessedtype": "function"}}, "file": "heartcode-canvasloader.js", "shortname": "CanvasLoader", "properties": {"diameter": {"description": "The diameter of the loader.", "default": "40", "protected": "", "guessedname": "diameter", "guessedtype": "property", "type": "Number"}, "canvas": {"protected": "", "type": "Object", "description": "The div we draw the shapes into.", "guessedname": "canvas", "guessedtype": "property"}, "container": {"protected": "", "type": "Object", "description": "The div we place the canvas object into.", "guessedname": "container", "guessedtype": "property"}, "fps": {"protected": "", "type": "Number", "description": "The FPS of the loader animation rendering.", "guessedname": "fps", "guessedtype": "property"}, "density": {"description": "The number of shapes drawn on the loader canvas.", "default": "40", "protected": "", "guessedname": "density", "guessedtype": "property", "type": "Number"}, "color": {"description": "The color of the loader shapes in HEX.", "default": "\"#000000\"", "protected": "", "guessedname": "color", "guessedtype": "property", "type": "String"}, "cacheContext": {"protected": "", "type": "Object", "description": "The context of the cache canvas.", "guessedname": "cacheContext", "guessedtype": "property"}, "colorRGB": {"protected": "", "type": "Object", "description": "The color of the loader shapes in RGB.", "guessedname": "colorRGB", "guessedtype": "property"}, "timer": {"protected": "", "type": "Boolean", "description": "Add a timer for the rendering.", "guessedname": "timer", "guessedtype": "property"}, "shape": {"description": "The type of the loader shapes.", "default": "\"oval\"", "protected": "", "guessedname": "shape", "guessedtype": "property", "type": "String"}, "cacheCanvas": {"protected": "", "type": "Object", "description": "The canvas we use for caching.", "guessedname": "cacheCanvas", "guessedtype": "property"}, "running": {"protected": "", "type": "Boolean", "description": "Tell if the loader rendering is running.", "guessedname": "running", "guessedtype": "property"}, "activeId": {"protected": "", "type": "Number", "description": "The active shape id for rendering.", "guessedname": "activeId", "guessedtype": "property"}, "context": {"protected": "", "type": "Object", "description": "The canvas context.", "guessedname": "context", "guessedtype": "property"}, "ready": {"protected": "", "type": "Boolean", "description": "Tell if the canvas and its context is ready.", "guessedname": "ready", "guessedtype": "property"}, "range": {"protected": "", "type": "Number", "description": "Sets the amount of the modified shapes in percent.", "guessedname": "range", "guessedtype": "property"}, "speed": {"protected": "", "type": "Number", "description": "The speed of the loader animation.", "guessedname": "speed", "guessedtype": "property"}, "fading": {"protected": "", "type": "Boolean", "description": "The fading of the loader shapes.", "guessedname": "fading", "guessedtype": "property"}}, "description": "CanvasLoader is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.
    \r\nA CanvasLoader instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.
    \r\nIf no id is passed in the constructor, the canvas objects are paced in the document directly."}}, "version": "0.8.0", "modules": {"CanvasLoader": {"description": "This lightweight library uses the HTML5 canvas element to draw and animate the most popular preloader shapes (circle, rectangle, square and rounded rectangle).
    \r\nThe implementation is (hopefully) very simple and doesn't require any external libraries.
    ", "submodules": [], "classlist": ["CanvasLoader"], "filelist": ["heartcode-canvasloader.js"], "subdata": {}, "name": "CanvasLoader"}}, "filemap": {"heartcode-canvasloader.js": {"classlist": ["CanvasLoader"], "name": "heartcode-canvasloader.js", "module": "CanvasLoader"}}} \ No newline at end of file +{"majorversion": 2, "classmap": {"CanvasLoader": {"name": "CanvasLoader", "constructors": [{"params": [{"type": "String", "name": "id", "description": " The id of the placeholder div"}], "description": "CanvasLoader is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.
    \r\nA CanvasLoader instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.
    \r\nIf no id is passed in the constructor, the canvas objects are paced in the document directly."}], "namespace": "", "module": "CanvasLoader", "guessedname": "CanvasLoader", "methods": {"getRange": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the modified shape range in percent", "guessedname": "getRange", "guessedtype": "function"}, "show": {"description": "Shows the rendering of the loader animation", "public": "", "guessedname": "show", "guessedtype": "function"}, "setDensity": {"public": "", "params": [{"type": "Number", "name": "density", "description": " The default value is 40"}], "description": "Sets the number of shapes drawn on the loader canvas", "guessedname": "setDensity", "guessedtype": "function"}, "getDiameter": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the diameter of the loader.", "guessedname": "getDiameter", "guessedtype": "function"}, "kill": {"description": "Removes the CanvasLoader instance and all its references", "public": "", "guessedname": "kill", "guessedtype": "function"}, "tick": {"protected": "", "description": "Renders the loader animation", "guessedname": "tick", "guessedtype": "function"}, "hide": {"description": "Stops the rendering of the loader animation and hides the loader", "public": "", "guessedname": "hide", "guessedtype": "function"}, "addEl": {"return": {"type": "Object", "description": "The DOM element"}, "description": "Creates a new element with the tag and applies the passed properties on it", "protected": "", "params": [{"type": "String", "name": "tag", "description": " The tag to be created"}, {"type": "String", "name": "par", "description": " The DOM element the new element will be appended to"}, {"type": "Object", "name": "props", "description": " Additional properties passed to the new DOM element"}], "guessedname": "addEl", "guessedtype": "function"}, "transformContext": {"protected": "", "params": [{"type": "Object", "name": "x", "description": " The canvas context to be transformed"}, {"type": "Number", "name": "x", "description": " x translation"}, {"type": "Number", "name": "y", "description": " y translation"}, {"type": "Number", "name": "r", "description": " Rotation radians"}], "description": "Prepares the cache canvas for drawing", "guessedname": "transformContext", "guessedtype": "function"}, "setRange": {"public": "", "params": [{"type": "Number", "name": "range", "description": " The default value is 1.3"}], "description": "Sets the amount of the modified shapes in percent.
    \r\nWith this value the user can set what range of the shapes should be scaled and/or faded. The shapes that are out of this range will be scaled and/or faded with a minimum amount only.
    \r\nThis minimum amount is 0.1 which means every shape which is out of the range is scaled and/or faded to 10% of the original values.
    \r\nThe visually acceptable range value should be between 0.4 and 1.5.", "guessedname": "setRange", "guessedtype": "function"}, "getFPS": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the fps of the loader", "guessedname": "getFPS", "guessedtype": "function"}, "draw": {"protected": "", "description": "Draw the shapes on the canvas", "guessedname": "draw", "guessedtype": "function"}, "setAttr": {"return": {"type": "Object", "description": "The DOM element"}, "description": "Sets the attributes on the element", "protected": "", "params": [{"type": "Object", "name": "el", "description": " The DOM element to add the attributes to"}, {"type": "Object", "name": "props", "description": " The attributes"}], "guessedname": "setAttr", "guessedtype": "function"}, "getColor": {"public": "", "return": {"type": "String", "description": ""}, "description": "Returns the loader color in a hexadecimal form", "guessedname": "getColor", "guessedtype": "function"}, "setFPS": {"public": "", "params": [{"type": "Number", "name": "fps", "description": " The default value is 24"}], "description": "Sets the rendering frequency.
    \r\nThis value tells the loader how many times to refresh and modify the canvas in 1 second.
    \r\nUsing the right combination of the setSpeed and the setFPS methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level.", "guessedname": "setFPS", "guessedtype": "function"}, "getDensity": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the number of shapes drawn on the loader canvas", "guessedname": "getDensity", "guessedtype": "function"}, "initialize": {"protected": "", "params": [{"type": "", "name": "parentId", "description": " (String) The id of the placeholder div, where the loader will be nested into"}, {"type": "", "name": "loaderId", "description": " (String) The id of loader"}], "description": "Initialization method", "guessedname": "initialize", "guessedtype": "function"}, "setCSS": {"return": {"type": "Object", "description": "The DOM element"}, "description": "Sets the css properties on the element", "protected": "", "params": [{"type": "Object", "name": "el", "description": " The DOM element to be styled"}, {"type": "Object", "name": "props", "description": " The style properties"}], "guessedname": "setCSS", "guessedtype": "function"}, "getSpeed": {"public": "", "return": {"type": "Number", "description": ""}, "description": "Returns the speed of the loader animation", "guessedname": "getSpeed", "guessedtype": "function"}, "reset": {"protected": "", "description": "Resets the timer", "guessedname": "reset", "guessedtype": "function"}, "setDiameter": {"public": "", "params": [{"type": "Number", "name": "diameter", "description": " The default value is 40"}], "description": "Sets the diameter of the loader", "guessedname": "setDiameter", "guessedtype": "function"}, "setColor": {"public": "", "params": [{"type": "String", "name": "color", "description": " The default value is '#000000'"}], "description": "Sets hexadecimal color of the loader", "guessedname": "setColor", "guessedtype": "function"}, "getRGB": {"protected": "", "params": [{"type": "String", "name": "color", "description": " The HEX color value to be converted to RGB"}], "description": "Return the RGB values of the passed color", "guessedname": "getRGB", "guessedtype": "function"}, "setSpeed": {"public": "", "params": [{"type": "Number", "name": "speed", "description": " The default value is 2"}], "description": "Sets the speed of the loader animation.
    \r\nThis value tells the loader how many shapes to skip by each tick.
    \r\nUsing the right combination of the setFPS and the setSpeed methods allows the users to optimize the CPU usage of the loader whilst keeping the animation on a visually pleasing level.", "guessedname": "setSpeed", "guessedtype": "function"}, "getShape": {"public": "", "return": {"type": "String", "description": ""}, "description": "Returns the type of the loader shapes", "guessedname": "getShape", "guessedtype": "function"}, "clean": {"protected": "", "description": "Cleans the canvas", "guessedname": "clean", "guessedtype": "function"}, "redraw": {"protected": "", "description": "Redraws the canvas", "guessedname": "redraw", "guessedtype": "function"}, "setShape": {"public": "", "params": [{"type": "String", "name": "shape", "description": " The default value is 'oval'"}], "description": "Sets the type of the loader shapes.
    \r\n
    The acceptable values are:\r\n
      \r\n
    • 'oval'
    • \r\n
    • 'spiral'
    • \r\n
    • 'square'
    • \r\n
    • 'rect'
    • \r\n
    • 'roundRect'
    • \r\n
    ", "guessedname": "setShape", "guessedtype": "function"}}, "file": "heartcode-canvasloader.js", "guessedtype": "function", "shortname": "CanvasLoader", "properties": {"diameter": {"description": "The diameter of the loader", "default": "40", "protected": "", "guessedname": "diameter", "guessedtype": "property", "type": "Number"}, "canvas": {"protected": "", "type": "Object", "description": "The div we draw the shapes into", "guessedname": "canvas", "guessedtype": "property"}, "container": {"protected": "", "type": "Object", "description": "The div we place the canvas object into", "guessedname": "container", "guessedtype": "property"}, "fps": {"protected": "", "type": "Number", "description": "The FPS value of the loader animation rendering", "guessedname": "fps", "guessedtype": "property"}, "density": {"description": "The number of shapes drawn on the loader canvas", "default": "40", "protected": "", "guessedname": "density", "guessedtype": "property", "type": "Number"}, "color": {"description": "The color of the loader shapes in HEX", "default": "\"#000000\"", "protected": "", "guessedname": "color", "guessedtype": "property", "type": "String"}, "cacheContext": {"protected": "", "type": "Object", "description": "The context of the cache canvas", "guessedname": "cacheContext", "guessedtype": "property"}, "colorRGB": {"protected": "", "type": "Object", "description": "The color of the loader shapes in RGB", "guessedname": "colorRGB", "guessedtype": "property"}, "timer": {"protected": "", "type": "Boolean", "description": "Adds a timer for the rendering", "guessedname": "timer", "guessedtype": "property"}, "cacheCanvas": {"protected": "", "type": "Object", "description": "The canvas we use for caching", "guessedname": "cacheCanvas", "guessedtype": "property"}, "shape": {"description": "The type of the loader shapes", "default": "\"oval\"", "protected": "", "guessedname": "shape", "guessedtype": "property", "type": "String"}, "activeId": {"protected": "", "type": "Number", "description": "The active shape id for rendering", "guessedname": "activeId", "guessedtype": "property"}, "context": {"protected": "", "type": "Object", "description": "The canvas context", "guessedname": "context", "guessedtype": "property"}, "ready": {"protected": "", "type": "Boolean", "description": "Tells if the canvas and its context is ready", "guessedname": "ready", "guessedtype": "property"}, "range": {"protected": "", "type": "Number", "description": "The amount of the modified shapes in percent.", "guessedname": "range", "guessedtype": "property"}, "speed": {"protected": "", "type": "Number", "description": "The speed of the loader animation", "guessedname": "speed", "guessedtype": "property"}}, "description": "CanvasLoader is a JavaScript UI library that draws and animates circular preloaders using the Canvas HTML object.
    \r\nA CanvasLoader instance creates two canvas elements which are placed into a placeholder div (the id of the div has to be passed in the constructor). The second canvas is invisible and used for caching purposes only.
    \r\nIf no id is passed in the constructor, the canvas objects are paced in the document directly."}}, "version": "0.8.0", "modules": {"CanvasLoader": {"description": "This lightweight library uses the HTML5 canvas element to draw and animate the most popular preloader shapes (circle, rectangle, square and rounded rectangle).
    \r\nThe implementation is (hopefully) very simple and doesn't require any external libraries.
    ", "submodules": [], "classlist": ["CanvasLoader"], "filelist": ["heartcode-canvasloader.js"], "subdata": {}, "name": "CanvasLoader"}}, "filemap": {"heartcode-canvasloader.js": {"classlist": ["CanvasLoader"], "name": "heartcode-canvasloader.js", "module": "CanvasLoader"}}} \ No newline at end of file diff --git a/heartcode-canvasloader-2.html b/heartcode-canvasloader-2.html deleted file mode 100644 index 573b711..0000000 --- a/heartcode-canvasloader-2.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Heartcode Canvas loader - - - - - - - - -
    - - - \ No newline at end of file diff --git a/heartcode-canvasloader.html b/heartcode-canvasloader.html index 794c9fc..797b754 100644 --- a/heartcode-canvasloader.html +++ b/heartcode-canvasloader.html @@ -1,4 +1,4 @@ - +