From 5adf772a64ce444334bc41dc527fd6bf30372ea8 Mon Sep 17 00:00:00 2001 From: Kienz Date: Wed, 9 Oct 2013 20:57:41 +0200 Subject: [PATCH] Invisible objects are no longer selectable with "selection-mode" (canvas.selection = true) - Closes issue #891 --- src/canvas.class.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index d963693f..64da852a 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -739,8 +739,11 @@ /** * @private + * @param {Event} e mouse event */ _findSelectedObjects: function (e) { + if (!this.selection) return; + var group = [ ], x1 = this._groupSelector.ex, y1 = this._groupSelector.ey, @@ -754,20 +757,18 @@ for (var i = this._objects.length; i--; ) { currentObject = this._objects[i]; - if (!currentObject) continue; + if (!currentObject || !currentObject.selectable || !currentObject.visible) continue; if (currentObject.intersectsWithRect(selectionX1Y1, selectionX2Y2) || currentObject.isContainedWithinRect(selectionX1Y1, selectionX2Y2) || currentObject.containsPoint(selectionX1Y1) || - currentObject.containsPoint(selectionX2Y2)) { + currentObject.containsPoint(selectionX2Y2) + ) { + currentObject.set('active', true); + group.push(currentObject); - if (this.selection && currentObject.selectable) { - currentObject.set('active', true); - group.push(currentObject); - - // only add one object if it's a click - if (isClick) break; - } + // only add one object if it's a click + if (isClick) break; } }