mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
smooth movement in parent-lines + std-lines + network-link-lines
This commit is contained in:
parent
9052a02c1b
commit
000f8d4b66
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -588,6 +588,9 @@ export default class VisualConsole {
|
|||||||
endY: endY
|
endY: endY
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update parents...
|
||||||
|
this.buildRelations(item.id, startX, startY);
|
||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
let debouncedLinePositionSave = debounce(
|
let debouncedLinePositionSave = debounce(
|
||||||
500,
|
500,
|
||||||
@ -868,7 +871,7 @@ export default class VisualConsole {
|
|||||||
/**
|
/**
|
||||||
* Create line elements which connect the elements with their parents.
|
* Create line elements which connect the elements with their parents.
|
||||||
*/
|
*/
|
||||||
public buildRelations(): void {
|
public buildRelations(itemId?: number, x?: number, y?: number): void {
|
||||||
// Clear relations.
|
// Clear relations.
|
||||||
this.clearRelations();
|
this.clearRelations();
|
||||||
// Add relations.
|
// Add relations.
|
||||||
@ -876,7 +879,22 @@ export default class VisualConsole {
|
|||||||
if (item.props.parentId !== null) {
|
if (item.props.parentId !== null) {
|
||||||
const parent = this.elementsById[item.props.parentId];
|
const parent = this.elementsById[item.props.parentId];
|
||||||
const child = this.elementsById[item.props.id];
|
const child = this.elementsById[item.props.id];
|
||||||
if (parent && child) this.addRelationLine(parent, child);
|
|
||||||
|
if (parent && child) {
|
||||||
|
if (itemId != undefined) {
|
||||||
|
if (item.props.parentId == itemId) {
|
||||||
|
// Update parent line position.
|
||||||
|
this.addRelationLine(parent, child, x, y);
|
||||||
|
} else if (item.props.id == itemId) {
|
||||||
|
// Update child line position.
|
||||||
|
this.addRelationLine(parent, child, undefined, undefined, x, y);
|
||||||
|
} else {
|
||||||
|
this.addRelationLine(parent, child);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.addRelationLine(parent, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1002,7 +1020,11 @@ export default class VisualConsole {
|
|||||||
*/
|
*/
|
||||||
private addRelationLine(
|
private addRelationLine(
|
||||||
parent: Item<ItemProps>,
|
parent: Item<ItemProps>,
|
||||||
child: Item<ItemProps>
|
child: Item<ItemProps>,
|
||||||
|
parentX?: number,
|
||||||
|
parentY?: number,
|
||||||
|
childX?: number,
|
||||||
|
childY?: number
|
||||||
): Line {
|
): Line {
|
||||||
const identifier = `${parent.props.id}|${child.props.id}`;
|
const identifier = `${parent.props.id}|${child.props.id}`;
|
||||||
if (this.relations[identifier] != null) {
|
if (this.relations[identifier] != null) {
|
||||||
@ -1010,8 +1032,25 @@ export default class VisualConsole {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the items center.
|
// Get the items center.
|
||||||
const { x: startX, y: startY } = this.getVisualCenter(parent.props, parent);
|
let { x: startX, y: startY } = this.getVisualCenter(parent.props, parent);
|
||||||
const { x: endX, y: endY } = this.getVisualCenter(child.props, child);
|
let { x: endX, y: endY } = this.getVisualCenter(child.props, child);
|
||||||
|
|
||||||
|
// Overwrite positions if needed (while moving it!).
|
||||||
|
if (parentX != null) {
|
||||||
|
startX = parentX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentY != null) {
|
||||||
|
startY = parentY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childX != null) {
|
||||||
|
endX = childX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (childY != null) {
|
||||||
|
endY = childY;
|
||||||
|
}
|
||||||
|
|
||||||
// Line inherits child element status.
|
// Line inherits child element status.
|
||||||
const line = new Line(
|
const line = new Line(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user