mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
Fix invisibility of objects with no widht/height but strokewidth (#5382)
* added test * fixed ellipse test * fixed ellipse lint
This commit is contained in:
parent
3af833930f
commit
cdb6b51385
3 changed files with 20 additions and 8 deletions
|
|
@ -1031,7 +1031,9 @@
|
|||
* @return {Boolean}
|
||||
*/
|
||||
isNotVisible: function() {
|
||||
return this.opacity === 0 || (this.width === 0 && this.height === 0) || !this.visible;
|
||||
return this.opacity === 0 ||
|
||||
(this.width === 0 && this.height === 0 && this.strokeWidth === 0) ||
|
||||
!this.visible;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -83,18 +83,16 @@
|
|||
assert.deepEqual(ellipse.getRx(), ellipse.rx * ellipse.scaleX);
|
||||
});
|
||||
|
||||
QUnit.test('render', function(assert) {
|
||||
QUnit.test('isNotVisible', function(assert) {
|
||||
var ellipse = new fabric.Ellipse();
|
||||
ellipse.set('rx', 0).set('ry', 0);
|
||||
|
||||
var wasRenderCalled = false;
|
||||
assert.equal(ellipse.isNotVisible(), false, 'isNotVisible false when rx/ry are 0 because strokeWidth is > 0');
|
||||
|
||||
ellipse._render = function(){
|
||||
wasRenderCalled = true;
|
||||
};
|
||||
ellipse.render({});
|
||||
ellipse.set('strokeWidth', 0);
|
||||
|
||||
assert.equal(ellipse.isNotVisible(), true, 'should not render anymore with also strokeWidth 0');
|
||||
|
||||
assert.equal(wasRenderCalled, false, 'should not render when rx/ry are 0');
|
||||
});
|
||||
|
||||
QUnit.test('toSVG', function(assert) {
|
||||
|
|
|
|||
|
|
@ -1249,4 +1249,16 @@
|
|||
object._set('fill', 'blue');
|
||||
assert.equal(object.dirty, false, 'dirty is not rised');
|
||||
});
|
||||
QUnit.test('isNotVisible', function(assert) {
|
||||
var object = new fabric.Object({ fill: 'blue', width: 100, height: 100 });
|
||||
assert.equal(object.isNotVisible(), false, 'object is default visilbe');
|
||||
object = new fabric.Object({ fill: 'blue', width: 0, height: 0, strokeWidth: 1 });
|
||||
assert.equal(object.isNotVisible(), false, 'object is visilbe with width and height equal 0, but strokeWidth 1');
|
||||
object = new fabric.Object({ opacity: 0, fill: 'blue' });
|
||||
assert.equal(object.isNotVisible(), true, 'object is not visilbe with opacity 0');
|
||||
object = new fabric.Object({ fill: 'blue', visible: false });
|
||||
assert.equal(object.isNotVisible(), true, 'object is not visilbe with visible false');
|
||||
object = new fabric.Object({ fill: 'blue', width: 0, height: 0, strokeWidth: 0 });
|
||||
assert.equal(object.isNotVisible(), true, 'object is not visilbe with also strokeWidth equal 0');
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue