Improve Item#_getStrokeMatrix()

This commit is contained in:
Jürg Lehni 2016-05-22 21:23:46 +02:00
parent 948a8af9a8
commit fefb4302e8
2 changed files with 9 additions and 8 deletions

View file

@ -209,7 +209,7 @@ new function() { // Injection scope for various item event handlers
* @param {ChangeFlag} flags describes what exactly has changed
*/
_changed: function(flags) {
var symbol = this._parentSymbol,
var symbol = this._symbol,
cacheParent = this._parent || symbol,
project = this._project;
if (flags & /*#=*/ChangeFlag.GEOMETRY) {
@ -911,7 +911,7 @@ new function() { // Injection scope for various item event handlers
].join('');
// NOTE: This needs to happen before returning cached values, since even
// then, _boundsCache needs to be kept up-to-date.
Item._updateBoundsCache(this._parent || this._parentSymbol, cacheItem);
Item._updateBoundsCache(this._parent || this._symbol, cacheItem);
if (cacheKey && this._bounds && cacheKey in this._bounds)
return this._bounds[cacheKey].rect.clone();
var bounds = this._getBounds(matrix || _matrix, options);
@ -936,9 +936,10 @@ new function() { // Injection scope for various item event handlers
* is always shiftless, meaning its translation vector is reset to zero.
*/
_getStrokeMatrix: function(matrix, options) {
var mx = this.getStrokeScaling() ? matrix : (options && options.internal
? this : this._parent || this._parentSymbol._item)
.getViewMatrix().invert();
var parent = this.getStrokeScaling() ? null
: options && options.internal ? this
: this._parent || this._symbol && this._symbol._item,
mx = parent ? parent.getViewMatrix().invert() : matrix;
return mx && mx._shiftless();
},

View file

@ -104,11 +104,11 @@ var SymbolDefinition = Base.extend(/** @lends SymbolDefinition# */{
setItem: function(item, _dontCenter) {
// Make sure we're not stealing another symbol's definition
if (item._parentSymbol)
if (item._symbol)
item = item.clone();
// Remove previous definition's reference to this symbol
if (this._item)
this._item._parentSymbol = null;
this._item._symbol = null;
this._item = item;
// Remove item from DOM, as it's embedded in Symbol now.
item.remove();
@ -116,7 +116,7 @@ var SymbolDefinition = Base.extend(/** @lends SymbolDefinition# */{
// Move position to 0, 0, so it's centered when placed.
if (!_dontCenter)
item.setPosition(new Point());
item._parentSymbol = this;
item._symbol = this;
this._changed(/*#=*/Change.GEOMETRY);
},