Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group nodes container resize issue #886

Open
sukhwinderkaur1389 opened this issue Jul 30, 2024 · 5 comments
Open

Group nodes container resize issue #886

sukhwinderkaur1389 opened this issue Jul 30, 2024 · 5 comments

Comments

@sukhwinderkaur1389
Copy link

Hi,

While resizing the node, attached line not moving with it. As following

image

@sukhwinderkaur1389
Copy link
Author

@jerosoler - Please update on it.

@jerosoler
Copy link
Owner

The default library does not allow node groups or resizing.

In any case, please provide an example where you can reproduce the problem.

@sukhwinderkaur1389
Copy link
Author

This is code for group node

editor.on("mouseMove", ({x,y}) => {
if(editor.node_selected && editor.drag && editor.node_selected.classList[1] !== "GROUP") {
const eles = document.elementsFromPoint(x,y);
const ele = eles.filter( ele => ele.classList[1] === "GROUP");
if(ele.length > 0) {
dragElementHover = ele[0];
dragElementHover.classList.add("hover-drop");
} else {
if(dragElementHover != null) {
dragElementHover.classList.remove("hover-drop");
dragElementHover = null;
}
}
} else if(editor.node_selected && editor.drag && editor.node_selected.classList[1] == "GROUP") {
const dragNode = editor.node_selected.id.slice(5);
const dragNodeInfo = editor.getNodeFromId(dragNode);
const elements = dragNodeInfo.data.elements;
elements.forEach(eleN => {

        const node = document.getElementById(`node-${eleN}`);
        var xnew = (last_x - x) * editor.precanvas.clientWidth / (editor.precanvas.clientWidth * editor.zoom);
        var ynew = (last_y - y) * editor.precanvas.clientHeight / (editor.precanvas.clientHeight * editor.zoom);

        node.style.top = (node.offsetTop - ynew) + "px";
        node.style.left = (node.offsetLeft - xnew) + "px";

        editor.drawflow.drawflow[editor.module].data[eleN].pos_x = (node.offsetLeft - xnew);
        editor.drawflow.drawflow[editor.module].data[eleN].pos_y = (node.offsetTop - ynew);
        editor.updateConnectionNodes(`node-${eleN}`);

    });
}
last_x = x;
last_y = y;

})

editor.on("nodeMoved", (id) => {
const dragNode = id;
if(dragElementHover !== null) {
const dropNode = dragElementHover.id.slice(5);
if(dragNode !== dropNode) {
removeOfGroupNode(dragNode);
dragElementHover.classList.remove("hover-drop");
const dropNodeInfo = editor.getNodeFromId(dropNode);
const dropNodeInfoData = dropNodeInfo.data;
if(dropNodeInfoData.elements.indexOf(dragNode) === -1) {
dropNodeInfoData.elements.push(dragNode);
editor.updateNodeDataFromId(dropNode, dropNodeInfoData);
}
}
dragElementHover = null;
} else {
removeOfGroupNode(dragNode);
}
})

function removeOfGroupNode(id) { console.log('group',id);
Object.keys(editor.drawflow.drawflow[editor.module].data).forEach(ele => {
var className = editor.drawflow.drawflow[editor.module].data[ele].class;
if(className.includes("GROUP")) {
const findIndex = editor.drawflow.drawflow[editor.module].data[ele].data.elements.indexOf(id);
if(findIndex !== -1) {
editor.drawflow.drawflow[editor.module].data[ele].data.elements.splice(findIndex, 1);
}
}
})
}

@sukhwinderkaur1389
Copy link
Author

The default library does not allow node groups or resizing.

In any case, please provide an example where you can reproduce the problem.

Above is the code

@jerosoler
Copy link
Owner

The code above is not a reproducible example.
Please create a codepen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants