mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-16 12:20:59 +00:00
fixed dirty (#3782)
This commit is contained in:
parent
e5b5e92530
commit
c145ac26f2
4 changed files with 26 additions and 5 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -50,11 +53,7 @@
|
|||
*/
|
||||
ry: 0,
|
||||
|
||||
/**
|
||||
* Used to specify dash pattern for stroke on this object
|
||||
* @type Array
|
||||
*/
|
||||
strokeDashArray: null,
|
||||
cacheProperties: cacheProperties,
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue