!2837 修复: 图层UI的层级结构

pull/2839/MERGE
张子涵 3 months ago committed by 林三
parent b98352c97b
commit e85fcc6590

@ -151,6 +151,8 @@ export class LayerManager extends React.Component<{}, {}>
SelectLayerEntitys(selected); SelectLayerEntitys(selected);
}} }}
/> />
{
!selected.children &&
<MenuItem <MenuItem
icon="inheritance" icon="inheritance"
text="将选中实体置为该图层" text="将选中实体置为该图层"
@ -170,6 +172,7 @@ export class LayerManager extends React.Component<{}, {}>
} }
}} }}
/> />
}
</Menu>, </Menu>,
{ left: e.clientX, top: e.clientY }, { left: e.clientX, top: e.clientY },
() => this.setState({ isContextMenuOpen: false }), () => this.setState({ isContextMenuOpen: false }),
@ -219,9 +222,13 @@ export class LayerManager extends React.Component<{}, {}>
const line = dom.children[0] as HTMLDivElement; const line = dom.children[0] as HTMLDivElement;
const key = dom.getAttribute("data-key"); const key = dom.getAttribute("data-key");
const node = TreeAction.FindNode(layerStore.data, (node: ILayerNode) => node.name === key); const node = TreeAction.FindNode(layerStore.data, (node: ILayerNode) => node.name === key);
const isInSelf = data.name === key;
// 拖拽到文件夹里
if (e.clientY > rect.top && e.clientY < rect.bottom && node.children) if (e.clientY > rect.top && e.clientY < rect.bottom && node.children)
{ {
if (!data.children || !TreeAction.FindNode(data.children, (node: ILayerNode) => node.name === key)) const isInChildren = data.children && TreeAction.FindNode(node.children, (node: ILayerNode) => node.name === key);
// 确保不拖拽到自身及其子文件里
if (!isInSelf && !isInChildren)
{ {
const div = dom.children[1] as HTMLDivElement; const div = dom.children[1] as HTMLDivElement;
div.style.background = "rgba(150, 180, 210, 0.5)"; div.style.background = "rgba(150, 180, 210, 0.5)";
@ -230,13 +237,19 @@ export class LayerManager extends React.Component<{}, {}>
return; return;
} }
} }
// 拖拽到文件上方
if (e.clientY < boundary) if (e.clientY < boundary)
{
const isInChildren = data.children && TreeAction.FindNode(data.children, (node: ILayerNode) => node.name === key);
// 确保不拖拽到自身及其子文件里
if (!isInSelf && !isInChildren)
{ {
line.style.height = "5px"; line.style.height = "5px";
this._ToWhere = key; this._ToWhere = key;
return; return;
} }
} }
}
this._ToWhere = "--LAST"; this._ToWhere = "--LAST";
line.style.height = "5px"; line.style.height = "5px";
} }
@ -383,7 +396,7 @@ export class LayerManager extends React.Component<{}, {}>
</div> </div>
</div> </div>
} }
{data.expanded && data.children && this.CreateList(data.children)} {data.expanded && data.children && data.children.length > 0 && this.CreateList(data.children)}
</>); </>);
}) })
); );

Loading…
Cancel
Save