mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +08:00
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:
9
dist/kinetic-core.js
vendored
9
dist/kinetic-core.js
vendored
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user