mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix: nested group matrix should not be reset
When a group had `applyMatrix` set to `false`, when its parent's matrix was applied, its matrix was applied to its children then it was reset. This makes sure that in this case, parent matrix is only added to child matrix but not applied to child's children and that child's matrix is not reset. Closes #1711
This commit is contained in:
parent
aa9dc86e7b
commit
f84199c83d
2 changed files with 27 additions and 16 deletions
|
@ -3549,24 +3549,25 @@ new function() { // Injection scope for hit-test functions shared with project
|
||||||
if (strokeColor)
|
if (strokeColor)
|
||||||
strokeColor.transform(matrix);
|
strokeColor.transform(matrix);
|
||||||
}
|
}
|
||||||
// Call #_transformContent() now, if we need to directly apply the
|
if (applyMatrix) {
|
||||||
// internal _matrix transformations to the item's content.
|
// Set the internal _applyMatrix flag to true if we're told to do so.
|
||||||
// Application is not possible on Raster, PointText, SymbolItem, since
|
|
||||||
// the matrix is where the actual transformation state is stored.
|
|
||||||
if (applyMatrix && (applyMatrix = this._transformContent(_matrix,
|
|
||||||
_applyRecursively, _setApplyMatrix))) {
|
|
||||||
// Pivot is provided in the parent's coordinate system, so transform
|
|
||||||
// it along too.
|
|
||||||
var pivot = this._pivot;
|
|
||||||
if (pivot)
|
|
||||||
_matrix._transformPoint(pivot, pivot, true);
|
|
||||||
// Reset the internal matrix to the identity transformation if
|
|
||||||
// it was possible to apply it, but do not notify owner of change.
|
|
||||||
_matrix.reset(true);
|
|
||||||
// Set the internal _applyMatrix flag to true if we're told to
|
|
||||||
// do so
|
|
||||||
if (_setApplyMatrix && this._canApplyMatrix)
|
if (_setApplyMatrix && this._canApplyMatrix)
|
||||||
this._applyMatrix = true;
|
this._applyMatrix = true;
|
||||||
|
// Call #_transformContent() now, if we need to directly apply the
|
||||||
|
// internal _matrix transformations to the item's content.
|
||||||
|
// Application is not possible on Raster, PointText, SymbolItem, since
|
||||||
|
// the matrix is where the actual transformation state is stored.
|
||||||
|
if (this._applyMatrix && (applyMatrix = this._transformContent(_matrix,
|
||||||
|
_applyRecursively, _setApplyMatrix))) {
|
||||||
|
// Pivot is provided in the parent's coordinate system, so transform
|
||||||
|
// it along too.
|
||||||
|
var pivot = this._pivot;
|
||||||
|
if (pivot)
|
||||||
|
_matrix._transformPoint(pivot, pivot, true);
|
||||||
|
// Reset the internal matrix to the identity transformation if
|
||||||
|
// it was possible to apply it, but do not notify owner of change.
|
||||||
|
_matrix.reset(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Calling _changed will clear _bounds and _position, but depending
|
// Calling _changed will clear _bounds and _position, but depending
|
||||||
// on matrix we can calculate and set them again, so preserve them.
|
// on matrix we can calculate and set them again, so preserve them.
|
||||||
|
|
|
@ -189,3 +189,13 @@ test(
|
||||||
equals(group.internalBounds, expected);
|
equals(group.internalBounds, expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test('group.matrix with parent matrix applied (#1711)', function() {
|
||||||
|
var child = new Group({ applyMatrix: false });
|
||||||
|
var parent = new Group([child]);
|
||||||
|
var scale = 1.1;
|
||||||
|
var initial = child.scaling.x;
|
||||||
|
parent.scale(scale);
|
||||||
|
var final = child.scaling.x;
|
||||||
|
equals(final, initial * scale);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue