mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -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
|
// If we're returning 'bounds', create a LinkedRectangle that uses
|
||||||
// the setBounds() setter to update the Item whenever the bounds are
|
// the setBounds() setter to update the Item whenever the bounds are
|
||||||
// changed:
|
// changed:
|
||||||
return name == 'bounds' ? LinkedRectangle.create(this, 'setBounds',
|
return name == 'getBounds'
|
||||||
bounds.x, bounds.y, bounds.width, bounds.height) : bounds;
|
? 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# */{
|
/** @lends Item# */{
|
||||||
|
@ -691,9 +695,7 @@ var Item = this.Item = Base.extend(Callback, {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
if (!this._bounds)
|
if (!this._bounds)
|
||||||
this._bounds = {};
|
this._bounds = {};
|
||||||
// Put a separate instance into the cache, so modifications of the
|
this._bounds[cache] = bounds;
|
||||||
// returned one won't affect it.
|
|
||||||
this._bounds[cache] = bounds.clone();
|
|
||||||
}
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue