fixed layer drawFunc bug. Now using call() for layer beforeDraw and afterDraw custom functions so that they are executed from the layer's context

This commit is contained in:
Eric Rowell
2012-05-19 22:18:33 -07:00
parent 7fcf5f156a
commit 97ddb507ea
3 changed files with 36 additions and 38 deletions

View File

@@ -2315,7 +2315,6 @@ Kinetic.Layer = function(config) {
this.lastDrawTime = 0;
this.beforeDrawFunc = undefined;
this.afterDrawFunc = undefined;
this.drawFunc = undefined;
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
@@ -2435,14 +2434,14 @@ Kinetic.Layer.prototype = {
// before draw handler
if(this.beforeDrawFunc !== undefined) {
this.beforeDrawFunc();
this.beforeDrawFunc.call(this);
}
this.clear();
if(this.attrs.visible) {
// draw custom func
if (this.drawFunc !== undefined) {
this.drawFunc();
if(this.attrs.drawFunc !== undefined) {
this.attrs.drawFunc.call(this);
}
// draw children
@@ -2451,7 +2450,7 @@ Kinetic.Layer.prototype = {
// after draw handler
if(this.afterDrawFunc !== undefined) {
this.afterDrawFunc();
this.afterDrawFunc.call(this);
}
}
};

File diff suppressed because one or more lines are too long

View File

@@ -18,7 +18,6 @@ Kinetic.Layer = function(config) {
this.lastDrawTime = 0;
this.beforeDrawFunc = undefined;
this.afterDrawFunc = undefined;
this.drawFunc = undefined;
this.canvas = document.createElement('canvas');
this.context = this.canvas.getContext('2d');
@@ -138,14 +137,14 @@ Kinetic.Layer.prototype = {
// before draw handler
if(this.beforeDrawFunc !== undefined) {
this.beforeDrawFunc();
this.beforeDrawFunc.call(this);
}
this.clear();
if(this.attrs.visible) {
// draw custom func
if (this.drawFunc !== undefined) {
this.drawFunc();
if(this.attrs.drawFunc !== undefined) {
this.attrs.drawFunc.call(this);
}
// draw children
@@ -154,7 +153,7 @@ Kinetic.Layer.prototype = {
// after draw handler
if(this.afterDrawFunc !== undefined) {
this.afterDrawFunc();
this.afterDrawFunc.call(this);
}
}
};