fixed afterFrame index bug which caused the event to trigger on the wrong index

This commit is contained in:
Eric Rowell
2012-07-08 19:15:23 -07:00
parent d0f37f7c88
commit 5169c93219
5 changed files with 9 additions and 7 deletions

View File

@@ -2574,7 +2574,7 @@ Kinetic.Stage = Kinetic.Container.extend({
}, },
_removeId: function(node) { _removeId: function(node) {
if(node.attrs.id !== undefined) { if(node.attrs.id !== undefined) {
this.ids[node.attrs.id] = undefined; delete this.ids[node.attrs.id];
} }
}, },
_addName: function(node) { _addName: function(node) {
@@ -3712,8 +3712,9 @@ Kinetic.Sprite = Kinetic.Shape.extend({
ka._addAnimation(this.anim); ka._addAnimation(this.anim);
this.interval = setInterval(function() { this.interval = setInterval(function() {
var index = that.attrs.index;
that._updateIndex(); that._updateIndex();
if(that.afterFrameFunc && that.attrs.index === that.afterFrameIndex) { if(that.afterFrameFunc && index === that.afterFrameIndex) {
that.afterFrameFunc(); that.afterFrameFunc();
} }
}, 1000 / this.attrs.frameRate); }, 1000 / this.attrs.frameRate);

File diff suppressed because one or more lines are too long

View File

@@ -883,7 +883,7 @@ Kinetic.Stage = Kinetic.Container.extend({
}, },
_removeId: function(node) { _removeId: function(node) {
if(node.attrs.id !== undefined) { if(node.attrs.id !== undefined) {
this.ids[node.attrs.id] = undefined; delete this.ids[node.attrs.id];
} }
}, },
_addName: function(node) { _addName: function(node) {

View File

@@ -68,8 +68,9 @@ Kinetic.Sprite = Kinetic.Shape.extend({
ka._addAnimation(this.anim); ka._addAnimation(this.anim);
this.interval = setInterval(function() { this.interval = setInterval(function() {
var index = that.attrs.index;
that._updateIndex(); that._updateIndex();
if(that.afterFrameFunc && that.attrs.index === that.afterFrameIndex) { if(that.afterFrameFunc && index === that.afterFrameIndex) {
that.afterFrameFunc(); that.afterFrameFunc();
} }
}, 1000 / this.attrs.frameRate); }, 1000 / this.attrs.frameRate);

View File

@@ -1395,7 +1395,7 @@ Test.prototype.tests = {
radius: [70, 35], radius: [70, 35],
fill: 'green', fill: 'green',
stroke: 'black', stroke: 'black',
strokeWidth: 4 strokeWidth: 8
}); });
layer.add(circle); layer.add(circle);
stage.add(layer); stage.add(layer);