allow cloning id

This commit is contained in:
Anton Lavrenov 2020-02-17 19:51:18 -05:00
parent c3d01c3f0c
commit 6fbe48e583
5 changed files with 14 additions and 31 deletions

View File

@ -158,7 +158,7 @@
"max-len": [2, 320, 4],
"max-nested-callbacks": [2, 2],
"max-params": [1, 8],
"max-statements": [1, 60],
"max-statements": [1, 260],
"new-cap": 0,
"new-parens": 2,
"newline-after-var": 0,

View File

@ -8,7 +8,7 @@
* Konva JavaScript Framework v4.1.5
* http://konvajs.org/
* Licensed under the MIT
* Date: Sun Feb 16 2020
* Date: Mon Feb 17 2020
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -2515,7 +2515,7 @@
}
};
// CONSTANTS
var ABSOLUTE_OPACITY = 'absoluteOpacity', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET$1 = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', CLONE_BLACK_LIST = ['id'], TRANSFORM_CHANGE_STR = [
var ABSOLUTE_OPACITY = 'absoluteOpacity', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', NAME = 'name', SET$1 = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
'xChange.konva',
'yChange.konva',
'scaleXChange.konva',
@ -3990,11 +3990,6 @@
Node.prototype.clone = function (obj) {
// instantiate new node
var attrs = Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
// filter black attrs
for (var i in CLONE_BLACK_LIST) {
var blockAttr = CLONE_BLACK_LIST[i];
delete attrs[blockAttr];
}
// apply attr overrides
for (key in obj) {
attrs[key] = obj[key];
@ -4345,10 +4340,10 @@
this._fire(eventType, evt);
// simulate event bubbling
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
(compareShape &&
compareShape.isAncestorOf &&
compareShape.isAncestorOf(this) &&
!compareShape.isAncestorOf(this.parent));
compareShape &&
compareShape.isAncestorOf &&
compareShape.isAncestorOf(this) &&
!compareShape.isAncestorOf(this.parent);
if (((evt && !evt.cancelBubble) || !evt) &&
this.parent &&
this.parent.isListening() &&

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1679,7 +1679,6 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
}
}
_getAbsoluteTransform(top?: Node) {
var at;
// we we need position relative to an ancestor, we will iterate for all
if (top) {
@ -1691,10 +1690,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
if (transformsEnabled === 'all') {
at.multiply(node.getTransform());
} else if (transformsEnabled === 'position') {
at.translate(
node.x() - node.offsetX(),
node.y() - node.offsetY()
);
at.translate(node.x() - node.offsetX(), node.y() - node.offsetY());
}
}, top);
return at;
@ -1710,10 +1706,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
if (transformsEnabled === 'all') {
at.multiply(this.getTransform());
} else if (transformsEnabled === 'position') {
at.translate(
this.x() - this.offsetX(),
this.y() - this.offsetY()
);
at.translate(this.x() - this.offsetX(), this.y() - this.offsetY());
}
return at;
}
@ -1844,11 +1837,6 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
len,
n,
listener;
// filter black attrs
for (var i in CLONE_BLACK_LIST) {
var blockAttr = CLONE_BLACK_LIST[i];
delete attrs[blockAttr];
}
// apply attr overrides
for (key in obj) {
attrs[key] = obj[key];
@ -2244,10 +2232,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
// simulate event bubbling
var stopBubble =
(eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
(compareShape &&
compareShape &&
compareShape.isAncestorOf &&
compareShape.isAncestorOf(this) &&
!compareShape.isAncestorOf(this.parent));
!compareShape.isAncestorOf(this.parent);
if (
((evt && !evt.cancelBubble) || !evt) &&
this.parent &&

View File

@ -560,7 +560,7 @@ suite('Node', function() {
assert.equal(rect.getShadowColor(), 'black');
assert.equal(clone.getShadowColor(), 'black');
assert.equal(clone.id() == '', true, 'do not clone id');
assert.equal(clone.id() === 'myRect', true, 'clone id');
clone.setShadowColor('green');