now it updates only when moved or created, not when bending points are corrected
This commit is contained in:
parent
3751b8ddb0
commit
fb8d37548d
1 changed files with 23 additions and 6 deletions
|
|
@ -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 ]
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue