showing results for - "mouse wheel event angular for table"
Emely
07 Apr 2019
1import { Directive, ElementRef, HostListener} from "@angular/core";
2import { MyService } from "./my-service";
3@Directive({
4    selector: "[testDirec]"
5})
6export class Test {
7  private initPointX: number;
8  private initPointY: number;
9
10  constructor(private ele: ElementRef,
11        private serviceInstance: MyService) {
12    }
13
14    @HostListener('mousewheel', ['$event'])
15    scroll(event: MouseEvent) {
16        console.log("Entered mouse wheel");
17        let wheelDelta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
18        if(wheelDelta > 0) {
19          factor = 0.5;
20        }else {
21         factor = 2.0;
22        }
23
24        this.initPointX = event.PageX;
25        this.initPointY = event.PageY;   
26    } 
27
28}