Skip to content

Commit 8fb4399

Browse files
docs: Added drag-handle example
1 parent 6f2bd7b commit 8fb4399

10 files changed

Lines changed: 127 additions & 4 deletions

File tree

projects/f-examples/_flow-common.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
}
115115

116116
@mixin node {
117-
width: 100px;
118117
padding: 4px;
119118
color: var(--node-color);
120119
text-align: center;
File renamed without changes.

projects/f-examples/custom-nodes/custom-nodes.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { BrowserService } from '@foblex/platform';
1313

1414
@Component({
1515
selector: 'custom-nodes',
16-
styleUrls: [ './custom-nodes.component.scss', './_mdc-controls.scss' ],
16+
styleUrls: [ './custom-nodes.component.scss', '../_mdc-controls.scss' ],
1717
templateUrl: './custom-nodes.component.html',
1818
changeDetection: ChangeDetectionStrategy.OnPush,
1919
standalone: true,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<f-flow fDraggable (fLoaded)="onLoaded()">
2+
<f-canvas fZoom>
3+
<div fNode fDragHandle
4+
[fNodePosition]="{ x: 24, y: 24 }">
5+
Node is the drag handle
6+
</div>
7+
8+
<div fNode
9+
[fNodePosition]="{ x: 164, y: 84 }" class="drag-handle-inside">
10+
<span fDragHandle class="f-icon f-drag-handle-icon"></span>
11+
Only the icon is the drag handle
12+
</div>
13+
14+
<div fNode
15+
[fNodePosition]="{ x: 304, y: 24 }" class="drag-handle-outside">
16+
<div fDragHandle>
17+
<span class="f-icon f-drag-handle-icon"></span>
18+
</div>
19+
Only the icon is the drag handle
20+
</div>
21+
22+
<div fNode
23+
[fNodePosition]="{ x: 150, y: 170 }">
24+
Only the image is the drag handle
25+
<div fDragHandle>
26+
<img src="https://material.angular.io/assets/img/examples/shiba2.jpg">
27+
</div>
28+
</div>
29+
</f-canvas>
30+
</f-flow>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@use "../flow-common";
2+
3+
::ng-deep drag-handle {
4+
@include flow-common.connection;
5+
}
6+
7+
.f-node {
8+
@include flow-common.node;
9+
cursor: default;
10+
11+
img {
12+
display: block;
13+
pointer-events: none;
14+
width: 150px;
15+
}
16+
}
17+
18+
.f-drag-handle {
19+
width: fit-content;
20+
cursor: move;
21+
}
22+
23+
.drag-handle-inside {
24+
display: flex;
25+
justify-content: flex-start;
26+
align-items: center;
27+
gap: 6px;
28+
}
29+
30+
.f-icon {
31+
display: block;
32+
width: 28px;
33+
min-width: 28px;
34+
height: 28px;
35+
mask-repeat: no-repeat;
36+
}
37+
38+
.drag-handle-outside {
39+
.f-drag-handle {
40+
background-color: var(--node-background-color);
41+
position: absolute;
42+
top: 50%;
43+
transform: translateY(-50%);
44+
left: -50px;
45+
padding: 4px;
46+
border: 0.5px solid var(--node-border-color);
47+
border-radius: var(--node-border-radius);
48+
}
49+
}
50+
51+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core';
2+
import {
3+
FCanvasComponent,
4+
FFlowModule
5+
} from '@foblex/flow';
6+
import { PointExtensions } from '@foblex/2d';
7+
8+
@Component({
9+
selector: 'drag-handle',
10+
styleUrls: [ './drag-handle.component.scss' ],
11+
templateUrl: './drag-handle.component.html',
12+
changeDetection: ChangeDetectionStrategy.OnPush,
13+
standalone: true,
14+
imports: [
15+
FFlowModule,
16+
]
17+
})
18+
export class DragHandleComponent {
19+
20+
@ViewChild(FCanvasComponent, { static: true })
21+
public fCanvas!: FCanvasComponent;
22+
23+
public onLoaded(): void {
24+
this.fCanvas.fitToScreen(PointExtensions.initialize(100, 100), false);
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Drag Handle
2+
3+
## Description
4+
5+
This example showcases how to add a [DragHandle](./docs/f-drag-handle-directive) for nodes, allowing users to move them easily within Angular and Foblex Flow.
6+
7+
## Example
8+
9+
::: ng-component <drag-handle></drag-handle> [height]="600"
10+
[component.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/drag-handle/drag-handle.component.html
11+
[component.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/drag-handle/drag-handle.component.ts
12+
[component.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/drag-handle/drag-handle.component.scss
13+
[common.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/projects/f-examples/_flow-common.scss
14+
:::
15+
16+

public/docs/en/examples/environment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function createEnvironment(): IDocsEnvironment {
3636
},
3737
components: [
3838
{ tag: 'custom-nodes', component: import('../../../../projects/f-examples/custom-nodes/custom-nodes.component') },
39+
{ tag: 'drag-handle', component: import('../../../../projects/f-examples/drag-handle/drag-handle.component') },
3940
{ tag: 'draggable-flow', component: import('../../../../projects/f-guides-examples/draggable-flow/draggable-flow.component') },
4041
{ tag: 'vp-flow', component: import('../../../../projects/f-pro-examples/visual-programming/components/flow/vp-flow.component') },
4142
{ tag: 'db-management-flow', component: import('../../../../projects/f-pro-examples/db-management-example/components/flow/db-management-flow.component') },
@@ -76,8 +77,8 @@ function introductionGroup(): INavigationGroup {
7677
{
7778
link: 'drag-handle',
7879
text: 'Drag Handle',
79-
image: './previews/examples/custom-nodes.light.png',
80-
image_dark: './previews/examples/custom-nodes.dark.png',
80+
image: './previews/examples/drag-handle.light.png',
81+
image_dark: './previews/examples/drag-handle.dark.png',
8182
description: 'This example showcases how to create a draggable handle for nodes, allowing users to move them easily within Angular and Foblex Flow.',
8283
},
8384
{
112 KB
Loading
112 KB
Loading

0 commit comments

Comments
 (0)