-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
015865d
commit 7e7e4f5
Showing
8 changed files
with
107 additions
and
8 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
projects/f-examples/connections/auto-snap/auto-snap.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<f-flow fDraggable (fLoaded)="onLoaded()" (fCreateConnection)="addConnection($event)"> | ||
<f-canvas> | ||
<f-connection-for-create></f-connection-for-create> | ||
<f-snap-connection [fSnapThreshold]="100"></f-snap-connection> | ||
|
||
@for (connection of connections; track connection.inputId) { | ||
<f-connection [fReassignDisabled]="true" | ||
[fOutputId]="connection.outputId" [fInputId]="connection.inputId"> | ||
</f-connection> | ||
} | ||
|
||
<div fNode fDragHandle [fNodePosition]="{ x: 0, y: 24 }" fNodeOutput fOutputConnectableSide="right">drag me</div> | ||
<div fNode fDragHandle [fNodePosition]="{ x: 300, y: 24 }" fNodeInput fInputConnectableSide="left">to me</div> | ||
|
||
</f-canvas> | ||
</f-flow> | ||
<div class="toolbar"> | ||
<button class="f-button" (click)="onDeleteConnections()">Delete Connections</button> | ||
</div> |
14 changes: 14 additions & 0 deletions
14
projects/f-examples/connections/auto-snap/auto-snap.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@use "../../flow-common"; | ||
|
||
::ng-deep auto-snap { | ||
@include flow-common.connection; | ||
} | ||
|
||
.f-node { | ||
@include flow-common.node; | ||
} | ||
|
||
.toolbar { | ||
@include flow-common.toolbar; | ||
} | ||
|
42 changes: 42 additions & 0 deletions
42
projects/f-examples/connections/auto-snap/auto-snap.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewChild } from '@angular/core'; | ||
import { FCanvasComponent, FCreateConnectionEvent, FFlowModule } from '@foblex/flow'; | ||
|
||
@Component({ | ||
selector: 'auto-snap', | ||
styleUrls: [ './auto-snap.component.scss' ], | ||
templateUrl: './auto-snap.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
FFlowModule | ||
] | ||
}) | ||
export class AutoSnapComponent { | ||
|
||
@ViewChild(FCanvasComponent, { static: true }) | ||
public fCanvas!: FCanvasComponent; | ||
|
||
public connections: { outputId: string, inputId: string }[] = []; | ||
|
||
constructor( | ||
private changeDetectorRef: ChangeDetectorRef | ||
) { | ||
} | ||
|
||
public addConnection(event: FCreateConnectionEvent): void { | ||
if(!event.fInputId) { | ||
return; | ||
} | ||
this.connections.push({ outputId: event.fOutputId, inputId: event.fInputId }); | ||
this.changeDetectorRef.detectChanges(); | ||
} | ||
|
||
public onLoaded(): void { | ||
this.fCanvas.resetScaleAndCenter(false); | ||
} | ||
|
||
public onDeleteConnections(): void { | ||
this.connections = []; | ||
this.changeDetectorRef.detectChanges(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto Snap | ||
|
||
## Description | ||
|
||
This guide shows how to create connections when a connection is dropped near a connector, providing a comprehensive approach to building interactive flow-based diagrams. | ||
|
||
## Example | ||
|
||
::: ng-component <auto-snap></auto-snap> [height]="600" | ||
[component.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/auto-snap/auto-snap.component.html | ||
[component.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/auto-snap/auto-snap.component.ts | ||
[component.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/connections/auto-snap/auto-snap.component.scss | ||
[common.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/_flow-common.scss | ||
::: | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<router-outlet></router-outlet> | ||
<!--<button class="take-screenshot" (click)="takeScreenshot()">--> | ||
<!-- Take Screenshot--> | ||
<!--</button>--> | ||
<button class="take-screenshot" (click)="takeScreenshot()"> | ||
Take Screenshot | ||
</button> |