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

@@ -1,7 +1,7 @@
import { Util, Collection } from './Util';
import { Factory, Validators } from './Factory';
import { Node, ids, names } from './Node';
import { getGlobalKonva } from './Global';
import { DD } from './DragAndDrop';
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 (getGlobalKonva().DD && child.isDragging()) {
getGlobalKonva().DD.anim.setLayers(child.getLayer());
if (child.isDragging()) {
DD.anim.setLayers(child.getLayer());
}
// chainable
@@ -499,12 +499,9 @@ export abstract class Container extends Node {
}
shouldDrawHit(canvas?) {
var layer = this.getLayer();
var dd = getGlobalKonva().DD;
var layerUnderDrag =
dd &&
getGlobalKonva().isDragging() &&
getGlobalKonva()
.DD.anim.getLayers()
DD.isDragging &&
DD.anim.getLayers()
.indexOf(layer) !== -1;
return (
(canvas && canvas.isCache) ||

View File

@@ -30,43 +30,11 @@ export const isUnminified = /comment/.test(
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) {
return getGlobalKonva().angleDeg ? angle * PI_OVER_180 : angle;
};
export const _detectIE = function(ua) {
const _detectIE = function(ua) {
var msie = ua.indexOf('msie ');
if (msie > 0) {
// IE 10 or older => return version number
@@ -89,6 +57,7 @@ export const _detectIE = function(ua) {
// other browser
return false;
};
export const _parseUA = function(userAgent) {
var ua = userAgent.toLowerCase(),
// jQuery UA regex

View File

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

View File

@@ -11,7 +11,9 @@ export { FastLayer } from './FastLayer';
export { Group } from './Group';
export { DD } from './DragAndDrop';
import { DD as dd } from './DragAndDrop';
export const DD = dd;
export { Shape, shapes } from './Shape';
export { Animation } from './Animation';
@@ -78,7 +80,23 @@ export const showWarnings = true;
*/
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
export { Arc } from './shapes/Arc';