2
0

feat(appComponent): added mouse wheel scaling

This commit is contained in:
2018-05-23 17:29:23 +02:00
parent d7672535d0
commit a58e1d0ed6
2 changed files with 26 additions and 2 deletions

View File

@@ -89,7 +89,7 @@
<label class="form-control-label"> <label class="form-control-label">
Skalierung Skalierung
</label> </label>
<input type="number" class="form-control" formControlName="scale" min="0" max="1" step="0.1"> <input type="number" class="form-control" formControlName="scale" min="0" max="1" step="0.01">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-control-label"> <label class="form-control-label">

View File

@@ -1,5 +1,5 @@
import { ConfigForm } from './forms/config.form'; import { ConfigForm } from './forms/config.form';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, HostListener } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { environment as env } from '../environments/environment'; import { environment as env } from '../environments/environment';
@@ -17,6 +17,30 @@ export class AppComponent implements OnInit {
public config: any | null; public config: any | null;
public configForm: FormGroup; public configForm: FormGroup;
@HostListener('mousewheel', ['$event'])
private onWheelUp(event) {
const delta = Math.sign(event.deltaY);
const step = 0.01;
if (delta > 0) {
if (this.config.scale === 1 - step) {
return;
}
this.config.scale += step;
} else {
if (this.config.scale === step) {
return;
}
this.config.scale -= step;
}
this.config.scale = Math.round(this.config.scale * 100) / 100;
this.configForm.reset({...this.config});
this.updateGraphs();
}
constructor() { constructor() {
this.canvasParam = { this.canvasParam = {
colors: { colors: {