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.
This commit is contained in:
Jürg Lehni 2011-12-26 11:08:09 +01:00
parent 28806fe977
commit 873cd79517

View file

@ -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);