mirror of
https://github.com/konvajs/konva.git
synced 2025-08-24 07:31:47 +08:00
removed Sprite afterFrame func. The same functionality can be achieved by listening to indexChange event
This commit is contained in:
parent
c5dd9e1090
commit
d3eb9990bd
@ -126,13 +126,7 @@
|
||||
this.anim.setLayers(layer);
|
||||
|
||||
this.interval = setInterval(function() {
|
||||
var index = that.getIndex();
|
||||
that._updateIndex();
|
||||
if(that.afterFrameFunc && index === that.afterFrameIndex) {
|
||||
that.afterFrameFunc();
|
||||
delete that.afterFrameFunc;
|
||||
delete that.afterFrameIndex;
|
||||
}
|
||||
}, 1000 / this.getFrameRate());
|
||||
|
||||
this.anim.start();
|
||||
@ -146,17 +140,6 @@
|
||||
this.anim.stop();
|
||||
clearInterval(this.interval);
|
||||
},
|
||||
/**
|
||||
* set after frame event handler
|
||||
* @method
|
||||
* @memberof Kinetic.Sprite.prototype
|
||||
* @param {Integer} index frame index
|
||||
* @param {Function} func function to be executed after frame has been drawn
|
||||
*/
|
||||
afterFrame: function(index, func) {
|
||||
this.afterFrameIndex = index;
|
||||
this.afterFrameFunc = func;
|
||||
},
|
||||
_updateIndex: function() {
|
||||
var index = this.getIndex(),
|
||||
animation = this.getAnimation(),
|
||||
|
@ -108,9 +108,10 @@ suite('Sprite', function() {
|
||||
// kick once
|
||||
setTimeout(function() {
|
||||
sprite.setAnimation('kicking');
|
||||
|
||||
sprite.afterFrame(5, function() {
|
||||
sprite.setAnimation('standing');
|
||||
sprite.on('indexChange', function(evt) {
|
||||
if (evt.newVal === 0 && this.getAnimation() === 'kicking') {
|
||||
sprite.setAnimation('standing');
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
setTimeout(function() {
|
||||
|
Loading…
Reference in New Issue
Block a user