mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 04:57:51 +00:00
Canvas resizes on window size change, fixes #54
This commit is contained in:
parent
e563dd6381
commit
6afdeb51a8
@ -1,5 +1,5 @@
|
||||
import {
|
||||
Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChange
|
||||
Component, ElementRef, HostListener, Input, OnChanges, OnDestroy, OnInit, SimpleChange
|
||||
} from '@angular/core';
|
||||
import { D3, D3Service } from 'd3-ng2-service';
|
||||
import {select, Selection} from 'd3-selection';
|
||||
@ -106,7 +106,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
});
|
||||
|
||||
this.graphLayout.draw(this.svg, this.graphContext);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,13 +116,6 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
private changeLayout() {
|
||||
if (this.graphContext != null) {
|
||||
this.svg
|
||||
.attr('width', this.graphContext.getSize().width)
|
||||
.attr('height', this.graphContext.getSize().height);
|
||||
}
|
||||
|
||||
|
||||
if (this.windowFullSize) {
|
||||
if (this.parentNativeElement != null) {
|
||||
this.graphContext.setSize(this.getSize());
|
||||
@ -133,6 +125,14 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
if (this.graphContext != null) {
|
||||
this.svg
|
||||
.attr('width', this.graphContext.getSize().width)
|
||||
.attr('height', this.graphContext.getSize().height);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.graphLayout.setNodes(this.nodes);
|
||||
this.graphLayout.setLinks(this.links);
|
||||
this.graphLayout.setDrawings(this.drawings);
|
||||
@ -174,4 +174,9 @@ export class MapComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.onLinksChange(null);
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event) {
|
||||
this.changeLayout();
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,4 @@ export class Context {
|
||||
public setSize(size: Size): void {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public getRoot() {
|
||||
return this.root;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user