From 873cd795177d9bed3f39e46484c99c11a61b2b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 26 Dec 2011 11:08:09 +0100 Subject: [PATCH] Fix a bug in code that keeps #_position cache up to date. Only happened in items that assign another type to 'bounds' through _boundsType, e.g. PlacedSymbol, leading to substantial slow downs. --- src/item/Item.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index b13d4da7..13f89485 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1849,11 +1849,15 @@ function(name) { // in _bounds and transform each. for (var key in bounds) { var rect = bounds[key]; - // If we have cached 'bounds', update _position again - if (key == 'bounds') - this._position = rect.getCenter(true); bounds[key] = matrix._transformBounds(rect, rect); } + // If we have cached 'bounds', update _position again as its + // center. We need to take into account _boundsType here too, in + // case another type is assigned to it, e.g. 'strokeBounds'. + var type = this._boundsType, + rect = bounds[type && type.bounds || 'bounds']; + if (rect) + this._position = rect.getCenter(true); } else if (position) { // Transform position as well. this._position = matrix._transformPoint(position, position);