diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index 939e4863..31704908 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -414,7 +414,7 @@ var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{ * point and finding the new bounding box to these points. This is not * really the transformed reactangle! */ - _transformBounds: function(bounds) { + _transformBounds: function(bounds, dest, dontNotify) { var coords = this._transformCorners(bounds), min = coords.slice(0, 2), max = coords.slice(0); @@ -426,8 +426,10 @@ var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{ else if (val > max[j]) max[j] = val; } - return Rectangle.create(min[0], min[1], - max[0] - min[0], max[1] - min[1]); + if (!dest) + dest = new Rectangle(Rectangle.dont); + return dest.set(min[0], min[1], max[0] - min[0], max[1] - min[1], + dontNotify); }, /** diff --git a/src/item/Item.js b/src/item/Item.js index 90fb0830..7ef28f21 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1699,8 +1699,13 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ // and transform the cached _bounds and _position without having to // fully recalculate each time. if (bounds && matrix.getRotation() % 90 === 0) { - this._bounds = this._createBounds( - matrix._transformBounds(bounds)); + // Transform the old _bounds without notifying it of changes + this._bounds = matrix._transformBounds(bounds, bounds, true); + // Update _position again, by linking it to _bounds + // TODO: If LinkedPoint would not just sync writes, but reads too, + // we could do this: this._position = position; + // This is a bug currently in Paper.js, that should be fixed, but + // can only really be handled properly using versioning... this._position = this._bounds.getCenter(); } else if (position) { // Transform position as well. Do not notify _position of diff --git a/src/text/PointText.js b/src/text/PointText.js index d059ba77..73f172fb 100644 --- a/src/text/PointText.js +++ b/src/text/PointText.js @@ -129,7 +129,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{ // rough guess var bounds = Rectangle.create(x, leading / 4 + (count - 1) * leading, width, -count * leading); - bounds = this._matrix._transformBounds(bounds); + this._matrix._transformBounds(bounds, bounds); // TODO: Only cache if no matrix is provided this[cacheName] = bounds; return getter == 'getBounds' ? this._createBounds(bounds) : bounds;