mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
Transformer optimizations
This commit is contained in:
11
src/Node.js
11
src/Node.js
@@ -52,7 +52,6 @@
|
||||
|
||||
Konva.Util.addMethods(Konva.Node, {
|
||||
_init: function(config) {
|
||||
var that = this;
|
||||
this._id = Konva.idCounter++;
|
||||
this.eventListeners = {};
|
||||
this.attrs = {};
|
||||
@@ -64,21 +63,21 @@
|
||||
// event bindings for cache handling
|
||||
this.on(TRANSFORM_CHANGE_STR, function() {
|
||||
this._clearCache(TRANSFORM);
|
||||
that._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
|
||||
this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM);
|
||||
});
|
||||
|
||||
this.on(SCALE_CHANGE_STR, function() {
|
||||
that._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
|
||||
this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
|
||||
});
|
||||
|
||||
this.on('visibleChange.konva', function() {
|
||||
that._clearSelfAndDescendantCache(VISIBLE);
|
||||
this._clearSelfAndDescendantCache(VISIBLE);
|
||||
});
|
||||
this.on('listeningChange.konva', function() {
|
||||
that._clearSelfAndDescendantCache(LISTENING);
|
||||
this._clearSelfAndDescendantCache(LISTENING);
|
||||
});
|
||||
this.on('opacityChange.konva', function() {
|
||||
that._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
||||
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
||||
});
|
||||
},
|
||||
_clearCache: function(attr) {
|
||||
|
@@ -163,10 +163,12 @@
|
||||
TRANSFORM_CHANGE_STR,
|
||||
function() {
|
||||
this._clearCache(NODE_RECT);
|
||||
this._clearCache('transform');
|
||||
this._clearSelfAndDescendantCache('absoluteTransform');
|
||||
}.bind(this)
|
||||
);
|
||||
node.on(TRANSFORM_CHANGE_STR, this.requestUpdate.bind(this));
|
||||
node.on('dragmove.resizer', this.requestUpdate.bind(this));
|
||||
// node.on(TRANSFORM_CHANGE_STR, this.requestUpdate.bind(this));
|
||||
// node.on('dragmove.resizer', this.requestUpdate.bind(this));
|
||||
|
||||
var elementsCreated = !!this.findOne('.top-left');
|
||||
if (elementsCreated) {
|
||||
@@ -181,7 +183,11 @@
|
||||
detach: function() {
|
||||
if (this.getNode()) {
|
||||
this.getNode().off('.resizer');
|
||||
this._node = undefined;
|
||||
}
|
||||
this._clearCache(NODE_RECT);
|
||||
this._clearCache('transform');
|
||||
this._clearSelfAndDescendantCache('absoluteTransform');
|
||||
},
|
||||
|
||||
_getNodeRect: function() {
|
||||
@@ -590,13 +596,8 @@
|
||||
},
|
||||
update: function() {
|
||||
var attrs = this._getNodeRect();
|
||||
var x = attrs.x;
|
||||
var y = attrs.y;
|
||||
var width = attrs.width;
|
||||
var height = attrs.height;
|
||||
this.x(x);
|
||||
this.y(y);
|
||||
this.rotation(attrs.rotation);
|
||||
|
||||
var enabledHandlers = this.enabledHandlers();
|
||||
var resizeEnabled = this.resizeEnabled();
|
||||
|
Reference in New Issue
Block a user