mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
new centeredScaling
for Konva.Transformer
This commit is contained in:
@@ -125,6 +125,7 @@
|
||||
* @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
|
||||
* @param {Boolean} [config.centeredScaling] Should we resize relative to node's center? Default is false
|
||||
* @param {Array} [config.enabledAnchors] Array of names of enabled handles
|
||||
* @param {Function} [config.boundBoxFunc] Bounding box function
|
||||
* @example
|
||||
@@ -575,7 +576,8 @@
|
||||
this.getParent()
|
||||
);
|
||||
|
||||
if (e.altKey) {
|
||||
var centeredScaling = this.getCenteredScaling() || e.altKey;
|
||||
if (centeredScaling) {
|
||||
var topLeft = this.findOne('.top-left');
|
||||
var bottomRight = this.findOne('.bottom-right');
|
||||
var topOffsetX = topLeft.x();
|
||||
@@ -1088,6 +1090,22 @@
|
||||
*/
|
||||
Konva.Factory.addGetterSetter(Konva.Transformer, 'keepRatio', true);
|
||||
|
||||
/**
|
||||
* get/set should we resize relative to node's center?
|
||||
* @name centeredScaling
|
||||
* @method
|
||||
* @memberof Konva.Transformer.prototype
|
||||
* @param {Boolean} centeredScaling
|
||||
* @returns {Boolean}
|
||||
* @example
|
||||
* // get
|
||||
* var centeredScaling = transformer.centeredScaling();
|
||||
*
|
||||
* // set
|
||||
* transformer.centeredScaling(true);
|
||||
*/
|
||||
Konva.Factory.addGetterSetter(Konva.Transformer, 'centeredScaling', false);
|
||||
|
||||
/**
|
||||
* get/set padding
|
||||
* @name padding
|
||||
|
Reference in New Issue
Block a user