How to use the @projectstorm/react-canvas-core.InputType.MOUSE_UP function in @projectstorm/react-canvas-core

To help you get started, we’ve selected a few @projectstorm/react-canvas-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github projectstorm / react-diagrams / packages / diagrams-demo-gallery / demos / demo-alternative-linking / DefaultState.ts View on Github external
}
					// 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);
				}
			})
		);
	}
}
github projectstorm / react-diagrams / packages / react-diagrams-core / src / states / DragNewLinkState.ts View on Github external
// 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();
github projectstorm / react-diagrams / packages / react-diagrams-core / src / states / DragDiagramItemsState.ts View on Github external
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();
								}
github projectstorm / react-diagrams / packages / diagrams-demo-gallery / demos / demo-alternative-linking / CreateLinkState.ts View on Github external
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 }]
                        })
github projectstorm / react-diagrams / packages / react-diagrams-routing / src / link / PathFindingLinkFactory.tsx View on Github external
stateChanged: event => {
				if (event.newState instanceof AbstractDisplacementState) {
					const deRegister = engine.getActionEventBus().registerAction(
						new Action({
							type: InputType.MOUSE_UP,
							fire: () => {
								this.calculateRoutingMatrix();
								engine.repaintCanvas();
								deRegister();
							}
						})
					);
				}
			}
		});