lhwong
March 5, 2018, 3:58am
1
Hi,
I uploaded an existing bpmn file to the bpmn.io modeler. The arrows are shown behind the task node.
After moving the task node, the arrows snap to the edge of the task node like below.
I hope someone can provide me some guidelines on how to make change to automatically snap the arrow to the edge of node elements.
HI @lhwong ,
Could you reformulate your question? It’s not very clear what you want to achieve. Maybe sharing the file would help more illustrate your issue.
lhwong
March 5, 2018, 8:42am
3
Hi,
Open the attached bpmn file at https://demo.bpmn.io/
get-started.bpmn (10.0 KB)
You can see that the arrows point to the center of the task node and are behind of the of node element.
Drag the task node and release it. You can see the arrows snap to the edge of the node.
I am wondering if I can programmatically trigger certain action/event so that all of the arrows automatically snap to the edge upon the modeler shows the diagram
Regards,
Nick Wong
Hi @lhwong ,
It’s possible possible to do so upon importing the diagram.
To illustrate how to achieve it, let’s take the following example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<!-- required modeler styles -->
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@0.31.0/dist/assets/diagram-js.css">
<link rel="stylesheet" href="https://unpkg.com/bpmn-js@0.31.0/dist/assets/bpmn-font/css/bpmn.css">
<!-- modeler distro -->
<script src="https://unpkg.com/bpmn-js@0.31.0/dist/bpmn-modeler.development.js"></script>
<!-- needed for this example only -->
<script src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
<!-- example styles -->
<style>
html, body, #canvas {
height: 100%;
This file has been truncated. show original
Upon importing diagram, you can simply adjust the connections waypoints and fire the event ‘elements.changed’:
bpmnModeler.importXML(bpmnXML, function(err) {
...
var eventBus = bpmnModeler.get('eventBus');
var connectionDocking = bpmnModeler.get('connectionDocking');
var elementRegistry = bpmnModeler.get('elementRegistry');
var connections = elementRegistry.filter(function(e) {
return e.waypoints;
});
connections.forEach(function(connection) {
connection.waypoints = connectionDocking.getCroppedWaypoints(connection);
});
eventBus.fire('elements.changed', { elements: connections });
. ...
})
lhwong
March 6, 2018, 1:55am
5
Hi @siffogh ,
Cool. It works. Thank you very much.
Regards,
Nick Wong
is there any way to format the layout, like all the elements will be positioned at certain distance, arrows starting/edining posting on element will be border of the element, ?