mirror of
https://github.com/konvajs/konva.git
synced 2026-01-23 13:26:07 +08:00
fixed wrong opacity level for cached group with opacity. close #191
This commit is contained in:
@@ -217,7 +217,7 @@
|
||||
},
|
||||
_applyOpacity: function(shape) {
|
||||
var absOpacity = shape.getAbsoluteOpacity();
|
||||
if(absOpacity !== 1) {
|
||||
if (absOpacity !== 1) {
|
||||
this.setAttr('globalAlpha', absOpacity);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
this.attrs = {};
|
||||
this._cache = {};
|
||||
this._filterUpToDate = false;
|
||||
this._isUnderCache = false;
|
||||
this.setAttrs(config);
|
||||
|
||||
// event bindings for cache handling
|
||||
@@ -217,8 +218,13 @@
|
||||
sceneContext.translate(-x, -y);
|
||||
hitContext.translate(-x, -y);
|
||||
|
||||
// extra flag to skip on getAbsolute opacity calc
|
||||
this._isUnderCache = true;
|
||||
this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
|
||||
|
||||
this.drawScene(cachedSceneCanvas, this, true);
|
||||
this.drawHit(cachedHitCanvas, this, true);
|
||||
this._isUnderCache = false;
|
||||
|
||||
sceneContext.restore();
|
||||
hitContext.restore();
|
||||
@@ -1138,7 +1144,8 @@
|
||||
},
|
||||
_getAbsoluteOpacity: function() {
|
||||
var absOpacity = this.getOpacity();
|
||||
if(this.getParent()) {
|
||||
var parent = this.getParent();
|
||||
if(parent && !parent._isUnderCache) {
|
||||
absOpacity *= this.getParent().getAbsoluteOpacity();
|
||||
}
|
||||
return absOpacity;
|
||||
|
||||
Reference in New Issue
Block a user