Fix transformer rotation when parent of a node is rotated too

This commit is contained in:
Anton Lavrenov
2021-02-12 16:44:00 -05:00
parent 550d0176cd
commit 24d069212c
7 changed files with 95 additions and 17 deletions

View File

@@ -28,9 +28,9 @@ export interface ContainerConfig extends NodeConfig {
* @@nodeParams
* @@containerParams
*/
export abstract class Container<ChildType extends Node> extends Node<
ContainerConfig
> {
export abstract class Container<
ChildType extends Node
> extends Node<ContainerConfig> {
children = new Collection<ChildType>();
/**
@@ -154,7 +154,7 @@ export abstract class Container<ChildType extends Node> extends Node<
* You can provide a string with '#' for id selections and '.' for name selections.
* Or a function that will return true/false when a node is passed through. See example below.
* With strings you can also select by type or class name. Pass multiple selectors
* separated by a space.
* separated by a comma.
* @method
* @name Konva.Container#find
* @param {String | Function} selector

View File

@@ -2809,7 +2809,7 @@ addGetterSetter(Node, 'opacity', 1, getNumberValidator());
addGetterSetter(Node, 'name', '', getStringValidator());
/**
* get/set name
* get/set name.
* @name Konva.Node#name
* @method
* @param {String} name

View File

@@ -283,7 +283,7 @@ export class Transformer extends Group {
}
this._nodes = nodes;
if (nodes.length === 1) {
this.rotation(nodes[0].rotation());
this.rotation(nodes[0].getAbsoluteRotation());
} else {
this.rotation(0);
}
@@ -295,7 +295,7 @@ export class Transformer extends Group {
const onChange = () => {
//
if (this.nodes().length === 1) {
this.rotation(this.nodes()[0].rotation());
this.rotation(this.nodes()[0].getAbsoluteRotation());
}
this._resetTransformCache();
@@ -524,7 +524,7 @@ export class Transformer extends Group {
name: name + ' _anchor',
dragDistance: 0,
// make it draggable,
// so activating the anchror will not start drag&drop of any parent
// so activating the anchor will not start drag&drop of any parent
draggable: true,
hitStrokeWidth: TOUCH_DEVICE ? 10 : 'auto',
});