feat(appComponent): added mouse wheel scaling
This commit is contained in:
@@ -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">
|
||||||
|
|||||||
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user