reset some changes

This commit is contained in:
Anton Lavrenov 2018-08-03 09:48:35 +07:00
parent 3a8f10687c
commit 0b58cf482b
2 changed files with 14 additions and 26 deletions

View File

@ -389,11 +389,10 @@
return arr;
},
_setChildrenIndicesBetween: function(idx, maxIdx) {
var children = this.children;
for (; idx <= maxIdx; ++idx) {
children[idx].index = idx;
}
_setChildrenIndices: function() {
this.children.each(function(child, n) {
child.index = n;
});
},
drawScene: function(can, top, caching) {
var layer = this.getLayer(),
@ -682,6 +681,5 @@
* });
*/
Konva.Collection.mapMethods(Konva.Container);
})();

View File

@ -609,7 +609,7 @@
if (parent && parent.children) {
parent.children.splice(this.index, 1);
parent._setChildrenIndicesBetween(this.index, parent.children.length - 1);
parent._setChildrenIndices();
delete this.parent;
}
@ -1089,11 +1089,10 @@
Konva.Util.warn('Node has no parent. moveToTop function is ignored.');
return false;
}
var children = this.parent.children;
var index = this.index;
children.splice(index, 1);
children.push(this);
this.parent._setChildrenIndicesBetween(index, children.length - 1);
this.parent.children.splice(index, 1);
this.parent.children.push(this);
this.parent._setChildrenIndices();
return true;
},
/**
@ -1112,7 +1111,7 @@
if (index < len - 1) {
this.parent.children.splice(index, 1);
this.parent.children.splice(index + 1, 0, this);
this.parent._setChildrenIndicesBetween(index, index + 1);
this.parent._setChildrenIndices();
return true;
}
return false;
@ -1132,7 +1131,7 @@
if (index > 0) {
this.parent.children.splice(index, 1);
this.parent.children.splice(index - 1, 0, this);
this.parent._setChildrenIndicesBetween(index - 1, index);
this.parent._setChildrenIndices();
return true;
}
return false;
@ -1154,7 +1153,7 @@
if (index > 0) {
this.parent.children.splice(index, 1);
this.parent.children.unshift(this);
this.parent._setChildrenIndicesBetween(0, index);
this.parent._setChildrenIndices();
return true;
}
return false;
@ -1171,19 +1170,10 @@
Konva.Util.warn('Node has no parent. zIndex parameter is ignored.');
return false;
}
var children = this.parent.children;
zIndex = Math.max(0, Math.min(zIndex, children.length - 1));
var index = this.index;
if (zIndex !== index) {
children.splice(index, 1);
children.splice(zIndex, 0, this);
if (index < zIndex) {
this.parent._setChildrenIndicesBetween(index, zIndex);
} else {
this.parent._setChildrenIndicesBetween(zIndex, index);
}
}
this.parent.children.splice(index, 1);
this.parent.children.splice(zIndex, 0, this);
this.parent._setChildrenIndices();
return this;
},
/**