fix cursor on anchors for rotated parent. fix#837

This commit is contained in:
Anton Lavrenov
2020-01-30 11:41:05 -05:00
parent e112c14852
commit 1c85a7ee26
7 changed files with 1407 additions and 53 deletions

View File

@@ -13,7 +13,6 @@ import {
import { Stage } from './Stage';
import { Context } from './Context';
import { Shape } from './Shape';
import { Layer } from './Layer';
import { BaseLayer } from './BaseLayer';
export const ids: any = {};
@@ -1756,6 +1755,26 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
y: scaleY
};
}
/**
* get absolute rotation of the node which takes into
* account its ancestor rotations
* @method
* @name Konva.Node#getAbsoluteRotation
* @returns {Number}
* @example
* // get absolute scale x
* var rotation = node.getAbsoluteRotation();
*/
getAbsoluteRotation() {
var parent: Node = this;
var rotation = 0;
while (parent) {
rotation += parent.rotation();
parent = parent.getParent();
}
return rotation;
}
/**
* get transform of the node
* @method

View File

@@ -360,7 +360,7 @@ export class Transformer extends Group {
// add hover styling
anchor.on('mouseenter', () => {
var rad = Konva.getAngle(this.rotation());
var rad = Konva.getAngle(this.getAbsoluteRotation());
var scale = this.getNode().getAbsoluteScale();
// If scale.y < 0 xor scale.x < 0 we need to flip (not rotate).