docs and types

This commit is contained in:
Anton Lavrenov
2021-01-26 11:43:52 -05:00
parent 76476a5d77
commit febf3251eb
6 changed files with 76 additions and 2 deletions

View File

@@ -1183,6 +1183,21 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
y: this.y(),
};
}
/**
* get absolute position of a node. That function can be used to calculate absolute position, but relative to any ancestor
* @method
* @name Konva.Node#getAbsolutePosition
* @param {Object} Ancestor optional ancestor node
* @returns {Konva.Node}
* @example
*
* // returns absolute position relative to top-left corner of canvas
* node.getAbsolutePosition();
*
* // calculate absolute position of node, inside stage
* // so stage transforms are ignored
* node.getAbsolutePosition(stage)
*/
getAbsolutePosition(top?) {
let haveCachedParent = false;
let parent = this.parent;

View File

@@ -599,7 +599,9 @@ export const Util = {
},
_sign(number: number) {
if (number === 0) {
return 0;
// that is not what sign usually returns
// but that is what we need
return 1;
}
if (number > 0) {
return 1;

View File

@@ -31,6 +31,7 @@ export interface TextConfig extends ShapeConfig {
verticalAlign?: string;
padding?: number;
lineHeight?: number;
letterSpacing?: number;
wrap?: string;
ellipsis?: boolean;
}

View File

@@ -29,6 +29,7 @@ export interface TransformerConfig extends ContainerConfig {
anchorStroke?: string;
anchorStrokeWidth?: number;
anchorSize?: number;
anchorCornerRadius?: number;
keepRatio?: boolean;
centeredScaling?: boolean;
enabledAnchors?: Array<string>;