mirror of
https://github.com/konvajs/konva.git
synced 2026-01-09 11:34:38 +08:00
draw events no longer bubble. It was causing too much of a performance hit, and didn't provide a whole lot of value. Now, only layers fire draw events
This commit is contained in:
15
src/Layer.js
15
src/Layer.js
@@ -1,6 +1,8 @@
|
||||
(function() {
|
||||
// constants
|
||||
var HASH = '#';
|
||||
var HASH = '#',
|
||||
BEFORE_DRAW ='beforeDraw',
|
||||
DRAW = 'draw';
|
||||
|
||||
Kinetic.Util.addMethods(Kinetic.Layer, {
|
||||
___init: function(config) {
|
||||
@@ -51,11 +53,20 @@
|
||||
drawScene: function(canvas) {
|
||||
canvas = canvas || this.getCanvas();
|
||||
|
||||
this._fire(BEFORE_DRAW, {
|
||||
node: this
|
||||
});
|
||||
|
||||
if(this.getClearBeforeDraw()) {
|
||||
canvas.clear();
|
||||
}
|
||||
|
||||
|
||||
Kinetic.Container.prototype.drawScene.call(this, canvas);
|
||||
|
||||
this._fire(DRAW, {
|
||||
node: this
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
drawHit: function() {
|
||||
|
||||
@@ -1117,7 +1117,7 @@
|
||||
return this;
|
||||
},
|
||||
shouldDrawHit: function() {
|
||||
return this.isVisible() && this.isListening() && !Kinetic.Global.isDragging();
|
||||
return this.isListening() && this.isVisible() && !Kinetic.Global.isDragging();
|
||||
},
|
||||
isDraggable: function() {
|
||||
return false;
|
||||
|
||||
17
src/Shape.js
17
src/Shape.js
@@ -1,7 +1,4 @@
|
||||
(function() {
|
||||
var BEFORE_DRAW = 'beforeDraw',
|
||||
DRAW = 'draw';
|
||||
|
||||
function _fillFunc(context) {
|
||||
context.fill();
|
||||
}
|
||||
@@ -210,25 +207,11 @@
|
||||
canvas._applyOpacity(this);
|
||||
canvas._applyLineJoin(this);
|
||||
canvas._applyAncestorTransforms(this);
|
||||
this._fireBeforeDrawEvents();
|
||||
drawFunc.call(this, canvas);
|
||||
this._fireDrawEvents();
|
||||
context.restore();
|
||||
|
||||
|
||||
}
|
||||
return this;
|
||||
},
|
||||
_fireBeforeDrawEvents: function() {
|
||||
this._fireAndBubble(BEFORE_DRAW, {
|
||||
node: this
|
||||
});
|
||||
},
|
||||
_fireDrawEvents: function() {
|
||||
this._fireAndBubble(DRAW, {
|
||||
node: this
|
||||
});
|
||||
},
|
||||
drawHit: function() {
|
||||
var attrs = this.getAttrs(),
|
||||
drawFunc = attrs.drawHitFunc || attrs.drawFunc,
|
||||
|
||||
Reference in New Issue
Block a user