mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-29 09:44:41 +00:00
Merge pull request #818 from Kienz/patch-1
Fix `fabric.Circle.set` for radius
This commit is contained in:
commit
5f86b84b87
2 changed files with 22 additions and 2 deletions
|
|
@ -35,9 +35,22 @@
|
|||
|
||||
this.set('radius', options.radius || 0);
|
||||
this.callSuper('initialize', options);
|
||||
},
|
||||
|
||||
var diameter = this.get('radius') * 2;
|
||||
this.set('width', diameter).set('height', diameter);
|
||||
/**
|
||||
* @private
|
||||
* @param {String} key
|
||||
* @param {Any} value
|
||||
* @return {fabric.Circle} thisArg
|
||||
*/
|
||||
_set: function(key, value) {
|
||||
this.callSuper('_set', key, value);
|
||||
|
||||
if (key === 'radius') {
|
||||
this.setRadius(value);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,6 +42,13 @@
|
|||
var circle = new fabric.Circle({ radius: 10 });
|
||||
|
||||
ok(typeof circle.setRadius == 'function');
|
||||
|
||||
equal(circle.getRadiusX(), 10);
|
||||
equal(circle.getRadiusY(), 10);
|
||||
|
||||
equal(circle.getWidth(), 20);
|
||||
equal(circle.getHeight(), 20);
|
||||
|
||||
circle.setRadius(20);
|
||||
|
||||
equal(circle.getRadiusX(), 20);
|
||||
|
|
|
|||
Loading…
Reference in a new issue