📜  表格的鼠标滚轮事件角度 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:42.360000             🧑  作者: Mango

代码示例1
import { Directive, ElementRef, HostListener} from "@angular/core";
import { MyService } from "./my-service";
@Directive({
    selector: "[testDirec]"
})
export class Test {
  private initPointX: number;
  private initPointY: number;

  constructor(private ele: ElementRef,
        private serviceInstance: MyService) {
    }

    @HostListener('mousewheel', ['$event'])
    scroll(event: MouseEvent) {
        console.log("Entered mouse wheel");
        let wheelDelta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
        if(wheelDelta > 0) {
          factor = 0.5;
        }else {
         factor = 2.0;
        }

        this.initPointX = event.PageX;
        this.initPointY = event.PageY;   
    } 

}