admin管理员组文章数量:1393060
When trying to redraw, the position of the node/group doesn't update on the jsPlumb 6.81.0.
The event is fired correctly, but the updateNode or Group dooes not do anything on the position.
May I know what we need to do to make it work correctly ?
surface?.bind(EVENT_NODE_MOVE, (event: VertexMovedParams<unknown>) => {
const group = toolkit?.getGroup(`group-${event.vertex.id}`);
console.log(group);
if (group) {
toolkit?.updateGroup(group, {
left: event.pos.x - 8,
top: event.pos.y + 217,
});
//surface.repaint(group, true);
}
});
I'm trying to make move my node programmatically with the bind event.
When trying to redraw, the position of the node/group doesn't update on the jsPlumb 6.81.0.
The event is fired correctly, but the updateNode or Group dooes not do anything on the position.
May I know what we need to do to make it work correctly ?
surface?.bind(EVENT_NODE_MOVE, (event: VertexMovedParams<unknown>) => {
const group = toolkit?.getGroup(`group-${event.vertex.id}`);
console.log(group);
if (group) {
toolkit?.updateGroup(group, {
left: event.pos.x - 8,
top: event.pos.y + 217,
});
//surface.repaint(group, true);
}
});
I'm trying to make move my node programmatically with the bind event.
Share Improve this question edited Mar 12 at 10:11 ahuemmer 2,05913 gold badges27 silver badges36 bronze badges asked Mar 11 at 20:10 Arthur KleinArthur Klein 11 Answer
Reset to default 0To programmatically update the position of a node or group in jsPlumb, you must update both the toolkit model and the DOM element's position, as jsPlumb does not automatically sync rendering with model updates.
surface?.bind(EVENT_NODE_MOVE, (event: VertexMovedParams<unknown>) => {
const group = toolkit?.getGroup(`group-${event.vertex.id}`);
console.log(group);
if (group) {
toolkit?.updateGroup(group, {
left: event.pos.x - 8,
top: event.pos.y + 217,
});
// Update the DOM element's position programmatically
const domElement = surface?.getRenderedGroup(group); // Get the rendered DOM element
if (domElement) {
domElement.style.left = `${event.pos.x - 8}px`;
domElement.style.top = `${event.pos.y + 217}px`;
}
surface.repaint(group, true);
}
});
本文标签: angularHow to programmatically update position of a nodegroupStack Overflow
版权声明:本文标题:angular - How to programmatically update position of a nodegroup? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744772981a2624454.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论