mirror of
https://github.com/konvajs/konva.git
synced 2025-08-24 06:12:19 +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.anim.setLayers(layer);
|
||||||
|
|
||||||
this.interval = setInterval(function() {
|
this.interval = setInterval(function() {
|
||||||
var index = that.getIndex();
|
|
||||||
that._updateIndex();
|
that._updateIndex();
|
||||||
if(that.afterFrameFunc && index === that.afterFrameIndex) {
|
|
||||||
that.afterFrameFunc();
|
|
||||||
delete that.afterFrameFunc;
|
|
||||||
delete that.afterFrameIndex;
|
|
||||||
}
|
|
||||||
}, 1000 / this.getFrameRate());
|
}, 1000 / this.getFrameRate());
|
||||||
|
|
||||||
this.anim.start();
|
this.anim.start();
|
||||||
@ -146,17 +140,6 @@
|
|||||||
this.anim.stop();
|
this.anim.stop();
|
||||||
clearInterval(this.interval);
|
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() {
|
_updateIndex: function() {
|
||||||
var index = this.getIndex(),
|
var index = this.getIndex(),
|
||||||
animation = this.getAnimation(),
|
animation = this.getAnimation(),
|
||||||
|
@ -108,9 +108,10 @@ suite('Sprite', function() {
|
|||||||
// kick once
|
// kick once
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
sprite.setAnimation('kicking');
|
sprite.setAnimation('kicking');
|
||||||
|
sprite.on('indexChange', function(evt) {
|
||||||
sprite.afterFrame(5, function() {
|
if (evt.newVal === 0 && this.getAnimation() === 'kicking') {
|
||||||
sprite.setAnimation('standing');
|
sprite.setAnimation('standing');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user