now it updates only when moved or created, not when bending points are corrected

This commit is contained in:
Gregory Bednov 2025-01-13 18:57:22 +03:00 committed by GitHub
commit fb8d37548d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,7 @@
import { connectPoints } from 'diagram-js/lib/layout/ManhattanLayout';
function ManhattanLayoutPlugin(eventBus, modeling) {
eventBus.on('connection.changed', (event) => {
var connection = event.element;
export function updateWaypointsByManhattan (connection, modeling) {
if (connection.source && connection.target) {
const x0 = connection.source.x + connection.source.width / 2;
const x1 = connection.target.x + connection.target.width / 2;
@ -22,11 +19,31 @@ function ManhattanLayoutPlugin(eventBus, modeling) {
modeling.updateWaypoints(connection, waypoints)
}
}
}
function ManhattanLayoutPlugin(eventBus, modeling) {
eventBus.on('connection.added', (event) => {
var connection = event.element;
updateWaypointsByManhattan(connection, modeling);
});
eventBus.on("shape.move.end", (event) => {
console.log(event.shape);
if (event.shape.incoming) {
event.shape.incoming.forEach(element => {
updateWaypointsByManhattan(element, modeling);
});
}
if (event.shape.outgoing) {
event.shape.outgoing.forEach(element => {
updateWaypointsByManhattan(element, modeling);
});
}
});
}
// export as module
export default {
__init__: [ 'manhattanLayoutPlugin' ],
manhattanLayoutPlugin: [ 'type', ManhattanLayoutPlugin ]
};
};