mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
new flipEnabled
property for Konva.Transformer
. close #954
This commit is contained in:
parent
386287eebe
commit
dbe88946ed
@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Fix `a` command parsing for `Konva.Path`
|
- Fix `a` command parsing for `Konva.Path`
|
||||||
- Fix fill pattern for `Konva.Text` when the pattern has an offset or rotation
|
- Fix fill pattern for `Konva.Text` when the pattern has an offset or rotation
|
||||||
- `Konva.names` and `Konva.ids` are removed
|
- `Konva.names` and `Konva.ids` are removed
|
||||||
|
- new `flipEnabled` property for `Konva.Transformer`.
|
||||||
|
|
||||||
## 7.2.5
|
## 7.2.5
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { Rect } from './Rect';
|
|||||||
import { Group } from '../Group';
|
import { Group } from '../Group';
|
||||||
import { ContainerConfig } from '../Container';
|
import { ContainerConfig } from '../Container';
|
||||||
import { Konva } from '../Global';
|
import { Konva } from '../Global';
|
||||||
import { getNumberValidator } from '../Validators';
|
import { getBooleanValidator, getNumberValidator } from '../Validators';
|
||||||
import { _registerNode } from '../Global';
|
import { _registerNode } from '../Global';
|
||||||
|
|
||||||
import { GetSet, IRect, Vector2d } from '../types';
|
import { GetSet, IRect, Vector2d } from '../types';
|
||||||
@ -33,6 +33,7 @@ export interface TransformerConfig extends ContainerConfig {
|
|||||||
keepRatio?: boolean;
|
keepRatio?: boolean;
|
||||||
centeredScaling?: boolean;
|
centeredScaling?: boolean;
|
||||||
enabledAnchors?: Array<string>;
|
enabledAnchors?: Array<string>;
|
||||||
|
flipEnabled?: boolean;
|
||||||
node?: Rect;
|
node?: Rect;
|
||||||
ignoreStroke?: boolean;
|
ignoreStroke?: boolean;
|
||||||
boundBoxFunc?: (oldBox: Box, newBox: Box) => Box;
|
boundBoxFunc?: (oldBox: Box, newBox: Box) => Box;
|
||||||
@ -217,6 +218,7 @@ function getSnap(snaps: Array<number>, newRotationRad: number, tol: number) {
|
|||||||
* @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
|
||||||
* @param {Boolean} [config.centeredScaling] Should we resize relative to node's center? Default is false
|
* @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 {Array} [config.enabledAnchors] Array of names of enabled handles
|
||||||
|
* @param {Boolean} [config.flipEnabled] Can we flip/mirror shape on transform?. True by default
|
||||||
* @param {Function} [config.boundBoxFunc] Bounding box function
|
* @param {Function} [config.boundBoxFunc] Bounding box function
|
||||||
* @param {Function} [config.ignoreStroke] Should we ignore stroke size? Default is false
|
* @param {Function} [config.ignoreStroke] Should we ignore stroke size? Default is false
|
||||||
*
|
*
|
||||||
@ -909,7 +911,7 @@ export class Transformer extends Group {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const allowNegativeScale = true;
|
const allowNegativeScale = this.flipEnabled();
|
||||||
var t = new Transform();
|
var t = new Transform();
|
||||||
t.rotate(Konva.getAngle(this.rotation()));
|
t.rotate(Konva.getAngle(this.rotation()));
|
||||||
if (
|
if (
|
||||||
@ -1219,6 +1221,7 @@ export class Transformer extends Group {
|
|||||||
anchorStrokeWidth: GetSet<number, this>;
|
anchorStrokeWidth: GetSet<number, this>;
|
||||||
keepRatio: GetSet<boolean, this>;
|
keepRatio: GetSet<boolean, this>;
|
||||||
centeredScaling: GetSet<boolean, this>;
|
centeredScaling: GetSet<boolean, this>;
|
||||||
|
flipEnabled: GetSet<boolean, this>;
|
||||||
ignoreStroke: GetSet<boolean, this>;
|
ignoreStroke: GetSet<boolean, this>;
|
||||||
boundBoxFunc: GetSet<(oldBox: Box, newBox: Box) => Box, this>;
|
boundBoxFunc: GetSet<(oldBox: Box, newBox: Box) => Box, this>;
|
||||||
shouldOverdrawWholeArea: GetSet<boolean, this>;
|
shouldOverdrawWholeArea: GetSet<boolean, this>;
|
||||||
@ -1266,6 +1269,26 @@ Factory.addGetterSetter(
|
|||||||
validateAnchors
|
validateAnchors
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get/set flip enabled
|
||||||
|
* @name Konva.Transformer#flipEnabled
|
||||||
|
* @method
|
||||||
|
* @param {Boolean} flag
|
||||||
|
* @returns {Boolean}
|
||||||
|
* @example
|
||||||
|
* // get flip enabled property
|
||||||
|
* var flipEnabled = transformer.flipEnabled();
|
||||||
|
*
|
||||||
|
* // set handlers
|
||||||
|
* transformer.flipEnabled(false);
|
||||||
|
*/
|
||||||
|
Factory.addGetterSetter(
|
||||||
|
Transformer,
|
||||||
|
'flipEnabled',
|
||||||
|
true,
|
||||||
|
getBooleanValidator()
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get/set resize ability. If false it will automatically hide resizing handlers
|
* get/set resize ability. If false it will automatically hide resizing handlers
|
||||||
* @name Konva.Transformer#resizeEnabled
|
* @name Konva.Transformer#resizeEnabled
|
||||||
|
@ -3578,7 +3578,7 @@ describe('Transformer', function () {
|
|||||||
y: 15,
|
y: 15,
|
||||||
text: 'Simple Text',
|
text: 'Simple Text',
|
||||||
fontSize: 60,
|
fontSize: 60,
|
||||||
fontFamily: 'Calibri',
|
fontFamily: 'Arial',
|
||||||
fill: 'green',
|
fill: 'green',
|
||||||
});
|
});
|
||||||
layer.add(shape);
|
layer.add(shape);
|
||||||
|
Loading…
Reference in New Issue
Block a user