Skip to content

Commit

Permalink
fixed dirty (#3782)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Mar 14, 2017
1 parent e5b5e92 commit c145ac2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@
this.dirty = true;
}

if (this.group && this.stateProperties.indexOf(key) > -1) {
this.group.set('dirty', true);
}

if (key === 'width' || key === 'height') {
this.minScaleLimit = Math.min(0.1, 1 / Math.max(this.width, this.height));
}
Expand Down
9 changes: 4 additions & 5 deletions src/shapes/rect.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push('rx', 'ry');

var cacheProperties = fabric.Object.prototype.cacheProperties.concat();
cacheProperties.push('rx', 'ry');

/**
* Rectangle class
* @class fabric.Rect
Expand Down Expand Up @@ -50,11 +53,7 @@
*/
ry: 0,

/**
* Used to specify dash pattern for stroke on this object
* @type Array
*/
strokeDashArray: null,
cacheProperties: cacheProperties,

/**
* Constructor
Expand Down
11 changes: 11 additions & 0 deletions test/unit/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,17 @@
equal(g1.dirty, true, 'Group has dirty flag set');
});

test('dirty flag propagation from children up with', function() {
var g1 = makeGroupWith4Objects();
var obj = g1.item(0);
g1.dirty = false;
obj.dirty = false;
equal(g1.dirty, false, 'Group has no dirty flag set');
obj.set('angle', 5);
equal(obj.dirty, false, 'Obj has dirty flag still false');
equal(g1.dirty, true, 'Group has dirty flag set');
});

test('_getCacheCanvasDimensions returns dimensions and zoom for cache canvas are influenced by group', function() {
var g1 = makeGroupWith4Objects();
var obj = g1.item(0);
Expand Down
7 changes: 7 additions & 0 deletions test/unit/rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
ok(typeof rect.complexity == 'function');
});

test('cache properties', function() {
var rect = new fabric.Rect();

ok(rect.cacheProperties.indexOf('rx') > -1, 'rx is in cacheProperties array');
ok(rect.cacheProperties.indexOf('ry') > -1, 'ry is in cacheProperties array');
});

test('toObject', function() {
var rect = new fabric.Rect();
ok(typeof rect.toObject == 'function');
Expand Down

0 comments on commit c145ac2

Please sign in to comment.