Merge branch 'drag-performance-improvement' of git://github.com/kzhdev/KineticJS into kzhdev-drag-performance-improvement

This commit is contained in:
Лаврёнов Антон
2014-05-01 08:44:44 +08:00
2 changed files with 18 additions and 3 deletions

View File

@@ -227,7 +227,10 @@
// if animation object has a function, execute it // if animation object has a function, execute it
if(func) { if(func) {
func.call(anim, anim.frame); // allow anim bypassing drawing
if (false === func.call(anim, anim.frame)) {
return;
}
} }
} }
@@ -294,4 +297,4 @@
layer.batchDraw(); layer.batchDraw();
}); });
}; };
})(this); })(this);

View File

@@ -1,7 +1,11 @@
(function() { (function() {
Kinetic.DD = { Kinetic.DD = {
// properties // properties
anim: new Kinetic.Animation(), anim: new Kinetic.Animation(function(frame) {
var b = this.dirty;
this.dirty = false;
return b;
}),
isDragging: false, isDragging: false,
justDragged: false, justDragged: false,
offset: { offset: {
@@ -136,6 +140,14 @@
} }
this.setAbsolutePosition(newNodePos); this.setAbsolutePosition(newNodePos);
if (!this._lastPos ||
this._lastPos.x !== newNodePos.x ||
this._lastPos.y !== newNodePos.y) {
dd.anim.dirty = true;
}
this._lastPos = newNodePos;
}; };
/** /**