typescript and docs fixes

This commit is contained in:
Anton Lavrenov 2018-06-15 14:50:36 +07:00
parent 4415b4be32
commit 7400977f50
4 changed files with 124 additions and 62 deletions

View File

@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [new version][unreleased] ## [new version][unreleased]
## Fixed
* Typescript fixes
## [2.1.4][2018-06-15] ## [2.1.4][2018-06-15]
## Fixed ## Fixed

2
konva.d.ts vendored
View File

@ -834,6 +834,7 @@ declare namespace Konva {
closed?: boolean; closed?: boolean;
pointerLength?: number; pointerLength?: number;
pointerWidth?: number; pointerWidth?: number;
pointerAtBeginning?: boolean;
} }
class Arrow extends Shape { class Arrow extends Shape {
@ -1059,6 +1060,7 @@ declare namespace Konva {
keepRatio?: boolean; keepRatio?: boolean;
enabledHandlers?: Array<string>; enabledHandlers?: Array<string>;
node?: Rect; node?: Rect;
boundBoxFunc?: (oldBox: SizeConfig, newBox: SizeConfig) => SizeConfig;
} }
class Transformer extends Container { class Transformer extends Container {

View File

@ -18808,6 +18808,7 @@
* @param {Number} [config.lineEnabled] Should we draw border? Default is true * @param {Number} [config.lineEnabled] Should we draw border? Default is true
* @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true * @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
* @param {Array} [config.enabledHandlers] Array of names of enabled handles * @param {Array} [config.enabledHandlers] Array of names of enabled handles
* @param {Function} [config.boundBoxFunc] Bounding box function
* @example * @example
* var transformer = new Konva.Transformer({ * var transformer = new Konva.Transformer({
* node: rectangle, * node: rectangle,
@ -18862,18 +18863,26 @@
} }
}, },
attachTo: function(node) {
this.setNode(node);
},
/** /**
* attach transformer to a Konva.Node. Transformer will adapt it its size and listed events * alias to `setNode`
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @returns {Konva.Transformer} * @returns {Konva.Transformer}
* @example * @example
* transformer.attachTo(shape); * transformer.attachTo(shape);
*/ */
attachTo: function(node) {
this.setNode(node);
},
/**
* attach transformer to a Konva.Node. Transformer will adapt to its size and listen its events
* @method
* @memberof Konva.Transformer.prototype
* @returns {Konva.Transformer}
* @example
* transformer.setNode(shape);
*/
setNode: function(node) { setNode: function(node) {
if (this._node) { if (this._node) {
this.detach(); this.detach();
@ -19463,10 +19472,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get list of handlers * // get list of handlers
* var enabledHandlers = shape.enabledHandlers(); * var enabledHandlers = transformer.enabledHandlers();
* *
* // set handlers * // set handlers
* shape.enabledHandlers(['top-left', 'top-center', 'top-right', 'middle-right', 'middle-left', 'bottom-left', 'bottom-center', 'bottom-right']); * transformer.enabledHandlers(['top-left', 'top-center', 'top-right', 'middle-right', 'middle-left', 'bottom-left', 'bottom-center', 'bottom-right']);
*/ */
Konva.Factory.addGetterSetter( Konva.Factory.addGetterSetter(
Konva.Transformer, Konva.Transformer,
@ -19484,10 +19493,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get * // get
* var resizeEnabled = shape.resizeEnabled(); * var resizeEnabled = transformer.resizeEnabled();
* *
* // set * // set
* shape.resizeEnabled(false); * transformer.resizeEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'resizeEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'resizeEnabled', true);
@ -19496,14 +19505,14 @@
* @name rotateEnabled * @name rotateEnabled
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} enabled
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var rotateEnabled = shape.rotateEnabled(); * var rotateEnabled = transformer.rotateEnabled();
* *
* // set * // set
* shape.rotateEnabled(false); * transformer.rotateEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateEnabled', true);
@ -19516,10 +19525,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get * // get
* var rotationSnaps = shape.rotationSnaps(); * var rotationSnaps = transformer.rotationSnaps();
* *
* // set * // set
* shape.rotationSnaps([0, 90, 180, 270]); * transformer.rotationSnaps([0, 90, 180, 270]);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotationSnaps', []); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotationSnaps', []);
@ -19528,14 +19537,14 @@
* @name rotateHandlerOffset * @name rotateHandlerOffset
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Number} offset
* @returns {Array} * @returns {Number}
* @example * @example
* // get * // get
* var rotateHandlerOffset = shape.rotateHandlerOffset(); * var rotateHandlerOffset = transformer.rotateHandlerOffset();
* *
* // set * // set
* shape.rotateHandlerOffset(100); * transformer.rotateHandlerOffset(100);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateHandlerOffset', 50); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateHandlerOffset', 50);
@ -19544,14 +19553,14 @@
* @name lineEnabled * @name lineEnabled
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} enabled
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var lineEnabled = shape.lineEnabled(); * var lineEnabled = transformer.lineEnabled();
* *
* // set * // set
* shape.lineEnabled(false); * transformer.lineEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'lineEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'lineEnabled', true);
@ -19560,14 +19569,14 @@
* @name keepRatio * @name keepRatio
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} keepRatio
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var keepRatio = shape.keepRatio(); * var keepRatio = transformer.keepRatio();
* *
* // set * // set
* shape.keepRatio(false); * transformer.keepRatio(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'keepRatio', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'keepRatio', true);
@ -19576,19 +19585,38 @@
* @name padding * @name padding
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Number} padding
* @returns {Array} * @returns {Number}
* @example * @example
* // get * // get
* var padding = shape.padding(); * var padding = transformer.padding();
* *
* // set * // set
* shape.padding(10); * transformer.padding(10);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'padding', 0); Konva.Factory.addGetterSetter(Konva.Transformer, 'padding', 0);
Konva.Factory.addOverloadedGetterSetter(Konva.Transformer, 'node'); Konva.Factory.addOverloadedGetterSetter(Konva.Transformer, 'node');
/**
* get/set bounding box function
* @name boundBoxFunc
* @method
* @memberof Konva.Transformer.prototype
* @param {Function} func
* @returns {Function}
* @example
* // get
* var boundBoxFunc = transformer.boundBoxFunc();
*
* // set
* transformer.boundBoxFunc(function(oldBox, newBox) {
* if (newBox.width > 200) {
* return oldBox;
* }
* return newBox;
* });
*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'boundBoxFunc'); Konva.Factory.addGetterSetter(Konva.Transformer, 'boundBoxFunc');
Konva.Collection.mapMethods(Konva.Transformer); Konva.Collection.mapMethods(Konva.Transformer);

View File

@ -105,6 +105,7 @@
* @param {Number} [config.lineEnabled] Should we draw border? Default is true * @param {Number} [config.lineEnabled] Should we draw border? Default is true
* @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true * @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
* @param {Array} [config.enabledHandlers] Array of names of enabled handles * @param {Array} [config.enabledHandlers] Array of names of enabled handles
* @param {Function} [config.boundBoxFunc] Bounding box function
* @example * @example
* var transformer = new Konva.Transformer({ * var transformer = new Konva.Transformer({
* node: rectangle, * node: rectangle,
@ -159,18 +160,26 @@
} }
}, },
attachTo: function(node) {
this.setNode(node);
},
/** /**
* attach transformer to a Konva.Node. Transformer will adapt it its size and listed events * alias to `setNode`
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @returns {Konva.Transformer} * @returns {Konva.Transformer}
* @example * @example
* transformer.attachTo(shape); * transformer.attachTo(shape);
*/ */
attachTo: function(node) {
this.setNode(node);
},
/**
* attach transformer to a Konva.Node. Transformer will adapt to its size and listen its events
* @method
* @memberof Konva.Transformer.prototype
* @returns {Konva.Transformer}
* @example
* transformer.setNode(shape);
*/
setNode: function(node) { setNode: function(node) {
if (this._node) { if (this._node) {
this.detach(); this.detach();
@ -760,10 +769,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get list of handlers * // get list of handlers
* var enabledHandlers = shape.enabledHandlers(); * var enabledHandlers = transformer.enabledHandlers();
* *
* // set handlers * // set handlers
* shape.enabledHandlers(['top-left', 'top-center', 'top-right', 'middle-right', 'middle-left', 'bottom-left', 'bottom-center', 'bottom-right']); * transformer.enabledHandlers(['top-left', 'top-center', 'top-right', 'middle-right', 'middle-left', 'bottom-left', 'bottom-center', 'bottom-right']);
*/ */
Konva.Factory.addGetterSetter( Konva.Factory.addGetterSetter(
Konva.Transformer, Konva.Transformer,
@ -781,10 +790,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get * // get
* var resizeEnabled = shape.resizeEnabled(); * var resizeEnabled = transformer.resizeEnabled();
* *
* // set * // set
* shape.resizeEnabled(false); * transformer.resizeEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'resizeEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'resizeEnabled', true);
@ -793,14 +802,14 @@
* @name rotateEnabled * @name rotateEnabled
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} enabled
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var rotateEnabled = shape.rotateEnabled(); * var rotateEnabled = transformer.rotateEnabled();
* *
* // set * // set
* shape.rotateEnabled(false); * transformer.rotateEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateEnabled', true);
@ -813,10 +822,10 @@
* @returns {Array} * @returns {Array}
* @example * @example
* // get * // get
* var rotationSnaps = shape.rotationSnaps(); * var rotationSnaps = transformer.rotationSnaps();
* *
* // set * // set
* shape.rotationSnaps([0, 90, 180, 270]); * transformer.rotationSnaps([0, 90, 180, 270]);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotationSnaps', []); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotationSnaps', []);
@ -825,14 +834,14 @@
* @name rotateHandlerOffset * @name rotateHandlerOffset
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Number} offset
* @returns {Array} * @returns {Number}
* @example * @example
* // get * // get
* var rotateHandlerOffset = shape.rotateHandlerOffset(); * var rotateHandlerOffset = transformer.rotateHandlerOffset();
* *
* // set * // set
* shape.rotateHandlerOffset(100); * transformer.rotateHandlerOffset(100);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateHandlerOffset', 50); Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateHandlerOffset', 50);
@ -841,14 +850,14 @@
* @name lineEnabled * @name lineEnabled
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} enabled
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var lineEnabled = shape.lineEnabled(); * var lineEnabled = transformer.lineEnabled();
* *
* // set * // set
* shape.lineEnabled(false); * transformer.lineEnabled(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'lineEnabled', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'lineEnabled', true);
@ -857,14 +866,14 @@
* @name keepRatio * @name keepRatio
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Boolean} keepRatio
* @returns {Array} * @returns {Boolean}
* @example * @example
* // get * // get
* var keepRatio = shape.keepRatio(); * var keepRatio = transformer.keepRatio();
* *
* // set * // set
* shape.keepRatio(false); * transformer.keepRatio(false);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'keepRatio', true); Konva.Factory.addGetterSetter(Konva.Transformer, 'keepRatio', true);
@ -873,19 +882,38 @@
* @name padding * @name padding
* @method * @method
* @memberof Konva.Transformer.prototype * @memberof Konva.Transformer.prototype
* @param {Array} array * @param {Number} padding
* @returns {Array} * @returns {Number}
* @example * @example
* // get * // get
* var padding = shape.padding(); * var padding = transformer.padding();
* *
* // set * // set
* shape.padding(10); * transformer.padding(10);
*/ */
Konva.Factory.addGetterSetter(Konva.Transformer, 'padding', 0); Konva.Factory.addGetterSetter(Konva.Transformer, 'padding', 0);
Konva.Factory.addOverloadedGetterSetter(Konva.Transformer, 'node'); Konva.Factory.addOverloadedGetterSetter(Konva.Transformer, 'node');
/**
* get/set bounding box function
* @name boundBoxFunc
* @method
* @memberof Konva.Transformer.prototype
* @param {Function} func
* @returns {Function}
* @example
* // get
* var boundBoxFunc = transformer.boundBoxFunc();
*
* // set
* transformer.boundBoxFunc(function(oldBox, newBox) {
* if (newBox.width > 200) {
* return oldBox;
* }
* return newBox;
* });
*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'boundBoxFunc'); Konva.Factory.addGetterSetter(Konva.Transformer, 'boundBoxFunc');
Konva.Collection.mapMethods(Konva.Transformer); Konva.Collection.mapMethods(Konva.Transformer);