Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

konva

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

konva - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

8

CHANGELOG.md

@@ -8,2 +8,10 @@ # Change Log

## [2.2.2][2018-08-21]
### Changed
* Default duration for tweens and `node.to()` methods is now 300ms
* Typescript fixes
* Automatic validations for many attributes
## [2.2.1][2018-08-10]

@@ -10,0 +18,0 @@

151

konva.d.ts

@@ -9,3 +9,8 @@ declare namespace Konva {

type HandlerFunc = (
e: { target: Konva.Shape; evt: Event; currentTarget: Konva.Node; cancelBubble: boolean }
e: {
target: Konva.Shape;
evt: Event;
currentTarget: Konva.Node;
cancelBubble: boolean;
}
) => void;

@@ -32,3 +37,3 @@

dragmove = 'dragmove',
dragend = 'dragend',
dragend = 'dragend'
}

@@ -50,3 +55,3 @@

contentTap = 'contentTap',
contentDblTap = 'contentDblTap',
contentDblTap = 'contentDblTap'
}

@@ -145,44 +150,44 @@

}
interface KonvaNodeEventMap extends KonvaStageEventMap {
'mouseover': MouseEvent,
'mouseout': MouseEvent,
'mousemove': MouseEvent,
'mouseleave': MouseEvent,
'mouseenter': MouseEvent,
'mousedown': MouseEvent,
'mouseup': MouseEvent,
'wheel': WheelEvent,
'contextmenu': PointerEvent,
'click': MouseEvent,
'dblclick': MouseEvent,
'touchstart': TouchEvent,
'touchmove': TouchEvent,
'touchend': TouchEvent,
'tap': Event,
'dbltap': Event,
'dragstart': DragEvent,
'dragmove': DragEvent,
'dragend': DragEvent,
'dragover': DragEvent,
'drop': DragEvent,
mouseover: MouseEvent;
mouseout: MouseEvent;
mousemove: MouseEvent;
mouseleave: MouseEvent;
mouseenter: MouseEvent;
mousedown: MouseEvent;
mouseup: MouseEvent;
wheel: WheelEvent;
contextmenu: PointerEvent;
click: MouseEvent;
dblclick: MouseEvent;
touchstart: TouchEvent;
touchmove: TouchEvent;
touchend: TouchEvent;
tap: Event;
dbltap: Event;
dragstart: DragEvent;
dragmove: DragEvent;
dragend: DragEvent;
dragover: DragEvent;
drop: DragEvent;
}
interface KonvaStageEventMap {
'contentMouseover': MouseEvent,
'contentMousemove': MouseEvent,
'contentMouseout': MouseEvent,
'contentMousedown': MouseEvent,
'contentMouseup': MouseEvent,
'contentWheel': WheelEvent,
'contentContextmenu': PointerEvent,
'contentClick': MouseEvent,
'contentDblclick': MouseEvent,
'contentTouchstart': TouchEvent,
'contentTouchmove': TouchEvent,
'contentTouchend': TouchEvent,
'contentTap': Event,
'contentDblTap': Event,
contentMouseover: MouseEvent;
contentMousemove: MouseEvent;
contentMouseout: MouseEvent;
contentMousedown: MouseEvent;
contentMouseup: MouseEvent;
contentWheel: WheelEvent;
contentContextmenu: PointerEvent;
contentClick: MouseEvent;
contentDblclick: MouseEvent;
contentTouchstart: TouchEvent;
contentTouchmove: TouchEvent;
contentTouchend: TouchEvent;
contentTap: Event;
contentDblTap: Event;
}
interface NodeConfig {

@@ -303,3 +308,6 @@ x?: number;

getClassName(): string;
getClientRect(attrs? : { skipTransform?: boolean, relativeTo?: object }): SizeConfig;
getClientRect(attrs?: {
skipTransform?: boolean;
relativeTo?: object;
}): SizeConfig;
getContent(): HTMLDivElement;

@@ -361,3 +369,13 @@ getDepth(): number;

offsetY(offsetY: number): this;
on<K extends keyof KonvaNodeEventMap>(evtStr: K, handler: (e: { target: Konva.Shape; evt: KonvaNodeEventMap[K]; currentTarget: Konva.Node; cancelBubble: boolean }) => void): this;
on<K extends keyof KonvaNodeEventMap>(
evtStr: K,
handler: (
e: {
target: Konva.Shape;
evt: KonvaNodeEventMap[K];
currentTarget: Konva.Node;
cancelBubble: boolean;
}
) => void
): this;
on(evtStr: KonvaEventString, handler: HandlerFunc): this;

@@ -497,4 +515,4 @@ opacity(): number;

lineCap?: string;
sceneFunc?: (con: Context) => void;
hitFunc?: (con: Context) => void;
sceneFunc?: (con: Context, shape: Shape) => void;
hitFunc?: (con: Context, shape: Shape) => void;
shadowColor?: string;

@@ -586,3 +604,3 @@ shadowBlur?: number;

hitFunc(): Function;
hitFunc(func: Function): this;
hitFunc(func: (con: Context, shape: Shape) => {}): this;
intersects(point: Vector2d): boolean;

@@ -596,3 +614,3 @@ lineCap(): string;

sceneFunc(): Function;
sceneFunc(func: (con: Context) => {}): this;
sceneFunc(func: (con: Context, shape: Shape) => {}): this;
shadowColor(): string;

@@ -1157,6 +1175,13 @@ shadowColor(shadowColor: string): this;

rotationSnaps?: Array<number>;
rotateHandlerOffset?: number;
lineEnabled?: number;
rotateAnchorOffset?: number;
borderEnabled?: number;
borderStroke?: string;
borderStrokeWidth?: number;
borderDash?: Array<number>;
anchorFill?: string;
anchorStroke?: string;
anchorStrokeWidth?: number;
anchorSize?: number;
keepRatio?: boolean;
enabledHandlers?: Array<string>;
enabledAnchors?: Array<string>;
node?: Rect;

@@ -1173,3 +1198,29 @@ boundBoxFunc?: (oldBox: SizeConfig, newBox: SizeConfig) => SizeConfig;

forceUpdate(): void;
update(): void;
resizeEnabled(): boolean;
resizeEnabled(enabled: boolean): this;
rotateEnabled(): boolean;
rotateEnabled(enabled: boolean): this;
rotationSnaps(): Array<number>;
rotationSnaps(snaps: Array<number>): this;
rotateAnchorOffset(): number;
rotateAnchorOffset(offset: number): this;
borderEnabled(): boolean;
borderEnabled(enabled: boolean): this;
borderStroke(): string;
borderStroke(color: string): this;
borderStrokeWidth(): number;
borderStrokeWidth(width: number): this;
borderDash(): Array<number>;
borderDash(snaps: Array<number>): this;
anchorFill(): string;
anchorFill(color: string): this;
anchorStroke(): string;
anchorStroke(color: string): this;
anchorStrokeWidth(): number;
anchorStrokeWidth(width: number): this;
anchorSize(): number;
anchorSize(width: number): this;
enabledAnchors(): Array<string>;
enabledAnchors(names: Array<string>): this;
}

@@ -1176,0 +1227,0 @@

{
"name": "konva",
"version": "2.2.1",
"version": "2.2.2",
"author": "Anton Lavrenov",

@@ -5,0 +5,0 @@ "files": [

@@ -26,3 +26,3 @@ <p align="center">

```html
<script src="https://cdn.rawgit.com/konvajs/konva/2.2.1/konva.min.js"></script>
<script src="https://cdn.rawgit.com/konvajs/konva/2.2.2/konva.min.js"></script>
<div id="container"></div>

@@ -29,0 +29,0 @@ <script>

@@ -175,2 +175,11 @@ (function(Konva) {

},
_toKonvaCanvas: function(config) {
config = config || {};
config.width = config.width || this.getWidth();
config.height = config.height || this.getHeight();
config.x = config.x !== undefined ? config.x : this.getX();
config.y = config.y !== undefined ? config.y : this.getY();
return Konva.Node.prototype._toKonvaCanvas.call(this, config);
},
/**

@@ -177,0 +186,0 @@ * get/set width of layer.getter return width of stage. setter doing nothing.

@@ -236,11 +236,9 @@ (function() {

if (!Konva.Util.isValidSelector(sel)) {
Konva.Util.warn(
var message =
'Selector "' +
sel +
'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'
);
Konva.Util.warn(
'If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'
);
Konva.Util.warn('Konva is awesome, right?');
sel +
'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".\n' +
'If you have a custom shape with such className, please change it to start with upper letter like "Triangle".\n' +
'Konva is awesome, right?';
Konva.Util.warn(message);
}

@@ -603,3 +601,8 @@ // id selector

Konva.Factory.addGetterSetter(Konva.Container, 'clipX');
Konva.Factory.addGetterSetter(
Konva.Container,
'clipX',
undefined,
Konva.Validators.getNumberValidator()
);
/**

@@ -620,3 +623,8 @@ * get/set clip x

Konva.Factory.addGetterSetter(Konva.Container, 'clipY');
Konva.Factory.addGetterSetter(
Konva.Container,
'clipY',
undefined,
Konva.Validators.getNumberValidator()
);
/**

@@ -637,3 +645,8 @@ * get/set clip y

Konva.Factory.addGetterSetter(Konva.Container, 'clipWidth');
Konva.Factory.addGetterSetter(
Konva.Container,
'clipWidth',
undefined,
Konva.Validators.getNumberValidator()
);
/**

@@ -654,3 +667,8 @@ * get/set clip width

Konva.Factory.addGetterSetter(Konva.Container, 'clipHeight');
Konva.Factory.addGetterSetter(
Konva.Container,
'clipHeight',
undefined,
Konva.Validators.getNumberValidator()
);
/**

@@ -657,0 +675,0 @@ * get/set clip height

@@ -22,7 +22,10 @@ (function() {

addSetter: function(constructor, attr, validator, after) {
// if (!validator && validator !== null) {
// console.error(constructor, attr, 'has no validator.');
// }
var method = SET + Konva.Util._capitalize(attr);
constructor.prototype[method] = function(val) {
if (validator) {
val = validator.call(this, val);
if (validator && val !== undefined && val !== null) {
val = validator.call(this, val, attr);
}

@@ -173,4 +176,122 @@

return val;
},
_formatValue: function(val) {
if (Konva.Util._isString(val)) {
return '"' + val + '"';
}
if (Object.prototype.toString.call(val) === '[object Number]') {
return val;
}
if (Konva.Util._isBoolean(val)) {
return val;
}
return Object.prototype.toString.call(val);
},
getNumberValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
if (!Konva.Util._isNumber(val)) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a number.'
);
}
return val;
};
}
},
getNumberOrAutoValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
var isNumber = Konva.Util._isNumber(val);
var isAuto = val === 'auto';
if (!(isNumber || isAuto)) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a number or "auto".'
);
}
return val;
};
}
},
getStringValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
if (!Konva.Util._isString(val)) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a string.'
);
}
return val;
};
}
},
getFunctionValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
if (!Konva.Util._isFunction(val)) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a function.'
);
}
return val;
};
}
},
getNumberArrayValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
if (!Konva.Util._isArray(val)) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a array of numbers.'
);
} else {
val.forEach(function(item) {
if (!Konva.Util._isNumber(item)) {
Konva.Util.warn(
'"' +
attr +
'" attribute has non numeric element ' +
item +
'. Make sure that all elements are numbers.'
);
}
});
}
return val;
};
}
},
getBooleanValidator: function() {
if (Konva.isUnminified) {
return function(val, attr) {
var isBool = val === true || val === false;
if (!isBool) {
Konva.Util.warn(
Konva.Validators._formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a boolean.'
);
}
return val;
};
}
}
};
})();

@@ -842,3 +842,3 @@ /*

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -845,0 +845,0 @@ );

@@ -33,3 +33,3 @@ (function(Konva) {

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -36,0 +36,0 @@ );

@@ -73,5 +73,5 @@ (function(Konva) {

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter
);
})(Konva);

@@ -145,3 +145,3 @@ (function() {

0.5,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -162,3 +162,3 @@ );

0.5,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -165,0 +165,0 @@ );

@@ -149,5 +149,5 @@ (function() {

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter
);
})();

@@ -7,3 +7,3 @@ (function() {

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -24,3 +24,3 @@ );

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -41,3 +41,3 @@ );

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -44,0 +44,0 @@ );

@@ -67,3 +67,3 @@ (function() {

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -84,3 +84,3 @@ );

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -101,3 +101,3 @@ );

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -104,0 +104,0 @@ );

@@ -277,3 +277,3 @@ (function() {

2,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -294,5 +294,5 @@ );

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter
);
})();

@@ -218,5 +218,5 @@ /*eslint-disable max-depth */

0,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter
);
})();

@@ -33,3 +33,3 @@ (function() {

0.2,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -36,0 +36,0 @@ );

@@ -109,3 +109,3 @@ /*eslint-disable max-depth */

8,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -112,0 +112,0 @@ );

@@ -35,3 +35,3 @@ (function() {

0.5,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -38,0 +38,0 @@ );

@@ -33,3 +33,3 @@ (function() {

0.5,
null,
Konva.Validators.getNumberValidator(),
Konva.Factory.afterSetFilter

@@ -36,0 +36,0 @@ );

@@ -42,2 +42,6 @@ /*

isUnminified: /comment/.test(function() {
/* comment */
}),
// configurations

@@ -126,5 +130,14 @@ enableTrace: false,

_addId: function(node, id) {
if (id !== undefined) {
this.ids[id] = node;
if (!id) {
return;
}
// do we need this warning?
// if (this.ids[id]) {
// Konva.Util.warn(
// 'Duplicate id "' +
// id +
// '". Please don not use same id several times. It may break find() method look up.'
// );
// }
this.ids[id] = node;
},

@@ -131,0 +144,0 @@ _removeId: function(id) {

@@ -522,3 +522,8 @@ (function(Konva) {

// add getters and setters
Konva.Factory.addGetterSetter(Konva.Shape, 'stroke');
Konva.Factory.addGetterSetter(
Konva.Shape,
'stroke',
undefined,
Konva.Validators.getStringValidator()
);

@@ -549,3 +554,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'strokeWidth', 2);
Konva.Factory.addGetterSetter(
Konva.Shape,
'strokeWidth',
2,
Konva.Validators.getNumberValidator()
);

@@ -567,3 +577,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'strokeHitEnabled', true);
Konva.Factory.addGetterSetter(
Konva.Shape,
'strokeHitEnabled',
true,
Konva.Validators.getBooleanValidator()
);

@@ -589,3 +604,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'perfectDrawEnabled', true);
Konva.Factory.addGetterSetter(
Konva.Shape,
'perfectDrawEnabled',
true,
Konva.Validators.getBooleanValidator()
);

@@ -609,3 +629,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowForStrokeEnabled', true);
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowForStrokeEnabled',
true,
Konva.Validators.getBooleanValidator()
);

@@ -727,3 +752,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'dashOffset', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'dashOffset',
0,
Konva.Validators.getNumberValidator()
);

@@ -743,3 +773,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowColor');
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowColor',
undefined,
Konva.Validators.getStringValidator()
);

@@ -770,3 +805,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowBlur');
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowBlur',
0,
Konva.Validators.getNumberValidator()
);

@@ -788,3 +828,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowOpacity');
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowOpacity',
1,
Konva.Validators.getNumberValidator()
);

@@ -831,3 +876,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowOffsetX', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowOffsetX',
0,
Konva.Validators.getNumberValidator()
);

@@ -849,3 +899,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'shadowOffsetY', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'shadowOffsetY',
0,
Konva.Validators.getNumberValidator()
);

@@ -888,3 +943,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fill');
Konva.Factory.addGetterSetter(
Konva.Shape,
'fill',
undefined,
Konva.Validators.getStringValidator()
);

@@ -918,3 +978,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternX', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternX',
0,
Konva.Validators.getNumberValidator()
);

@@ -935,3 +1000,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternY', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternY',
0,
Konva.Validators.getNumberValidator()
);

@@ -1207,3 +1277,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternOffsetX', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternOffsetX',
0,
Konva.Validators.getNumberValidator()
);

@@ -1225,3 +1300,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternOffsetY', 0);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternOffsetY',
0,
Konva.Validators.getNumberValidator()
);

@@ -1268,3 +1348,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternScaleX', 1);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternScaleX',
1,
Konva.Validators.getNumberValidator()
);

@@ -1286,3 +1371,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Shape, 'fillPatternScaleY', 1);
Konva.Factory.addGetterSetter(
Konva.Shape,
'fillPatternScaleY',
1,
Konva.Validators.getNumberValidator()
);

@@ -1289,0 +1379,0 @@ /**

@@ -74,3 +74,8 @@ (function(Konva) {

// add getters setters
Konva.Factory.addGetterSetter(Konva.Arc, 'innerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Arc,
'innerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -92,3 +97,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Arc, 'outerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Arc,
'outerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -110,3 +120,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Arc, 'angle', 0);
Konva.Factory.addGetterSetter(
Konva.Arc,
'angle',
0,
Konva.Validators.getNumberValidator()
);

@@ -113,0 +128,0 @@ /**

@@ -128,3 +128,8 @@ (function(Konva) {

Konva.Factory.addGetterSetter(Konva.Arrow, 'pointerLength', 10);
Konva.Factory.addGetterSetter(
Konva.Arrow,
'pointerLength',
10,
Konva.Validators.getNumberValidator()
);
/**

@@ -146,3 +151,8 @@ * get/set pointerWidth

Konva.Factory.addGetterSetter(Konva.Arrow, 'pointerWidth', 10);
Konva.Factory.addGetterSetter(
Konva.Arrow,
'pointerWidth',
10,
Konva.Validators.getNumberValidator()
);
/**

@@ -149,0 +159,0 @@ * get/set pointerAtBeginning

@@ -69,3 +69,8 @@ (function(Konva) {

// add getters setters
Konva.Factory.addGetterSetter(Konva.Circle, 'radius', 0);
Konva.Factory.addGetterSetter(
Konva.Circle,
'radius',
0,
Konva.Validators.getNumberValidator()
);
Konva.Factory.addOverloadedGetterSetter(Konva.Circle, 'radius');

@@ -72,0 +77,0 @@

@@ -98,3 +98,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Ellipse, 'radiusX', 0);
Konva.Factory.addGetterSetter(
Konva.Ellipse,
'radiusX',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -115,3 +120,8 @@ * get/set radius x

Konva.Factory.addGetterSetter(Konva.Ellipse, 'radiusY', 0);
Konva.Factory.addGetterSetter(
Konva.Ellipse,
'radiusY',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -118,0 +128,0 @@ * get/set radius y

@@ -156,3 +156,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Image, 'cropX', 0);
Konva.Factory.addGetterSetter(
Konva.Image,
'cropX',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -173,3 +178,8 @@ * get/set crop x

Konva.Factory.addGetterSetter(Konva.Image, 'cropY', 0);
Konva.Factory.addGetterSetter(
Konva.Image,
'cropY',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -190,3 +200,8 @@ * get/set crop y

Konva.Factory.addGetterSetter(Konva.Image, 'cropWidth', 0);
Konva.Factory.addGetterSetter(
Konva.Image,
'cropWidth',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -207,3 +222,8 @@ * get/set crop width

Konva.Factory.addGetterSetter(Konva.Image, 'cropHeight', 0);
Konva.Factory.addGetterSetter(
Konva.Image,
'cropHeight',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -210,0 +230,0 @@ * get/set crop height

@@ -340,3 +340,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Tag, 'pointerWidth', 0);
Konva.Factory.addGetterSetter(
Konva.Tag,
'pointerWidth',
0,
Konva.Validators.getNumberValidator()
);

@@ -358,3 +363,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Tag, 'pointerHeight', 0);
Konva.Factory.addGetterSetter(
Konva.Tag,
'pointerHeight',
0,
Konva.Validators.getNumberValidator()
);

@@ -376,3 +386,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Tag, 'cornerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Tag,
'cornerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -379,0 +394,0 @@ /**

@@ -247,3 +247,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Line, 'tension', 0);
Konva.Factory.addGetterSetter(
Konva.Line,
'tension',
0,
Konva.Validators.getNumberValidator()
);

@@ -266,3 +271,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Line, 'points', []);
Konva.Factory.addGetterSetter(
Konva.Line,
'points',
[],
Konva.Validators.getNumberArrayValidator()
);
/**

@@ -269,0 +279,0 @@ * get/set points array

@@ -89,3 +89,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Rect, 'cornerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Rect,
'cornerRadius',
0,
Konva.Validators.getNumberValidator()
);
/**

@@ -92,0 +97,0 @@ * get/set corner radius

@@ -79,3 +79,8 @@ (function() {

// add getters setters
Konva.Factory.addGetterSetter(Konva.RegularPolygon, 'radius', 0);
Konva.Factory.addGetterSetter(
Konva.RegularPolygon,
'radius',
0,
Konva.Validators.getNumberValidator()
);

@@ -97,3 +102,8 @@ /**

Konva.Factory.addGetterSetter(Konva.RegularPolygon, 'sides', 0);
Konva.Factory.addGetterSetter(
Konva.RegularPolygon,
'sides',
0,
Konva.Validators.getNumberValidator()
);

@@ -100,0 +110,0 @@ /**

@@ -75,3 +75,8 @@ (function() {

// add getters setters
Konva.Factory.addGetterSetter(Konva.Ring, 'innerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Ring,
'innerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -92,3 +97,8 @@ /**

*/
Konva.Factory.addGetter(Konva.Ring, 'outerRadius', 0);
Konva.Factory.addGetter(
Konva.Ring,
'outerRadius',
0,
Konva.Validators.getNumberValidator()
);
Konva.Factory.addOverloadedGetterSetter(Konva.Ring, 'outerRadius');

@@ -95,0 +105,0 @@

@@ -317,3 +317,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.Sprite, 'frameIndex', 0);
Konva.Factory.addGetterSetter(
Konva.Sprite,
'frameIndex',
0,
Konva.Validators.getNumberValidator()
);

@@ -335,3 +340,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Sprite, 'frameRate', 17);
Konva.Factory.addGetterSetter(
Konva.Sprite,
'frameRate',
17,
Konva.Validators.getNumberValidator()
);

@@ -338,0 +348,0 @@ /**

@@ -82,3 +82,8 @@ (function() {

// add getters setters
Konva.Factory.addGetterSetter(Konva.Star, 'numPoints', 5);
Konva.Factory.addGetterSetter(
Konva.Star,
'numPoints',
5,
Konva.Validators.getNumberValidator()
);

@@ -100,3 +105,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Star, 'innerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Star,
'innerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -118,3 +128,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Star, 'outerRadius', 0);
Konva.Factory.addGetterSetter(
Konva.Star,
'outerRadius',
0,
Konva.Validators.getNumberValidator()
);

@@ -121,0 +136,0 @@ /**

@@ -477,2 +477,14 @@ /*eslint-disable max-depth */

Konva.Factory.addSetter(
Konva.Node,
'width',
Konva.Validators.getNumberOrAutoValidator()
);
Konva.Factory.addSetter(
Konva.Node,
'height',
Konva.Validators.getNumberOrAutoValidator()
);
// add getters setters

@@ -496,3 +508,8 @@ Konva.Factory.addGetterSetter(Konva.Text, 'fontFamily', 'Arial');

Konva.Factory.addGetterSetter(Konva.Text, 'fontSize', 12);
Konva.Factory.addGetterSetter(
Konva.Text,
'fontSize',
12,
Konva.Validators.getNumberValidator()
);

@@ -548,3 +565,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Text, 'padding', 0);
Konva.Factory.addGetterSetter(
Konva.Text,
'padding',
0,
Konva.Validators.getNumberValidator()
);

@@ -586,3 +608,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Text, 'lineHeight', 1);
Konva.Factory.addGetterSetter(
Konva.Text,
'lineHeight',
1,
Konva.Validators.getNumberValidator()
);

@@ -639,3 +666,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Text, 'letterSpacing', 0);
Konva.Factory.addGetterSetter(
Konva.Text,
'letterSpacing',
0,
Konva.Validators.getNumberValidator()
);

@@ -642,0 +674,0 @@ /**

@@ -561,3 +561,8 @@ (function() {

Konva.Factory.addGetterSetter(Konva.TextPath, 'fontSize', 12);
Konva.Factory.addGetterSetter(
Konva.TextPath,
'fontSize',
12,
Konva.Validators.getNumberValidator()
);

@@ -608,3 +613,8 @@ /**

Konva.Factory.addGetterSetter(Konva.TextPath, 'letterSpacing', 0);
Konva.Factory.addGetterSetter(
Konva.TextPath,
'letterSpacing',
0,
Konva.Validators.getNumberValidator()
);

@@ -611,0 +621,0 @@ /**

@@ -874,3 +874,8 @@ (function(Konva) {

*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'anchorSize', 10);
Konva.Factory.addGetterSetter(
Konva.Transformer,
'anchorSize',
10,
Konva.Validators.getNumberValidator()
);

@@ -923,3 +928,8 @@ /**

*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'rotateAnchorOffset', 50);
Konva.Factory.addGetterSetter(
Konva.Transformer,
'rotateAnchorOffset',
50,
Konva.Validators.getNumberValidator()
);

@@ -976,3 +986,8 @@ /**

*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'anchorStrokeWidth', 1);
Konva.Factory.addGetterSetter(
Konva.Transformer,
'anchorStrokeWidth',
1,
Konva.Validators.getNumberValidator()
);

@@ -1029,3 +1044,8 @@ /**

*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'borderStrokeWidth', 1);
Konva.Factory.addGetterSetter(
Konva.Transformer,
'borderStrokeWidth',
1,
Konva.Validators.getNumberValidator()
);

@@ -1078,3 +1098,8 @@ /**

*/
Konva.Factory.addGetterSetter(Konva.Transformer, 'padding', 0);
Konva.Factory.addGetterSetter(
Konva.Transformer,
'padding',
0,
Konva.Validators.getNumberValidator()
);

@@ -1081,0 +1106,0 @@ Konva.Factory.addOverloadedGetterSetter(Konva.Transformer, 'node');

@@ -76,3 +76,8 @@ (function() {

// add getters setters
Konva.Factory.addGetterSetter(Konva.Wedge, 'radius', 0);
Konva.Factory.addGetterSetter(
Konva.Wedge,
'radius',
0,
Konva.Validators.getNumberValidator()
);

@@ -94,3 +99,8 @@ /**

Konva.Factory.addGetterSetter(Konva.Wedge, 'angle', 0);
Konva.Factory.addGetterSetter(
Konva.Wedge,
'angle',
0,
Konva.Validators.getNumberValidator()
);

@@ -97,0 +107,0 @@ /**

@@ -235,8 +235,6 @@ (function() {

},
toDataURL: function(config) {
_toKonvaCanvas: function(config) {
config = config || {};
var mimeType = config.mimeType || null,
quality = config.quality || null,
x = config.x || 0,
var x = config.x || 0,
y = config.y || 0,

@@ -259,20 +257,12 @@ canvas = new Konva.SceneCanvas({

}
var width = layer.getCanvas().getWidth();
var height = layer.getCanvas().getHeight();
var ratio = layer.getCanvas().getPixelRatio();
var layerCanvas = layer._toKonvaCanvas(config);
_context.drawImage(
layer.getCanvas()._canvas,
0,
0,
width / ratio,
height / ratio
layerCanvas._canvas,
x,
y,
layerCanvas.getWidth() / layerCanvas.getPixelRatio(),
layerCanvas.getHeight() / layerCanvas.getPixelRatio()
);
});
var src = canvas.toDataURL(mimeType, quality);
if (config.callback) {
config.callback(src);
}
return src;
return canvas;
},

@@ -279,0 +269,0 @@ /**

@@ -159,3 +159,3 @@ (function() {

if (typeof config.duration === 'undefined') {
duration = 1;
duration = 0.3;
} else if (config.duration === 0) {

@@ -162,0 +162,0 @@ // zero is bad value for duration

@@ -306,2 +306,3 @@ /*eslint-disable eqeqeq, no-cond-assign, no-empty*/

OBJECT_STRING = '[object String]',
OBJECT_BOOLEAN = '[object Boolean]',
PI_OVER_DEG180 = Math.PI / 180,

@@ -489,3 +490,7 @@ DEG180_OVER_PI = 180 / Math.PI,

_isNumber: function(obj) {
return Object.prototype.toString.call(obj) === OBJECT_NUMBER;
return (
Object.prototype.toString.call(obj) === OBJECT_NUMBER &&
!isNaN(obj) &&
isFinite(obj)
);
},

@@ -495,2 +500,5 @@ _isString: function(obj) {

},
_isBoolean: function(obj) {
return Object.prototype.toString.call(obj) === OBJECT_BOOLEAN;
},
// arrays are objects too

@@ -497,0 +505,0 @@ isObject: function(val) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc