mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Improve handling of bounds caching.
Cloning was done in the wrong place.
This commit is contained in:
parent
0a81787c7e
commit
afac35fabf
1 changed files with 7 additions and 5 deletions
|
@ -634,8 +634,12 @@ var Item = this.Item = Base.extend(Callback, {
|
|||
// If we're returning 'bounds', create a LinkedRectangle that uses
|
||||
// the setBounds() setter to update the Item whenever the bounds are
|
||||
// changed:
|
||||
return name == 'bounds' ? LinkedRectangle.create(this, 'setBounds',
|
||||
bounds.x, bounds.y, bounds.width, bounds.height) : bounds;
|
||||
return name == 'getBounds'
|
||||
? LinkedRectangle.create(this, 'setBounds',
|
||||
bounds.x, bounds.y, bounds.width, bounds.height)
|
||||
// Return a clone of the cahce, so modifications won't
|
||||
// affect it.
|
||||
: bounds.clone();
|
||||
};
|
||||
},
|
||||
/** @lends Item# */{
|
||||
|
@ -691,9 +695,7 @@ var Item = this.Item = Base.extend(Callback, {
|
|||
if (cache) {
|
||||
if (!this._bounds)
|
||||
this._bounds = {};
|
||||
// Put a separate instance into the cache, so modifications of the
|
||||
// returned one won't affect it.
|
||||
this._bounds[cache] = bounds.clone();
|
||||
this._bounds[cache] = bounds;
|
||||
}
|
||||
return bounds;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue