heartcode / CanvasLoader

Heartcode CanvasLoader is a lightweight JavaScript UI library, which uses the HTML canvas element to draw and animate circular preloaders. The library is currently in beta, some minor changes and improvements might be done to it in the near future.
http://heartcode.robertpataki.com
285 stars 81 forks source link

Scoping issue (reported by Jens Meineck) #29

Closed heartcode closed 10 years ago

heartcode commented 10 years ago

I've started using your canvas loader script - it is simply awesome...

Everything worked fine until I did some tidying up of my code today when canavasloader stopped working.

A little digging revealed that you have the following lines in your code:

    /**
    * Shows the rendering of the loader animation
    * @method show
    * @public
    */
    p.show = function () {
            if (typeof (this.timer) !== "number") {
                    var t = this;
                    this.timer = self.setInterval(function () { t.tick(); }, Math.round(1000 / this.fps));
                    setCSS(this.cont, {display: "block"});
            }
    };

notice the

    self.setInterval (.....

since you never define self it resolved it to another object in my scope that cause a problem. Removing the

    self.

from the expression seems to fix the problem.