docs: Fix Tree drag demo

close #5837
This commit is contained in:
Wei Zhu 2017-05-02 16:45:32 +08:00
parent 38a7a87690
commit 2190f63959

View File

@ -61,6 +61,8 @@ class Demo extends React.Component {
console.log(info);
const dropKey = info.node.props.eventKey;
const dragKey = info.dragNode.props.eventKey;
const dropPos = info.node.props.pos.split('-');
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
// const dragNodesKeys = info.dragNodesKeys;
const loop = (data, key, callback) => {
data.forEach((item, index, arr) => {
@ -85,7 +87,11 @@ class Demo extends React.Component {
ar = arr;
i = index;
});
ar.splice(i, 0, dragObj);
if (dropPosition === -1) {
ar.splice(i, 0, dragObj);
} else {
ar.splice(i - 1, 0, dragObj);
}
} else {
loop(data, dropKey, (item) => {
item.children = item.children || [];