Merge branch 'fix-cache-hit-before-added-to-layer' of git://github.com/kzhdev/KineticJS into kzhdev-fix-cache-hit-before-added-to-layer

This commit is contained in:
Лаврёнов Антон 2014-05-04 11:55:43 +08:00
commit 224790f7c9
3 changed files with 7 additions and 4 deletions

View File

@ -306,7 +306,7 @@
cachedCanvas = this._cache.canvas,
cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
if (this.shouldDrawHit()) {
if (this.shouldDrawHit(canvas)) {
if (cachedHitCanvas) {
this._drawCachedHitCanvas(context);
}

View File

@ -175,6 +175,8 @@
sceneContext = cachedSceneCanvas.getContext(),
hitContext = cachedHitCanvas.getContext();
cachedHitCanvas.isCache = true;
this.clearCache();
sceneContext.save();
@ -638,9 +640,10 @@
* @memberof Kinetic.Node.prototype
* @returns {Boolean}
*/
shouldDrawHit: function() {
shouldDrawHit: function(canvas) {
var layer = this.getLayer();
return layer && layer.hitGraphEnabled() && this.isListening() && this.isVisible() && !Kinetic.isDragging();
return ((canvas && canvas.isCache) || (layer && layer.hitGraphEnabled()))
&& this.isListening() && this.isVisible() && !Kinetic.isDragging();
},
/**
* show node

View File

@ -202,7 +202,7 @@
cachedCanvas = this._cache.canvas,
cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
if(this.shouldDrawHit()) {
if(this.shouldDrawHit(canvas)) {
if (cachedHitCanvas) {
this._drawCachedHitCanvas(context);