Do not change cashed decomposed matrix data when transforming content.

Just clear the cache and force new decomposition on next use, to avoid issues with nested applied transforms.

Closes #1004
This commit is contained in:
Jürg Lehni 2016-06-14 15:16:45 +02:00
parent 2551027d17
commit f6b77b7442

View file

@ -1077,12 +1077,7 @@ new function() { // Injection scope for various item event handlers
setRotation: function(rotation) { setRotation: function(rotation) {
var current = this.getRotation(); var current = this.getRotation();
if (current != null && rotation != null) { if (current != null && rotation != null) {
// Preserve the cached _decomposed values over rotation, and only
// update the rotation property on it.
var decomposed = this._decomposed;
this.rotate(rotation - current); this.rotate(rotation - current);
decomposed.rotation = rotation;
this._decomposed = decomposed;
} }
}, },
@ -1101,15 +1096,11 @@ new function() { // Injection scope for various item event handlers
}, },
setScaling: function(/* scaling */) { setScaling: function(/* scaling */) {
var current = this.getScaling(); var current = this.getScaling(),
if (current) {
// Clone existing points since we're caching internally. // Clone existing points since we're caching internally.
var scaling = Point.read(arguments, 0, { clone: true }), scaling = Point.read(arguments, 0, { clone: true, readNull: true })
// See #setRotation() for preservation of _decomposed. if (current && scaling) {
decomposed = this._decomposed;
this.scale(scaling.x / current.x, scaling.y / current.y); this.scale(scaling.x / current.x, scaling.y / current.y);
decomposed.scaling = scaling;
this._decomposed = decomposed;
} }
}, },