remove some method from public API

This commit is contained in:
Anton Lavrenov 2019-02-23 21:36:05 -05:00
parent 98afa3fac6
commit 4a6eba726c
6 changed files with 66 additions and 96 deletions

View File

@ -29,35 +29,6 @@
/* comment */ /* comment */
}.toString()); }.toString());
var dblClickWindow = 400; var dblClickWindow = 400;
/**
* returns whether or not drag and drop is currently active
* @method
* @memberof Konva
*/
var isDragging = function () {
var dd = getGlobalKonva()['DD'];
// if DD is not included with the build, then
// drag and drop is not even possible
if (dd) {
return dd.isDragging;
}
return false;
};
/**
* returns whether or not a drag and drop operation is ready, but may
* not necessarily have started
* @method
* @memberof Konva
*/
var isDragReady = function () {
var dd = getGlobalKonva()['DD'];
// if DD is not included with the build, then
// drag and drop is not even possible
if (dd) {
return !!dd.node;
}
return false;
};
var getAngle = function (angle) { var getAngle = function (angle) {
return getGlobalKonva().angleDeg ? angle * PI_OVER_180 : angle; return getGlobalKonva().angleDeg ? angle * PI_OVER_180 : angle;
}; };
@ -5008,8 +4979,8 @@
child: child child: child
}); });
// if node under drag we need to update drag animation // if node under drag we need to update drag animation
if (getGlobalKonva().DD && child.isDragging()) { if (child.isDragging()) {
getGlobalKonva().DD.anim.setLayers(child.getLayer()); DD.anim.setLayers(child.getLayer());
} }
// chainable // chainable
return this; return this;
@ -5328,11 +5299,8 @@
}; };
Container.prototype.shouldDrawHit = function (canvas) { Container.prototype.shouldDrawHit = function (canvas) {
var layer = this.getLayer(); var layer = this.getLayer();
var dd = getGlobalKonva().DD; var layerUnderDrag = DD.isDragging &&
var layerUnderDrag = dd && DD.anim.getLayers()
getGlobalKonva().isDragging() &&
getGlobalKonva()
.DD.anim.getLayers()
.indexOf(layer) !== -1; .indexOf(layer) !== -1;
return ((canvas && canvas.isCache) || return ((canvas && canvas.isCache) ||
(layer && layer.hitGraphEnabled() && this.isVisible() && !layerUnderDrag)); (layer && layer.hitGraphEnabled() && this.isVisible() && !layerUnderDrag));
@ -5798,7 +5766,7 @@
Stage.prototype._mouseout = function (evt) { Stage.prototype._mouseout = function (evt) {
this.setPointersPositions(evt); this.setPointersPositions(evt);
var targetShape = this.targetShape; var targetShape = this.targetShape;
if (targetShape && !getGlobalKonva().isDragging()) { if (targetShape && !DD.isDragging) {
targetShape._fireAndBubble(MOUSEOUT, { evt: evt }); targetShape._fireAndBubble(MOUSEOUT, { evt: evt });
targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt }); targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt });
this.targetShape = null; this.targetShape = null;
@ -5813,11 +5781,11 @@
} }
this.setPointersPositions(evt); this.setPointersPositions(evt);
var shape; var shape;
if (!getGlobalKonva().isDragging()) { if (!DD.isDragging) {
shape = this.getIntersection(this.getPointerPosition()); shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) { if (shape && shape.isListening()) {
var differentTarget = !this.targetShape || this.targetShape !== shape; var differentTarget = !this.targetShape || this.targetShape !== shape;
if (!getGlobalKonva().isDragging() && differentTarget) { if (!DD.isDragging && differentTarget) {
if (this.targetShape) { if (this.targetShape) {
this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }, shape); this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }, shape);
this.targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt }, shape); this.targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt }, shape);
@ -5835,7 +5803,7 @@
* if no shape was detected, clear target shape and try * if no shape was detected, clear target shape and try
* to run mouseout from previous target shape * to run mouseout from previous target shape
*/ */
if (this.targetShape && !getGlobalKonva().isDragging()) { if (this.targetShape && !DD.isDragging) {
this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }); this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt });
this.targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt }); this.targetShape._fireAndBubble(MOUSELEAVE$1, { evt: evt });
this._fire(MOUSEOVER, { this._fire(MOUSEOVER, {
@ -6046,7 +6014,7 @@
Stage.prototype._touchmove = function (evt) { Stage.prototype._touchmove = function (evt) {
this.setPointersPositions(evt); this.setPointersPositions(evt);
var dd = getGlobalKonva().DD, shape; var dd = getGlobalKonva().DD, shape;
if (!getGlobalKonva().isDragging()) { if (!DD.isDragging) {
shape = this.getIntersection(this.getPointerPosition()); shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) { if (shape && shape.isListening()) {
shape._fireAndBubble(TOUCHMOVE, { evt: evt }); shape._fireAndBubble(TOUCHMOVE, { evt: evt });
@ -6065,7 +6033,7 @@
this._fire(CONTENT_TOUCHMOVE, { evt: evt }); this._fire(CONTENT_TOUCHMOVE, { evt: evt });
} }
if (dd) { if (dd) {
if (getGlobalKonva().isDragging() && if (DD.isDragging &&
getGlobalKonva().DD.node.preventDefault() && getGlobalKonva().DD.node.preventDefault() &&
evt.cancelable) { evt.cancelable) {
evt.preventDefault(); evt.preventDefault();
@ -16946,6 +16914,7 @@
* @returns {Number} * @returns {Number}
*/ */
var DD$1 = DD;
var enableTrace = false; var enableTrace = false;
// TODO: move that to stage? // TODO: move that to stage?
var listenClickTap = false; var listenClickTap = false;
@ -17002,6 +16971,23 @@
* Konva.dragButtons = [0, 2]; * Konva.dragButtons = [0, 2];
*/ */
var dragButtons = [0, 1]; var dragButtons = [0, 1];
/**
* returns whether or not drag and drop is currently active
* @method
* @memberof Konva
*/
var isDragging = function () {
return DD.isDragging;
};
/**
* returns whether or not a drag and drop operation is ready, but may
* not necessarily have started
* @method
* @memberof Konva
*/
var isDragReady = function () {
return !!DD.node;
};
/** /**
* @namespace Filters * @namespace Filters
* @memberof Konva * @memberof Konva
@ -17029,6 +17015,7 @@
}; };
var Konva = ({ var Konva = ({
DD: DD$1,
enableTrace: enableTrace, enableTrace: enableTrace,
listenClickTap: listenClickTap, listenClickTap: listenClickTap,
inDblClickWindow: inDblClickWindow, inDblClickWindow: inDblClickWindow,
@ -17037,6 +17024,8 @@
angleDeg: angleDeg, angleDeg: angleDeg,
showWarnings: showWarnings, showWarnings: showWarnings,
dragButtons: dragButtons, dragButtons: dragButtons,
isDragging: isDragging,
isDragReady: isDragReady,
Filters: Filters, Filters: Filters,
Collection: Collection, Collection: Collection,
Util: Util, Util: Util,
@ -17049,7 +17038,6 @@
Layer: Layer, Layer: Layer,
FastLayer: FastLayer, FastLayer: FastLayer,
Group: Group, Group: Group,
DD: DD,
Shape: Shape, Shape: Shape,
shapes: shapes, shapes: shapes,
Animation: Animation, Animation: Animation,
@ -17077,10 +17065,7 @@
isBrowser: isBrowser, isBrowser: isBrowser,
isUnminified: isUnminified, isUnminified: isUnminified,
dblClickWindow: dblClickWindow, dblClickWindow: dblClickWindow,
isDragging: isDragging,
isDragReady: isDragReady,
getAngle: getAngle, getAngle: getAngle,
_detectIE: _detectIE,
_parseUA: _parseUA, _parseUA: _parseUA,
glob: glob, glob: glob,
UA: UA, UA: UA,

2
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import { Util, Collection } from './Util'; import { Util, Collection } from './Util';
import { Factory, Validators } from './Factory'; import { Factory, Validators } from './Factory';
import { Node, ids, names } from './Node'; import { Node, ids, names } from './Node';
import { getGlobalKonva } from './Global'; import { DD } from './DragAndDrop';
import { GetSet, IRect } from './types'; import { GetSet, IRect } from './types';
@ -123,8 +123,8 @@ export abstract class Container extends Node {
}); });
// if node under drag we need to update drag animation // if node under drag we need to update drag animation
if (getGlobalKonva().DD && child.isDragging()) { if (child.isDragging()) {
getGlobalKonva().DD.anim.setLayers(child.getLayer()); DD.anim.setLayers(child.getLayer());
} }
// chainable // chainable
@ -499,12 +499,9 @@ export abstract class Container extends Node {
} }
shouldDrawHit(canvas?) { shouldDrawHit(canvas?) {
var layer = this.getLayer(); var layer = this.getLayer();
var dd = getGlobalKonva().DD;
var layerUnderDrag = var layerUnderDrag =
dd && DD.isDragging &&
getGlobalKonva().isDragging() && DD.anim.getLayers()
getGlobalKonva()
.DD.anim.getLayers()
.indexOf(layer) !== -1; .indexOf(layer) !== -1;
return ( return (
(canvas && canvas.isCache) || (canvas && canvas.isCache) ||

View File

@ -30,43 +30,11 @@ export const isUnminified = /comment/.test(
export const dblClickWindow = 400; export const dblClickWindow = 400;
/**
* returns whether or not drag and drop is currently active
* @method
* @memberof Konva
*/
export const isDragging = function() {
var dd = getGlobalKonva()['DD'];
// if DD is not included with the build, then
// drag and drop is not even possible
if (dd) {
return dd.isDragging;
}
return false;
};
/**
* returns whether or not a drag and drop operation is ready, but may
* not necessarily have started
* @method
* @memberof Konva
*/
export const isDragReady = function() {
var dd = getGlobalKonva()['DD'];
// if DD is not included with the build, then
// drag and drop is not even possible
if (dd) {
return !!dd.node;
}
return false;
};
export const getAngle = function(angle) { export const getAngle = function(angle) {
return getGlobalKonva().angleDeg ? angle * PI_OVER_180 : angle; return getGlobalKonva().angleDeg ? angle * PI_OVER_180 : angle;
}; };
export const _detectIE = function(ua) { const _detectIE = function(ua) {
var msie = ua.indexOf('msie '); var msie = ua.indexOf('msie ');
if (msie > 0) { if (msie > 0) {
// IE 10 or older => return version number // IE 10 or older => return version number
@ -89,6 +57,7 @@ export const _detectIE = function(ua) {
// other browser // other browser
return false; return false;
}; };
export const _parseUA = function(userAgent) { export const _parseUA = function(userAgent) {
var ua = userAgent.toLowerCase(), var ua = userAgent.toLowerCase(),
// jQuery UA regex // jQuery UA regex

View File

@ -6,6 +6,7 @@ import { SceneCanvas, HitCanvas } from './Canvas';
import { GetSet, Vector2d } from './types'; import { GetSet, Vector2d } from './types';
import { Shape } from './Shape'; import { Shape } from './Shape';
import { BaseLayer } from './BaseLayer'; import { BaseLayer } from './BaseLayer';
import { DD } from './DragAndDrop';
// CONSTANTS // CONSTANTS
var STAGE = 'Stage', var STAGE = 'Stage',
@ -379,7 +380,7 @@ export class Stage extends Container {
this.setPointersPositions(evt); this.setPointersPositions(evt);
var targetShape = this.targetShape; var targetShape = this.targetShape;
if (targetShape && !getGlobalKonva().isDragging()) { if (targetShape && !DD.isDragging) {
targetShape._fireAndBubble(MOUSEOUT, { evt: evt }); targetShape._fireAndBubble(MOUSEOUT, { evt: evt });
targetShape._fireAndBubble(MOUSELEAVE, { evt: evt }); targetShape._fireAndBubble(MOUSELEAVE, { evt: evt });
this.targetShape = null; this.targetShape = null;
@ -396,11 +397,11 @@ export class Stage extends Container {
this.setPointersPositions(evt); this.setPointersPositions(evt);
var shape; var shape;
if (!getGlobalKonva().isDragging()) { if (!DD.isDragging) {
shape = this.getIntersection(this.getPointerPosition()); shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) { if (shape && shape.isListening()) {
var differentTarget = !this.targetShape || this.targetShape !== shape; var differentTarget = !this.targetShape || this.targetShape !== shape;
if (!getGlobalKonva().isDragging() && differentTarget) { if (!DD.isDragging && differentTarget) {
if (this.targetShape) { if (this.targetShape) {
this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }, shape); this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }, shape);
this.targetShape._fireAndBubble(MOUSELEAVE, { evt: evt }, shape); this.targetShape._fireAndBubble(MOUSELEAVE, { evt: evt }, shape);
@ -416,7 +417,7 @@ export class Stage extends Container {
* if no shape was detected, clear target shape and try * if no shape was detected, clear target shape and try
* to run mouseout from previous target shape * to run mouseout from previous target shape
*/ */
if (this.targetShape && !getGlobalKonva().isDragging()) { if (this.targetShape && !DD.isDragging) {
this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt }); this.targetShape._fireAndBubble(MOUSEOUT, { evt: evt });
this.targetShape._fireAndBubble(MOUSELEAVE, { evt: evt }); this.targetShape._fireAndBubble(MOUSELEAVE, { evt: evt });
this._fire(MOUSEOVER, { this._fire(MOUSEOVER, {
@ -653,7 +654,7 @@ export class Stage extends Container {
this.setPointersPositions(evt); this.setPointersPositions(evt);
var dd = getGlobalKonva().DD, var dd = getGlobalKonva().DD,
shape; shape;
if (!getGlobalKonva().isDragging()) { if (!DD.isDragging) {
shape = this.getIntersection(this.getPointerPosition()); shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) { if (shape && shape.isListening()) {
shape._fireAndBubble(TOUCHMOVE, { evt: evt }); shape._fireAndBubble(TOUCHMOVE, { evt: evt });
@ -672,7 +673,7 @@ export class Stage extends Container {
} }
if (dd) { if (dd) {
if ( if (
getGlobalKonva().isDragging() && DD.isDragging &&
getGlobalKonva().DD.node.preventDefault() && getGlobalKonva().DD.node.preventDefault() &&
evt.cancelable evt.cancelable
) { ) {

View File

@ -11,7 +11,9 @@ export { FastLayer } from './FastLayer';
export { Group } from './Group'; export { Group } from './Group';
export { DD } from './DragAndDrop'; import { DD as dd } from './DragAndDrop';
export const DD = dd;
export { Shape, shapes } from './Shape'; export { Shape, shapes } from './Shape';
export { Animation } from './Animation'; export { Animation } from './Animation';
@ -78,7 +80,23 @@ export const showWarnings = true;
*/ */
export const dragButtons = [0, 1]; export const dragButtons = [0, 1];
// export default KonvaInternals; /**
* returns whether or not drag and drop is currently active
* @method
* @memberof Konva
*/
export const isDragging = function() {
return dd.isDragging;
};
/**
* returns whether or not a drag and drop operation is ready, but may
* not necessarily have started
* @method
* @memberof Konva
*/
export const isDragReady = function() {
return !!dd.node;
};
// shapes // shapes
export { Arc } from './shapes/Arc'; export { Arc } from './shapes/Arc';