fix tree layout
This commit is contained in:
parent
fcd0f92259
commit
e792c85771
@ -231,7 +231,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
|
|||||||
name: 'preset',
|
name: 'preset',
|
||||||
|
|
||||||
positions: (e) => {
|
positions: (e) => {
|
||||||
|
console.log('POSITIIIIIIIONS')
|
||||||
const id = e.id()
|
const id = e.id()
|
||||||
const incomming = e.cy().edges(`[target="${id}"]`)
|
const incomming = e.cy().edges(`[target="${id}"]`)
|
||||||
const layer = 0
|
const layer = 0
|
||||||
@ -258,7 +258,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
|
|||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
const task = queue.pop()
|
const task = queue.pop()
|
||||||
if (task.children.length === 0) {
|
if (task.children.length === 0) {
|
||||||
task.parent.data('subtreeWidth', task.parent.height())
|
task.parent.data('subtreeWidth', 0)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const unprocessed = task?.children.filter(e => {
|
const unprocessed = task?.children.filter(e => {
|
||||||
@ -305,132 +305,11 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.querySelector("#root")?.addEventListener("mouseup", cleardragQuestionContentId);
|
document.querySelector("#root")?.addEventListener("mouseup", cleardragQuestionContentId);
|
||||||
const cy = cyRef.current;
|
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?.fit()
|
||||||
|
|
||||||
// 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?.layout().run()
|
//cy?.layout().run()
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user