adjusted resizing and env's
This commit is contained in:
@@ -30,6 +30,8 @@ import { NlsMathService } from './../services/math.service';
|
|||||||
import { NlsGuillocheDirective } from './../directives/guilloche.directive';
|
import { NlsGuillocheDirective } from './../directives/guilloche.directive';
|
||||||
import { NlsGraphService } from './../services/graph.service';
|
import { NlsGraphService } from './../services/graph.service';
|
||||||
|
|
||||||
|
const RESIZING_TIMEOUT = 800;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'nls-graphs',
|
selector: 'nls-graphs',
|
||||||
templateUrl: './graphs.component.html',
|
templateUrl: './graphs.component.html',
|
||||||
@@ -46,6 +48,7 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
private genShiftPoint: any | null;
|
private genShiftPoint: any | null;
|
||||||
private genLoadedAllGraphs: any | null;
|
private genLoadedAllGraphs: any | null;
|
||||||
private hash: string;
|
private hash: string;
|
||||||
|
private resizingWindow: any;
|
||||||
|
|
||||||
@Input() config: Config;
|
@Input() config: Config;
|
||||||
@Input() restoredHistory: any;
|
@Input() restoredHistory: any;
|
||||||
@@ -56,7 +59,13 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
|
|
||||||
@HostListener('window:resize', ['$event'])
|
@HostListener('window:resize', ['$event'])
|
||||||
onResize(event) {
|
onResize(event) {
|
||||||
this.canvasService.adjustToWindow();
|
clearTimeout(this.resizingWindow);
|
||||||
|
|
||||||
|
this.resizingWindow = setTimeout(() => {
|
||||||
|
this.canvas = this.adjustCanvas();
|
||||||
|
this.matrix = this.calcMatrix();
|
||||||
|
this.updateGraphs();
|
||||||
|
}, RESIZING_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -66,25 +75,27 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
private graphService: NlsGraphService
|
private graphService: NlsGraphService
|
||||||
) {
|
) {
|
||||||
this.genLoadedAllGraphs = this.countLoadedGraphs();
|
this.genLoadedAllGraphs = this.countLoadedGraphs();
|
||||||
|
this.resizingWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
this.config.autoHeight = true;
|
this.canvas = this.adjustCanvas();
|
||||||
this.updateCanvas();
|
|
||||||
this.matrix = this.calcMatrix();
|
this.matrix = this.calcMatrix();
|
||||||
|
|
||||||
if (changes.config) {
|
if (changes.config) {
|
||||||
// Config changes must not trigger any other events
|
|
||||||
this.updateGraphs();
|
this.updateGraphs();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.restoredHistory && this.restoredHistory.hash !== this.hash) {
|
if (this.restoredHistory && this.restoredHistory.hash !== this.hash) {
|
||||||
this.graphs = this.restoredHistory.graphs;
|
this.restoreGraph();
|
||||||
this.hash = this.restoredHistory.hash;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private restoreGraph() {
|
||||||
|
this.graphs = this.restoredHistory.graphs;
|
||||||
|
this.hash = this.restoredHistory.hash;
|
||||||
|
}
|
||||||
|
|
||||||
private saveHistory() {
|
private saveHistory() {
|
||||||
this.hash = this.historyService.hash(this.graphs);
|
this.hash = this.historyService.hash(this.graphs);
|
||||||
this.historyService.save(this.graphs, this.config);
|
this.historyService.save(this.graphs, this.config);
|
||||||
@@ -149,10 +160,11 @@ export class NlsGraphsComponent implements OnChanges {
|
|||||||
return (x === 'start') ? 'end' : 'start';
|
return (x === 'start') ? 'end' : 'start';
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateCanvas(): void {
|
private adjustCanvas(): void {
|
||||||
this.canvas = this.svgElementRef.nativeElement;
|
|
||||||
this.canvasService.set(this.canvas);
|
this.canvasService.set(this.canvas);
|
||||||
this.canvasService.adjustToWindow();
|
this.canvasService.adjustToWindow();
|
||||||
|
|
||||||
|
return this.svgElementRef.nativeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
private calcMatrix() {
|
private calcMatrix() {
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ export class AppComponent implements OnInit {
|
|||||||
moment.locale('de');
|
moment.locale('de');
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
colors: {
|
...env.config,
|
||||||
primary: env.guilloche.colors.primary,
|
|
||||||
secondary: env.guilloche.colors.secondary,
|
|
||||||
},
|
|
||||||
...env.formDefaults
|
...env.formDefaults
|
||||||
};
|
};
|
||||||
this.configForm = ConfigForm;
|
this.configForm = ConfigForm;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const environment = {
|
|||||||
production: true,
|
production: true,
|
||||||
debug: false,
|
debug: false,
|
||||||
animation: false,
|
animation: false,
|
||||||
guilloche: {
|
config: {
|
||||||
colors: {
|
colors: {
|
||||||
secondary: '#F8485E',
|
secondary: '#F8485E',
|
||||||
primary: '#5CC0C7'
|
primary: '#5CC0C7'
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ export const environment = {
|
|||||||
production: false,
|
production: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
animation: false,
|
animation: false,
|
||||||
guilloche: {
|
config: {
|
||||||
colors: {
|
colors: {
|
||||||
primary: '#129490',
|
primary: '#129490',
|
||||||
secondary: '#CE1483'
|
secondary: '#CE1483'
|
||||||
}
|
},
|
||||||
|
autoSize: true
|
||||||
},
|
},
|
||||||
formDefaults: {
|
formDefaults: {
|
||||||
width: 1,
|
width: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user