Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// initiate dragging a new link
else if (element instanceof PortModel) {
return;
}
// move the items (and potentially link points)
else {
this.transitionWithEvent(this.dragItems, event);
}
}
})
);
this.registerAction(
new Action({
type: InputType.MOUSE_UP,
fire: (event: ActionEvent) => {
const element = this.engine.getActionEventBus().getModelForEvent(event);
if (element instanceof PortModel) this.transitionWithEvent(this.createLink, event);
}
})
);
}
}
// if no link is given, just eject the state
if (!this.link) {
this.eject();
return;
}
this.link.setSelected(true);
this.link.setSourcePort(this.port);
this.engine.getModel().addLink(this.link);
this.port.reportPosition();
}
})
);
this.registerAction(
new Action({
type: InputType.MOUSE_UP,
fire: (event: ActionEvent) => {
const model = this.engine.getMouseElement(event.event);
// check to see if we connected to a new port
if (model instanceof PortModel) {
if (this.port.canLinkToPort(model)) {
this.link.setTargetPort(model);
model.reportPosition();
this.engine.repaintCanvas();
return;
}
}
if (!this.config.allowLooseLinks) {
this.link.remove();
this.engine.repaintCanvas();
constructor() {
super();
this.registerAction(
new Action({
type: InputType.MOUSE_UP,
fire: (event: ActionEvent) => {
const item = this.engine.getMouseElement(event.event);
if (item instanceof PortModel) {
_.forEach(this.initialPositions, position => {
if (position.item instanceof PointModel) {
const link = position.item.getParent() as LinkModel;
// only care about the last links
if (link.getLastPoint() !== position.item) {
return;
}
if (link.getSourcePort().canLinkToPort(item)) {
link.setTargetPort(item);
item.reportPosition();
this.engine.repaintCanvas();
}
constructor() {
super({ name: 'create-new-link' });
this.registerAction(
new Action({
type: InputType.MOUSE_UP,
fire: (actionEvent: ActionEvent) => {
const element = this.engine.getActionEventBus().getModelForEvent(actionEvent);
const {
event: { clientX, clientY }
} = actionEvent;
const ox = this.engine.getModel().getOffsetX();
const oy = this.engine.getModel().getOffsetY();
if (element instanceof PortModel && !this.sourcePort) {
this.sourcePort = element;
/* would be cool if link creating could be done somewhat like
const link = createLink({
sourcePort: this.sourcePort,
points: [{ x: clientX, y: clientY }, { x: clientX, y: clientY }]
})
stateChanged: event => {
if (event.newState instanceof AbstractDisplacementState) {
const deRegister = engine.getActionEventBus().registerAction(
new Action({
type: InputType.MOUSE_UP,
fire: () => {
this.calculateRoutingMatrix();
engine.repaintCanvas();
deRegister();
}
})
);
}
}
});