diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index c6d9d899..3e57be9b 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -70,16 +70,20 @@ var Matrix = Base.extend(/** @lends Matrix# */{ * @name Matrix#initialize * @param {Matrix} matrix the matrix to copy the values from */ - initialize: function Matrix(arg) { + initialize: function Matrix(arg, _dontNotify) { var count = arguments.length, ok = true; - if (count === 6) { + if (count >= 6) { // >= 6 to pass on optional _dontNotify argument. this._set.apply(this, arguments); - } else if (count === 1) { + } else if (count === 1 || count === 2) { + // Support both Matrix and Array arguments through #_set(), and pass + // on the optional _dontNotify argument: if (arg instanceof Matrix) { - this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty); + this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty, + _dontNotify); } else if (Array.isArray(arg)) { - this._set.apply(this, arg); + this._set.apply(this, + _dontNotify ? arg.concat([_dontNotify]) : arg); } else { ok = false; } diff --git a/src/item/Item.js b/src/item/Item.js index bfd09a82..6537ce11 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1562,7 +1562,7 @@ new function() { // Injection scope for various item event handlers } // Use Matrix#initialize to easily copy over values. if (!excludeMatrix) - this._matrix.set(source._matrix); + this._matrix.set(source._matrix, true); // We can't just set _applyMatrix as many item types won't allow it, // e.g. creating a Shape in Path#toShape(). // Using the setter instead takes care of it. diff --git a/test/tests/Item_Cloning.js b/test/tests/Item_Cloning.js index b3051744..762701d0 100644 --- a/test/tests/Item_Cloning.js +++ b/test/tests/Item_Cloning.js @@ -179,3 +179,22 @@ test('Item#clone() Hierarchy', function() { return clone.isBelow(path2); }, true); }); + +test('Item#clone() and #applyMatrix (#1225)', function() { + var group = new Group({ + applyMatrix: false, + children: [ + new Shape.Rectangle({ + size: [100, 100], + point: [100, 100], + strokeColor: 'red', + }) + ] + }); + + group.translate(300, 300); + + equals(function() { + return group.clone().matrix.translation; + }, new Point(300, 300)); +}); diff --git a/test/tests/PathItem.js b/test/tests/PathItem.js index 6ff1ae79..41b89e28 100644 --- a/test/tests/PathItem.js +++ b/test/tests/PathItem.js @@ -122,7 +122,7 @@ test('PathItem#create() with SVG path-data (#1101)', function() { test('PathItem#compare()', function() { var empty = new Path(); var circle = new Path.Circle({ - point: [100, 100], + center: [100, 100], radius: 100 }); var square = new Path.Rectangle({