Skip to content

Commit

Permalink
docs: Added zoom example
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheihuzarevich committed Oct 6, 2024
1 parent 82c57cd commit 044452f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<f-flow fDraggable (fLoaded)="onLoaded()">
<f-canvas [fZoom]="isZoomEnabled">
<f-connection fOutputId="output1" fInputId="input1" fBehavior="floating"></f-connection>
<div fNode [fNodePosition]="{ x: 24, y: 24 }" fNodeOutput fOutputId="output1" fDragHandle>I'm a node</div>
<div fNode [fNodePosition]="{ x: 244, y: 24 }" fNodeInput fInputId="input1" fDragHandle>I'm a node</div>
</f-canvas>
</f-flow>
<div class="toolbar">
<button class="f-button" (click)="onZoomIn()">Zoom In</button>
<button class="f-button" (click)="onZoomOut()">Zoom Out</button>
<f-checkbox [checked]="isZoomEnabled" (change)="onZoomOnMouseWheelChanged($event)">Zoom on mouse wheel</f-checkbox>
</div>

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../flow-common";
@use "../../flow-common";

::ng-deep zoom-example {
@include flow-common.connection;
Expand All @@ -7,3 +7,7 @@
.f-node {
@include flow-common.node;
}

.toolbar {
@include flow-common.toolbar;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewChild } from '@angular/core';
import { FCanvasComponent, FCreateConnectionEvent, FFlowModule, FZoomDirective } from '@foblex/flow';
import { FCheckboxComponent } from '@foblex/f-docs';

@Component({
selector: 'zoom-example',
styleUrls: [ './zoom-example.component.scss' ],
templateUrl: './zoom-example.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
FFlowModule,
FCheckboxComponent
]
})
export class ZoomExampleComponent {

@ViewChild(FCanvasComponent, { static: true })
public fCanvas!: FCanvasComponent;

@ViewChild(FZoomDirective, { static: true })
public fZoom!: FZoomDirective;

public isZoomEnabled: boolean = true;

constructor(
private changeDetectorRef: ChangeDetectorRef
) {
}

public onLoaded(): void {
this.fCanvas.resetScaleAndCenter(false);
}

public onZoomIn(): void {
this.fZoom.zoomIn();
}

public onZoomOut(): void {
this.fZoom.zoomOut();
}

public onZoomOnMouseWheelChanged(checked: boolean): void {
this.isZoomEnabled = checked;
this.changeDetectorRef.detectChanges();
}
}
7 changes: 0 additions & 7 deletions projects/f-examples/zoom-example/zoom-example.component.html

This file was deleted.

16 changes: 0 additions & 16 deletions projects/f-examples/zoom-example/zoom-example.component.ts

This file was deleted.

0 comments on commit 044452f

Please sign in to comment.