@@ -38,7 +38,7 @@ import { Node, ClusterNode, CompoundNode } from '../models/node.model';
3838import { Graph } from '../models/graph.model' ;
3939import { id } from '../utils/id' ;
4040import { PanningAxis } from '../enums/panning.enum' ;
41- import { MiniMapPosition } from '../enums/mini-map-position.enum' ;
41+ import { MiniMapPosition , DefaultMiniMapMargin , MiniMapMargin } from '../enums/mini-map-position.enum' ;
4242import { throttleable } from '../utils/throttle' ;
4343import { ColorHelper } from '../utils/color.helper' ;
4444import { ViewDimensions , calculateViewDimensions } from '../utils/view-dimensions.helper' ;
@@ -139,6 +139,7 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
139139 readonly miniMapMaxWidth = input < number > ( 100 ) ;
140140 readonly miniMapMaxHeight = input < number > ( undefined ) ;
141141 readonly miniMapPosition = input < MiniMapPosition > ( MiniMapPosition . UpperRight ) ;
142+ readonly miniMapMargin = input < MiniMapMargin > ( DefaultMiniMapMargin ) ;
142143 readonly view = input < [ number , number ] > ( undefined ) ;
143144 readonly scheme = input < any > ( 'cool' ) ;
144145 readonly customColors = input < any > ( undefined ) ;
@@ -229,6 +230,7 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
229230 height : number ;
230231 resizeSubscription : any ;
231232 visibilityObserver : VisibilityObserver ;
233+ private waitForGraphDims : ReturnType < typeof setInterval > ;
232234 private destroy$ = new Subject < void > ( ) ;
233235
234236 /** Latest requestAnimationFrame id per edge for imperative path morphing (cancel on relayout / drag). */
@@ -375,6 +377,13 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
375377 } ) ;
376378 }
377379
380+ this . waitForGraphDims = setInterval ( ( ) => {
381+ if ( this . hasDims ( ) ) {
382+ clearInterval ( this . waitForGraphDims ) ;
383+ this . drawComplete . emit ( ) ;
384+ }
385+ } , 1000 ) ;
386+
378387 this . minimapClipPathId = `minimapClip${ id ( ) } ` ;
379388 this . stateChange . emit ( { state : NgxGraphStates . Subscribe } ) ;
380389 }
@@ -432,6 +441,9 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
432441 this . visibilityObserver . visible . unsubscribe ( ) ;
433442 this . visibilityObserver . destroy ( ) ;
434443 }
444+ if ( this . waitForGraphDims ) {
445+ clearInterval ( this . waitForGraphDims ) ;
446+ }
435447 this . destroy$ . next ( ) ;
436448 this . destroy$ . complete ( ) ;
437449 }
@@ -1480,20 +1492,32 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
14801492 getMinimapTransform ( ) : string {
14811493 switch ( this . miniMapPosition ( ) ) {
14821494 case MiniMapPosition . UpperLeft : {
1483- return '' ;
1495+ return 'translate(' + this . miniMapMargin ( ) . left + ',' + this . miniMapMargin ( ) . top + ') ';
14841496 }
14851497 case MiniMapPosition . UpperRight : {
1486- return 'translate(' + ( this . dims . width - this . graphDims . width / this . minimapScaleCoefficient ) + ',' + 0 + ')' ;
1498+ return (
1499+ 'translate(' +
1500+ ( this . dims . width - this . graphDims . width / this . minimapScaleCoefficient - this . miniMapMargin ( ) . right ) +
1501+ ',' +
1502+ this . miniMapMargin ( ) . top +
1503+ ')'
1504+ ) ;
14871505 }
14881506 case MiniMapPosition . LowerLeft : {
1489- return 'translate(' + 0 + ',' + ( this . dims . height - this . graphDims . height / this . minimapScaleCoefficient ) + ')' ;
1507+ return (
1508+ 'translate(' +
1509+ this . miniMapMargin ( ) . left +
1510+ ',' +
1511+ ( this . dims . height - this . graphDims . height / this . minimapScaleCoefficient - this . miniMapMargin ( ) . bottom ) +
1512+ ')'
1513+ ) ;
14901514 }
14911515 case MiniMapPosition . LowerRight : {
14921516 return (
14931517 'translate(' +
1494- ( this . dims . width - this . graphDims . width / this . minimapScaleCoefficient ) +
1518+ ( this . dims . width - this . graphDims . width / this . minimapScaleCoefficient - this . miniMapMargin ( ) . right ) +
14951519 ',' +
1496- ( this . dims . height - this . graphDims . height / this . minimapScaleCoefficient ) +
1520+ ( this . dims . height - this . graphDims . height / this . minimapScaleCoefficient - this . miniMapMargin ( ) . bottom ) +
14971521 ')'
14981522 ) ;
14991523 }
@@ -1797,8 +1821,6 @@ export class GraphComponent implements OnInit, OnChanges, OnDestroy, AfterViewIn
17971821 return ;
17981822 }
17991823 this . stateChange . emit ( { state : NgxGraphStates . Output } ) ;
1800- // TODO: The 'emit' function requires a mandatory void argument
1801- this . drawComplete . emit ( ) ;
18021824 }
18031825
18041826 private cancelEdgePathAnimation ( edgeId : string ) : void {
0 commit comments