mirror of
https://github.com/konvajs/konva.git
synced 2025-09-22 20:14:01 +08:00
moved drawFunc definition out of the shape initializers as a method to improve space performance
This commit is contained in:
@@ -14,19 +14,7 @@ Kinetic.Sprite = Kinetic.Shape.extend({
|
||||
frameRate: 17
|
||||
});
|
||||
|
||||
config.drawFunc = function(context) {
|
||||
if(!!this.attrs.image) {
|
||||
var anim = this.attrs.animation;
|
||||
var index = this.attrs.index;
|
||||
var f = this.attrs.animations[anim][index];
|
||||
|
||||
context.beginPath();
|
||||
context.rect(0, 0, f.width, f.height);
|
||||
context.closePath();
|
||||
|
||||
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
|
||||
}
|
||||
};
|
||||
config.drawFunc = this.drawFunc;
|
||||
// call super constructor
|
||||
this._super(config);
|
||||
|
||||
@@ -36,6 +24,19 @@ Kinetic.Sprite = Kinetic.Shape.extend({
|
||||
that.setIndex(0);
|
||||
});
|
||||
},
|
||||
drawFunc: function(context) {
|
||||
if(this.attrs.image) {
|
||||
var anim = this.attrs.animation;
|
||||
var index = this.attrs.index;
|
||||
var f = this.attrs.animations[anim][index];
|
||||
|
||||
context.beginPath();
|
||||
context.rect(0, 0, f.width, f.height);
|
||||
context.closePath();
|
||||
|
||||
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* start sprite animation
|
||||
* @name start
|
||||
|
Reference in New Issue
Block a user