mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 04:42:02 +08:00
reset some changes
This commit is contained in:
parent
3a8f10687c
commit
0b58cf482b
@ -389,11 +389,10 @@
|
|||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
_setChildrenIndicesBetween: function(idx, maxIdx) {
|
_setChildrenIndices: function() {
|
||||||
var children = this.children;
|
this.children.each(function(child, n) {
|
||||||
for (; idx <= maxIdx; ++idx) {
|
child.index = n;
|
||||||
children[idx].index = idx;
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
drawScene: function(can, top, caching) {
|
drawScene: function(can, top, caching) {
|
||||||
var layer = this.getLayer(),
|
var layer = this.getLayer(),
|
||||||
@ -682,6 +681,5 @@
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Konva.Collection.mapMethods(Konva.Container);
|
Konva.Collection.mapMethods(Konva.Container);
|
||||||
})();
|
})();
|
||||||
|
30
src/Node.js
30
src/Node.js
@ -609,7 +609,7 @@
|
|||||||
|
|
||||||
if (parent && parent.children) {
|
if (parent && parent.children) {
|
||||||
parent.children.splice(this.index, 1);
|
parent.children.splice(this.index, 1);
|
||||||
parent._setChildrenIndicesBetween(this.index, parent.children.length - 1);
|
parent._setChildrenIndices();
|
||||||
delete this.parent;
|
delete this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,11 +1089,10 @@
|
|||||||
Konva.Util.warn('Node has no parent. moveToTop function is ignored.');
|
Konva.Util.warn('Node has no parent. moveToTop function is ignored.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var children = this.parent.children;
|
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
children.splice(index, 1);
|
this.parent.children.splice(index, 1);
|
||||||
children.push(this);
|
this.parent.children.push(this);
|
||||||
this.parent._setChildrenIndicesBetween(index, children.length - 1);
|
this.parent._setChildrenIndices();
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -1112,7 +1111,7 @@
|
|||||||
if (index < len - 1) {
|
if (index < len - 1) {
|
||||||
this.parent.children.splice(index, 1);
|
this.parent.children.splice(index, 1);
|
||||||
this.parent.children.splice(index + 1, 0, this);
|
this.parent.children.splice(index + 1, 0, this);
|
||||||
this.parent._setChildrenIndicesBetween(index, index + 1);
|
this.parent._setChildrenIndices();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1132,7 +1131,7 @@
|
|||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
this.parent.children.splice(index, 1);
|
this.parent.children.splice(index, 1);
|
||||||
this.parent.children.splice(index - 1, 0, this);
|
this.parent.children.splice(index - 1, 0, this);
|
||||||
this.parent._setChildrenIndicesBetween(index - 1, index);
|
this.parent._setChildrenIndices();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1154,7 +1153,7 @@
|
|||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
this.parent.children.splice(index, 1);
|
this.parent.children.splice(index, 1);
|
||||||
this.parent.children.unshift(this);
|
this.parent.children.unshift(this);
|
||||||
this.parent._setChildrenIndicesBetween(0, index);
|
this.parent._setChildrenIndices();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1171,19 +1170,10 @@
|
|||||||
Konva.Util.warn('Node has no parent. zIndex parameter is ignored.');
|
Konva.Util.warn('Node has no parent. zIndex parameter is ignored.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var children = this.parent.children;
|
|
||||||
zIndex = Math.max(0, Math.min(zIndex, children.length - 1));
|
|
||||||
|
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
if (zIndex !== index) {
|
this.parent.children.splice(index, 1);
|
||||||
children.splice(index, 1);
|
this.parent.children.splice(zIndex, 0, this);
|
||||||
children.splice(zIndex, 0, this);
|
this.parent._setChildrenIndices();
|
||||||
if (index < zIndex) {
|
|
||||||
this.parent._setChildrenIndicesBetween(index, zIndex);
|
|
||||||
} else {
|
|
||||||
this.parent._setChildrenIndicesBetween(zIndex, index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user