fix tree layout

This commit is contained in:
skeris 2023-12-02 14:52:33 +03:00
parent fcd0f92259
commit e792c85771

@ -231,7 +231,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
name: 'preset',
positions: (e) => {
console.log('POSITIIIIIIIONS')
const id = e.id()
const incomming = e.cy().edges(`[target="${id}"]`)
const layer = 0
@ -258,7 +258,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
while (queue.length) {
const task = queue.pop()
if (task.children.length === 0) {
task.parent.data('subtreeWidth', task.parent.height())
task.parent.data('subtreeWidth', 0)
continue
}
const unprocessed = task?.children.filter(e => {
@ -305,132 +305,11 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
useEffect(() => {
document.querySelector("#root")?.addEventListener("mouseup", cleardragQuestionContentId);
const cy = cyRef.current;
const eles = cy?.add(storeToNodes(questions))
console.log('PETTY', storeToNodes(questions), eles.length)
const elecs = eles.layout(lyopts).run()
cy?.add(storeToNodes(questions))
// cy?.add(storeToNodes(questions))
//cy?.on('add',()=>cy.fit())
// const elecs = cy?.add(
// [
// {
// "data": {
// "id": "1",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 3",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2 4",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2 6",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 3 5",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 3 7",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2 6 9867874",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2 6 7398789",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "id": "1 2 6 9484789",
// "label": "нет имени"
// }
// },
// {
// "data": {
// "source": "1",
// "target": "1 2"
// }
// },
// {
// "data": {
// "source": "1",
// "target": "1 3"
// }
// },
// {
// "data": {
// "source": "1 2",
// "target": "1 2 4"
// }
// },
// {
// "data": {
// "source": "1 2",
// "target": "1 2 6"
// }
// },
// {
// "data": {
// "source": "1 3",
// "target": "1 3 5"
// }
// },
// {
// "data": {
// "source": "1 3",
// "target": "1 3 7"
// }
// },
// {
// "data": {
// "source": "1 2 6",
// "target": "1 2 6 9867874"
// }
// },
// {
// "data": {
// "source": "1 2 6",
// "target": "1 2 6 7398789"
// }
// },
// {
// "data": {
// "source": "1 2 6",
// "target": "1 2 6 9484789"
// }
// }
// ]
// ).layout(lyopts)
// elecs.run()
//cy?.fit()
cy?.fit()
//cy?.layout().run()
return () => {