black list for clone function. fix #583

This commit is contained in:
Лаврёнов Антон
2014-03-02 21:51:35 +08:00
parent 53ac9329de
commit e5db9115a0
2 changed files with 13 additions and 3 deletions

View File

@@ -22,6 +22,7 @@
TRANSFORM = 'transform',
UPPER_STAGE = 'Stage',
VISIBLE = 'visible',
CLONE_BLACK_LIST = ['id'],
TRANSFORM_CHANGE_STR = [
'xChange.kinetic',
@@ -36,6 +37,7 @@
'transformsEnabledChange.kinetic'
].join(SPACE);
Kinetic.Util.addMethods(Kinetic.Node, {
_init: function(config) {
var that = this;
@@ -1181,9 +1183,14 @@
clone: function(obj) {
// instantiate new node
var className = this.getClassName(),
node = new Kinetic[className](this.attrs),
attrs = 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];
}
var node = new Kinetic[className](attrs);
// copy over listeners
for(key in this.eventListeners) {
allListeners = this.eventListeners[key];