mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
fix cursor on anchors for rotated parent. fix#837
This commit is contained in:
21
src/Node.ts
21
src/Node.ts
@@ -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
|
||||
|
@@ -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).
|
||||
|
Reference in New Issue
Block a user