@@ -10,9 +10,11 @@ import {
10
10
ElementRef ,
11
11
NgZone ,
12
12
ChangeDetectionStrategy ,
13
+ Input ,
14
+ OnInit ,
13
15
} from '@angular/core' ;
14
16
import { startWith } from 'rxjs' ;
15
- import { Arrangements2 as Arrangements } from './arrangements' ;
17
+ import { Arrangements2 as Arrangements } from './plugins/ arrangements' ;
16
18
import { Connections } from './connections' ;
17
19
import { FlowChildComponent } from './flow-child.component' ;
18
20
import { FlowService } from './flow.service' ;
@@ -22,9 +24,9 @@ import {
22
24
FlowDirection ,
23
25
DotOptions ,
24
26
ArrowPathFn ,
27
+ FlowConfig ,
25
28
} from './flow-interface' ;
26
29
import { blendCorners , flowPath , bezierPath , blendCorners1 } from './svg' ;
27
- import { FitToWindow } from './fit-to-window' ;
28
30
29
31
const BASE_SCALE_AMOUNT = 0.05 ;
30
32
@@ -125,10 +127,11 @@ const BASE_SCALE_AMOUNT = 0.05;
125
127
] ,
126
128
} )
127
129
export class FlowComponent
128
- implements AfterContentInit , AfterViewInit , OnDestroy
130
+ implements OnInit , AfterContentInit , AfterViewInit , OnDestroy
129
131
{
130
- @ContentChildren ( FlowChildComponent ) children : QueryList < FlowChildComponent > =
131
- new QueryList ( ) ;
132
+ @Input ( ) config : FlowConfig = new FlowConfig ( ) ;
133
+ @ContentChildren ( FlowChildComponent ) children =
134
+ new QueryList < FlowChildComponent > ( ) ;
132
135
133
136
// @ViewChildren ('arrowPaths') arrowPaths: QueryList<ElementRef<SVGPathElement>>;
134
137
@ViewChild ( 'zoomContainer' ) zoomContainer : ElementRef < HTMLDivElement > ;
@@ -143,7 +146,9 @@ export class FlowComponent
143
146
public el : ElementRef < HTMLElement > ,
144
147
public flow : FlowService ,
145
148
private ngZone : NgZone
146
- ) {
149
+ ) { }
150
+
151
+ ngOnInit ( ) : void {
147
152
this . flow . zoomContainer = this . el . nativeElement ;
148
153
this . flow . arrowsChange . subscribe ( ( e ) => this . updateArrows ( e ) ) ;
149
154
this . ngZone . runOutsideAngular ( ( ) => {
@@ -166,6 +171,7 @@ export class FlowComponent
166
171
167
172
ngAfterViewInit ( ) : void {
168
173
this . createArrows ( ) ;
174
+ this . config . Plugins . forEach ( ( x ) => x . afterInit ?.( this ) ) ;
169
175
}
170
176
171
177
ngAfterContentInit ( ) {
@@ -281,22 +287,7 @@ export class FlowComponent
281
287
return { scale : newScale , panX : newPanX , panY : newPanY } ;
282
288
}
283
289
284
- fitToWindow ( ) {
285
- const ftw = new FitToWindow (
286
- this . list ,
287
- this . zoomContainer . nativeElement . getBoundingClientRect ( ) ,
288
- this . flow . scale ,
289
- this . flow . panX ,
290
- this . flow . panY
291
- ) ;
292
- const { scale, panX, panY } = ftw . fitToWindow ( ) ;
293
- this . flow . scale = scale ;
294
- this . flow . panX = panX ;
295
- this . flow . panY = panY ;
296
- this . updateZoomContainer ( ) ;
297
- }
298
-
299
- private updateZoomContainer ( ) {
290
+ updateZoomContainer ( ) {
300
291
this . zoomContainer . nativeElement . style . transform = `translate3d(${ this . flow . panX } px, ${ this . flow . panY } px, 0) scale(${ this . flow . scale } )` ;
301
292
}
302
293
0 commit comments