Skip to content

Commit

Permalink
feat: add flag for link line visiable for Transformer's rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
liulinboyi committed Dec 19, 2023
1 parent f7c8b81 commit 8a05f34
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/shapes/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Box extends IRect {
export interface TransformerConfig extends ContainerConfig {
resizeEnabled?: boolean;
rotateEnabled?: boolean;
rotateLinkLineVisiable?: boolean;
rotationSnaps?: Array<number>;
rotationSnapTolerance?: number;
rotateAnchorOffset?: number;
Expand Down Expand Up @@ -205,6 +206,7 @@ function getSnap(snaps: Array<number>, newRotationRad: number, tol: number) {
* @param {Object} config
* @param {Boolean} [config.resizeEnabled] Default is true
* @param {Boolean} [config.rotateEnabled] Default is true
* @param {Boolean} [config.rotateLinkLineVisiable] Default is true
* @param {Array} [config.rotationSnaps] Array of angles for rotation snaps. Default is []
* @param {Number} [config.rotationSnapTolerance] Snapping tolerance. If closer than this it will snap. Default is 5
* @param {Number} [config.rotateAnchorOffset] Default is 50
Expand Down Expand Up @@ -614,7 +616,7 @@ export class Transformer extends Group {
shape.height() + padding * 2
);
ctx.moveTo(shape.width() / 2, -padding);
if (tr.rotateEnabled()) {
if (tr.rotateEnabled() && tr.rotateLinkLineVisiable()) {
ctx.lineTo(
shape.width() / 2,
-tr.rotateAnchorOffset() * Util._sign(shape.height()) - padding
Expand Down Expand Up @@ -1289,6 +1291,7 @@ export class Transformer extends Group {
anchorSize: GetSet<number, this>;
resizeEnabled: GetSet<boolean, this>;
rotateEnabled: GetSet<boolean, this>;
rotateLinkLineVisiable: GetSet<boolean, this>;
rotateAnchorOffset: GetSet<number, this>;
rotationSnapTolerance: GetSet<number, this>;
rotateAnchorCursor: GetSet<string, this>;
Expand Down Expand Up @@ -1422,6 +1425,21 @@ Factory.addGetterSetter(Transformer, 'anchorSize', 10, getNumberValidator());
*/
Factory.addGetterSetter(Transformer, 'rotateEnabled', true);

/**
* get/set visiable to rotate link line.
* @name Konva.Transformer#rotateLinkLineVisiable
* @method
* @param {Boolean} enabled
* @returns {Boolean}
* @example
* // get
* var rotateLinkLineVisiable = transformer.rotateLinkLineVisiable();
*
* // set
* transformer.rotateLinkLineVisiable(false);
*/
Factory.addGetterSetter(Transformer, 'rotateLinkLineVisiable', true);

/**
* get/set rotation snaps angles.
* @name Konva.Transformer#rotationSnaps
Expand Down

0 comments on commit 8a05f34

Please sign in to comment.