From 86fd69d6bf4c1974755a47ed07c9686557d84bc6 Mon Sep 17 00:00:00 2001 From: Original-Recipe-Chicken Date: Tue, 31 Dec 2024 11:50:15 +0800 Subject: [PATCH] fix: Remove mouse wheel event optimization --- .../src/core/toolOperation/basicToolOperation.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/lb-annotation/src/core/toolOperation/basicToolOperation.ts b/packages/lb-annotation/src/core/toolOperation/basicToolOperation.ts index 4c2ca7e1..53d4345e 100644 --- a/packages/lb-annotation/src/core/toolOperation/basicToolOperation.ts +++ b/packages/lb-annotation/src/core/toolOperation/basicToolOperation.ts @@ -245,7 +245,6 @@ class BasicToolOperation extends EventListener { this.onKeyDown = this.onKeyDown.bind(this); this.onKeyUp = this.onKeyUp.bind(this); this.onWheel = this.onWheel.bind(this); - this.optimizeWheel = this.optimizeWheel.bind(this); this.onLeftDblClick = this.onLeftDblClick.bind(this); this.onRightDblClick = this.onRightDblClick.bind(this); this.onClick = this.onClick.bind(this); @@ -869,7 +868,7 @@ class BasicToolOperation extends EventListener { this.container.addEventListener('mouseleave', this.onMouseLeave); this.container.addEventListener('click', this.onClick); - this.container.addEventListener('wheel', this.optimizeWheel); + this.container.addEventListener('wheel', this.onWheel); document.addEventListener('keydown', this.onKeyDown); document.addEventListener('keyup', this.onKeyUp); @@ -881,7 +880,7 @@ class BasicToolOperation extends EventListener { this.container.removeEventListener('mousemove', this.optimizeMouseMove); this.container.removeEventListener('mouseup', this.onMouseUp); this.container.removeEventListener('mouseleave', this.onMouseLeave); - this.container.removeEventListener('wheel', this.optimizeWheel); + this.container.removeEventListener('wheel', this.onWheel); this.container.removeEventListener('click', this.onClick); document.removeEventListener('keydown', this.onKeyDown); document.removeEventListener('keyup', this.onKeyUp); @@ -908,8 +907,6 @@ class BasicToolOperation extends EventListener { private moveAnimationFrameId: number | null = null; - private onWheelAnimationFrameId: number | null = null; - public optimizeMouseMove(event: MouseEvent): boolean | void { if (this.moveAnimationFrameId) return; @@ -919,15 +916,6 @@ class BasicToolOperation extends EventListener { }); } - public optimizeWheel(event: MouseEvent): boolean | void { - if (this.onWheelAnimationFrameId) return; - - this.onWheelAnimationFrameId = requestAnimationFrame(() => { - this.onWheel(event); - this.onWheelAnimationFrameId = null; - }); - } - public onMouseDown(e: MouseEvent): void | boolean { // e.stopPropagation(); if (!this.canvas || this.isImgError) {