diff --git a/src/item/Group.js b/src/item/Group.js index 8a47a29c..5a592a28 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -71,17 +71,10 @@ var Group = this.Group = Item.extend({ this.base(); this._children = []; this._namedChildren = {}; - this._clipped = false; this.setChildren(!items || !Array.isArray(items) || typeof items[0] !== 'object' ? arguments : items); }, - clone: function() { - var copy = this.base(); - copy._clipped = this._clipped; - return copy; - }, - /** * Specifies whether the group item is to be clipped. * When setting to {@code true}, the first child in the group is @@ -91,20 +84,22 @@ var Group = this.Group = Item.extend({ * @bean */ isClipped: function() { - return this._clipped; + for (var i = 0, l = this._children.length; i < l; i++) { + if (this._children[i]._clipMask) + return true; + } + return false; }, setClipped: function(clipped) { - this._clipped = clipped; var child = this.getFirstChild(); if (child) child.setClipMask(clipped); + return this; }, draw: function(ctx, param) { for (var i = 0, l = this._children.length; i < l; i++) { - // the group is clipped on its first child - param.clip = this._clipped && i == 0; Item.draw(this._children[i], ctx, param); } } diff --git a/src/item/Item.js b/src/item/Item.js index 06ff1c08..f32dae0b 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -290,7 +290,7 @@ var Item = this.Item = Base.extend({ setClipMask: function(clipMask) { this._clipMask = clipMask; - if (this._clipMask) { + if (clipMask) { this.setFillColor(null); this.setStrokeColor(null); } diff --git a/src/path/Path.js b/src/path/Path.js index 3868807e..aa7a9087 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1249,7 +1249,7 @@ var Path = this.Path = PathItem.extend({ dashArray = this.getDashArray() || [], // TODO: Always defined? hasDash = !!dashArray.length; - if (param.compound || param.selection || param.clip || fillColor + if (param.compound || param.selection || this._clipMask || fillColor || strokeColor && !hasDash) { drawSegments(ctx, this); } @@ -1259,7 +1259,7 @@ var Path = this.Path = PathItem.extend({ if (param.selection) { ctx.stroke(); drawHandles(ctx, this._segments); - } else if (param.clip) { + } else if (this._clipMask) { ctx.clip(); } else if (!param.compound && (fillColor || strokeColor)) { // If the path is part of a compound path or doesn't have a fill