mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
allow cloning id
This commit is contained in:
parent
c3d01c3f0c
commit
6fbe48e583
@ -158,7 +158,7 @@
|
|||||||
"max-len": [2, 320, 4],
|
"max-len": [2, 320, 4],
|
||||||
"max-nested-callbacks": [2, 2],
|
"max-nested-callbacks": [2, 2],
|
||||||
"max-params": [1, 8],
|
"max-params": [1, 8],
|
||||||
"max-statements": [1, 60],
|
"max-statements": [1, 260],
|
||||||
"new-cap": 0,
|
"new-cap": 0,
|
||||||
"new-parens": 2,
|
"new-parens": 2,
|
||||||
"newline-after-var": 0,
|
"newline-after-var": 0,
|
||||||
|
17
konva.js
17
konva.js
@ -8,7 +8,7 @@
|
|||||||
* Konva JavaScript Framework v4.1.5
|
* Konva JavaScript Framework v4.1.5
|
||||||
* http://konvajs.org/
|
* http://konvajs.org/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Sun Feb 16 2020
|
* Date: Mon Feb 17 2020
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
@ -2515,7 +2515,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// CONSTANTS
|
// 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',
|
'xChange.konva',
|
||||||
'yChange.konva',
|
'yChange.konva',
|
||||||
'scaleXChange.konva',
|
'scaleXChange.konva',
|
||||||
@ -3990,11 +3990,6 @@
|
|||||||
Node.prototype.clone = function (obj) {
|
Node.prototype.clone = function (obj) {
|
||||||
// instantiate new node
|
// instantiate new node
|
||||||
var attrs = Util.cloneObject(this.attrs), key, allListeners, len, n, listener;
|
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
|
// apply attr overrides
|
||||||
for (key in obj) {
|
for (key in obj) {
|
||||||
attrs[key] = obj[key];
|
attrs[key] = obj[key];
|
||||||
@ -4345,10 +4340,10 @@
|
|||||||
this._fire(eventType, evt);
|
this._fire(eventType, evt);
|
||||||
// simulate event bubbling
|
// simulate event bubbling
|
||||||
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
|
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
|
||||||
(compareShape &&
|
compareShape &&
|
||||||
compareShape.isAncestorOf &&
|
compareShape.isAncestorOf &&
|
||||||
compareShape.isAncestorOf(this) &&
|
compareShape.isAncestorOf(this) &&
|
||||||
!compareShape.isAncestorOf(this.parent));
|
!compareShape.isAncestorOf(this.parent);
|
||||||
if (((evt && !evt.cancelBubble) || !evt) &&
|
if (((evt && !evt.cancelBubble) || !evt) &&
|
||||||
this.parent &&
|
this.parent &&
|
||||||
this.parent.isListening() &&
|
this.parent.isListening() &&
|
||||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
20
src/Node.ts
20
src/Node.ts
@ -1679,7 +1679,6 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_getAbsoluteTransform(top?: Node) {
|
_getAbsoluteTransform(top?: Node) {
|
||||||
|
|
||||||
var at;
|
var at;
|
||||||
// we we need position relative to an ancestor, we will iterate for all
|
// we we need position relative to an ancestor, we will iterate for all
|
||||||
if (top) {
|
if (top) {
|
||||||
@ -1691,10 +1690,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (transformsEnabled === 'all') {
|
if (transformsEnabled === 'all') {
|
||||||
at.multiply(node.getTransform());
|
at.multiply(node.getTransform());
|
||||||
} else if (transformsEnabled === 'position') {
|
} else if (transformsEnabled === 'position') {
|
||||||
at.translate(
|
at.translate(node.x() - node.offsetX(), node.y() - node.offsetY());
|
||||||
node.x() - node.offsetX(),
|
|
||||||
node.y() - node.offsetY()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, top);
|
}, top);
|
||||||
return at;
|
return at;
|
||||||
@ -1710,10 +1706,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (transformsEnabled === 'all') {
|
if (transformsEnabled === 'all') {
|
||||||
at.multiply(this.getTransform());
|
at.multiply(this.getTransform());
|
||||||
} else if (transformsEnabled === 'position') {
|
} else if (transformsEnabled === 'position') {
|
||||||
at.translate(
|
at.translate(this.x() - this.offsetX(), this.y() - this.offsetY());
|
||||||
this.x() - this.offsetX(),
|
|
||||||
this.y() - this.offsetY()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return at;
|
return at;
|
||||||
}
|
}
|
||||||
@ -1844,11 +1837,6 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
len,
|
len,
|
||||||
n,
|
n,
|
||||||
listener;
|
listener;
|
||||||
// filter black attrs
|
|
||||||
for (var i in CLONE_BLACK_LIST) {
|
|
||||||
var blockAttr = CLONE_BLACK_LIST[i];
|
|
||||||
delete attrs[blockAttr];
|
|
||||||
}
|
|
||||||
// apply attr overrides
|
// apply attr overrides
|
||||||
for (key in obj) {
|
for (key in obj) {
|
||||||
attrs[key] = obj[key];
|
attrs[key] = obj[key];
|
||||||
@ -2244,10 +2232,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
// simulate event bubbling
|
// simulate event bubbling
|
||||||
var stopBubble =
|
var stopBubble =
|
||||||
(eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
|
(eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
|
||||||
(compareShape &&
|
compareShape &&
|
||||||
compareShape.isAncestorOf &&
|
compareShape.isAncestorOf &&
|
||||||
compareShape.isAncestorOf(this) &&
|
compareShape.isAncestorOf(this) &&
|
||||||
!compareShape.isAncestorOf(this.parent));
|
!compareShape.isAncestorOf(this.parent);
|
||||||
if (
|
if (
|
||||||
((evt && !evt.cancelBubble) || !evt) &&
|
((evt && !evt.cancelBubble) || !evt) &&
|
||||||
this.parent &&
|
this.parent &&
|
||||||
|
@ -560,7 +560,7 @@ suite('Node', function() {
|
|||||||
assert.equal(rect.getShadowColor(), 'black');
|
assert.equal(rect.getShadowColor(), 'black');
|
||||||
assert.equal(clone.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');
|
clone.setShadowColor('green');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user