mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-19 15:23:51 +00:00
Merge pull request #523 from GNS3/WebUI-starts-at-0,0-position
Option to center view added
This commit is contained in:
@ -115,6 +115,12 @@
|
|||||||
<mat-icon>settings_applications</mat-icon>
|
<mat-icon>settings_applications</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-toolbar-row>
|
</mat-toolbar-row>
|
||||||
|
|
||||||
|
<mat-toolbar-row *ngIf="!readonly">
|
||||||
|
<button matTooltip="Center view" mat-icon-button (click)="centerView()">
|
||||||
|
<mat-icon>center_focus_strong</mat-icon>
|
||||||
|
</button>
|
||||||
|
</mat-toolbar-row>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation, ElementRef } from '@angular/core';
|
||||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||||
|
|
||||||
import { Observable, Subject, Subscription, from } from 'rxjs';
|
import { Observable, Subject, Subscription, from } from 'rxjs';
|
||||||
@ -394,6 +394,17 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public centerView() {
|
||||||
|
if (this.project) {
|
||||||
|
let scrollX: number = (this.project.scene_width - document.documentElement.clientWidth) > 0 ? (this.project.scene_width - document.documentElement.clientWidth)/2 : 0;
|
||||||
|
let scrollY: number = (this.project.scene_height - document.documentElement.clientHeight) > 0 ? (this.project.scene_height - document.documentElement.clientHeight)/2 : 0;
|
||||||
|
|
||||||
|
window.scrollTo(scrollX, scrollY);
|
||||||
|
} else {
|
||||||
|
this.toasterService.error('Please wait until all components are loaded.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public onDrawingSaved() {
|
public onDrawingSaved() {
|
||||||
this.projectMapMenuComponent.resetDrawToolChoice();
|
this.projectMapMenuComponent.resetDrawToolChoice();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user