New anchorCornerRadius for Konva.Transformer

This commit is contained in:
Anton Lavrenov
2018-10-18 12:00:01 -05:00
parent a1876a367e
commit 298a563b8a
4 changed files with 59 additions and 7 deletions

View File

@@ -12,7 +12,8 @@
'borderStrokeWidthChange',
'anchorStrokeChange',
'anchorStrokeWidthChange',
'anchorFillChange'
'anchorFillChange',
'anchorCornerRadiusChange'
].join(' ');
var NODE_RECT = 'nodeRect';
@@ -123,6 +124,7 @@
* @param {Array} [config.borderDash] Array for border dash.
* @param {String} [config.anchorFill] Anchor fill color
* @param {String} [config.anchorStroke] Anchor stroke color
* @param {String} [config.anchorCornerRadius] Anchor corner radius
* @param {Number} [config.anchorStrokeWidth] Anchor stroke size
* @param {Number} [config.anchorSize] Default is 10
* @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
@@ -712,7 +714,8 @@
offsetY: anchorSize / 2,
stroke: this.getAnchorStroke(),
strokeWidth: this.getAnchorStrokeWidth(),
fill: this.getAnchorFill()
fill: this.getAnchorFill(),
cornerRadius: this.getAnchorCornerRadius()
});
this.findOne('.top-left').setAttrs({
@@ -1026,6 +1029,27 @@
*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'anchorFill', 'white');
/**
* get/set anchor corner radius
* @name anchorCornerRadius
* @method
* @memberof Konva.Transformer.prototype
* @param {Number} enabled
* @returns {Number}
* @example
* // get
* var anchorCornerRadius = transformer.anchorCornerRadius();
*
* // set
* transformer.anchorCornerRadius(3);
*/
Konva.Factory.addGetterSetter(
Konva.Transformer,
'anchorCornerRadius',
0,
Konva.Validators.getNumberValidator()
);
/**
* get/set border stroke color
* @name borderStroke