removed animations length cached variable because the length can change while the for loop is running

This commit is contained in:
Eric Rowell
2013-01-09 08:27:57 -08:00
parent eef3d58a1c
commit ffaa108830
2 changed files with 7 additions and 3 deletions

View File

@@ -70,7 +70,7 @@
};
Kinetic.Animation._runFrames = function() {
var nodes = {}, animations = this.animations, len = animations.length;
var nodes = {}, animations = this.animations;
/*
* loop through all animations and execute animation
* function. if the animation object has specified node,
@@ -78,7 +78,11 @@
* drawing the same node multiple times. The node property
* can be the stage itself or a layer
*/
for(var n = 0; n < len; n++) {
/*
* WARNING: don't cache animations.length because it could change while
* the for loop is running, causing a JS error
*/
for(var n = 0; n < animations.length; n++) {
var anim = animations[n], node = anim.node, func = anim.func;
anim._updateFrameObject(new Date().getTime());
if(node && node._id !== undefined) {

View File

@@ -142,7 +142,7 @@ Test.Modules.MANUAL = {
stage.add(layer);
},
'*ANIMATION - start and stop animation': function(containerId) {
'ANIMATION - start and stop animation': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,