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

@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [new version][unreleased] ## [new version][unreleased]
### Added
* New `anchorCornerRadius` for `Konva.Transformer`
### Fixed ### Fixed
* Performance fixes for caching * Performance fixes for caching

View File

@@ -2,7 +2,7 @@
* Konva JavaScript Framework v2.4.2 * Konva JavaScript Framework v2.4.2
* http://konvajs.github.io/ * http://konvajs.github.io/
* Licensed under the MIT * Licensed under the MIT
* Date: Mon Oct 15 2018 * Date: Thu Oct 18 2018
* *
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -19477,7 +19477,8 @@
'borderStrokeWidthChange', 'borderStrokeWidthChange',
'anchorStrokeChange', 'anchorStrokeChange',
'anchorStrokeWidthChange', 'anchorStrokeWidthChange',
'anchorFillChange' 'anchorFillChange',
'anchorCornerRadiusChange'
].join(' '); ].join(' ');
var NODE_RECT = 'nodeRect'; var NODE_RECT = 'nodeRect';
@@ -19588,6 +19589,7 @@
* @param {Array} [config.borderDash] Array for border dash. * @param {Array} [config.borderDash] Array for border dash.
* @param {String} [config.anchorFill] Anchor fill color * @param {String} [config.anchorFill] Anchor fill color
* @param {String} [config.anchorStroke] Anchor stroke 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.anchorStrokeWidth] Anchor stroke size
* @param {Number} [config.anchorSize] Default is 10 * @param {Number} [config.anchorSize] Default is 10
* @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true * @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
@@ -20177,7 +20179,8 @@
offsetY: anchorSize / 2, offsetY: anchorSize / 2,
stroke: this.getAnchorStroke(), stroke: this.getAnchorStroke(),
strokeWidth: this.getAnchorStrokeWidth(), strokeWidth: this.getAnchorStrokeWidth(),
fill: this.getAnchorFill() fill: this.getAnchorFill(),
cornerRadius: this.getAnchorCornerRadius()
}); });
this.findOne('.top-left').setAttrs({ this.findOne('.top-left').setAttrs({
@@ -20491,6 +20494,27 @@
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'anchorFill', 'white'); 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 * get/set border stroke color
* @name borderStroke * @name borderStroke

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

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