Skip to content

Commit 044452f

Browse files
docs: Added zoom example
1 parent 82c57cd commit 044452f

5 files changed

Lines changed: 65 additions & 24 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<f-flow fDraggable (fLoaded)="onLoaded()">
2+
<f-canvas [fZoom]="isZoomEnabled">
3+
<f-connection fOutputId="output1" fInputId="input1" fBehavior="floating"></f-connection>
4+
<div fNode [fNodePosition]="{ x: 24, y: 24 }" fNodeOutput fOutputId="output1" fDragHandle>I'm a node</div>
5+
<div fNode [fNodePosition]="{ x: 244, y: 24 }" fNodeInput fInputId="input1" fDragHandle>I'm a node</div>
6+
</f-canvas>
7+
</f-flow>
8+
<div class="toolbar">
9+
<button class="f-button" (click)="onZoomIn()">Zoom In</button>
10+
<button class="f-button" (click)="onZoomOut()">Zoom Out</button>
11+
<f-checkbox [checked]="isZoomEnabled" (change)="onZoomOnMouseWheelChanged($event)">Zoom on mouse wheel</f-checkbox>
12+
</div>
13+

projects/f-examples/zoom-example/zoom-example.component.scss renamed to projects/f-examples/extensions/zoom-example/zoom-example.component.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@use "../flow-common";
1+
@use "../../flow-common";
22

33
::ng-deep zoom-example {
44
@include flow-common.connection;
@@ -7,3 +7,7 @@
77
.f-node {
88
@include flow-common.node;
99
}
10+
11+
.toolbar {
12+
@include flow-common.toolbar;
13+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewChild } from '@angular/core';
2+
import { FCanvasComponent, FCreateConnectionEvent, FFlowModule, FZoomDirective } from '@foblex/flow';
3+
import { FCheckboxComponent } from '@foblex/f-docs';
4+
5+
@Component({
6+
selector: 'zoom-example',
7+
styleUrls: [ './zoom-example.component.scss' ],
8+
templateUrl: './zoom-example.component.html',
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
standalone: true,
11+
imports: [
12+
FFlowModule,
13+
FCheckboxComponent
14+
]
15+
})
16+
export class ZoomExampleComponent {
17+
18+
@ViewChild(FCanvasComponent, { static: true })
19+
public fCanvas!: FCanvasComponent;
20+
21+
@ViewChild(FZoomDirective, { static: true })
22+
public fZoom!: FZoomDirective;
23+
24+
public isZoomEnabled: boolean = true;
25+
26+
constructor(
27+
private changeDetectorRef: ChangeDetectorRef
28+
) {
29+
}
30+
31+
public onLoaded(): void {
32+
this.fCanvas.resetScaleAndCenter(false);
33+
}
34+
35+
public onZoomIn(): void {
36+
this.fZoom.zoomIn();
37+
}
38+
39+
public onZoomOut(): void {
40+
this.fZoom.zoomOut();
41+
}
42+
43+
public onZoomOnMouseWheelChanged(checked: boolean): void {
44+
this.isZoomEnabled = checked;
45+
this.changeDetectorRef.detectChanges();
46+
}
47+
}

projects/f-examples/zoom-example/zoom-example.component.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

projects/f-examples/zoom-example/zoom-example.component.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)