From fd4db4438dbcc04c0a6d9194946220e85c39ae8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=BF=E7=8F=82?= Date: Mon, 31 Jul 2023 17:47:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(scroll):=20=E4=BF=AE=E5=A4=8D=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E6=BB=9A=E5=8A=A8=E6=97=B6=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=8F=B0=E6=8A=A5=E9=94=99=20close=20#2266?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/src/facet/base-facet.ts | 10 ++++++++-- packages/s2-core/src/sheet-type/spread-sheet.ts | 1 - packages/s2-react/playground/index.html | 3 +-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/s2-core/src/facet/base-facet.ts b/packages/s2-core/src/facet/base-facet.ts index c665ff7a11..4a4724026b 100644 --- a/packages/s2-core/src/facet/base-facet.ts +++ b/packages/s2-core/src/facet/base-facet.ts @@ -199,6 +199,7 @@ export abstract class BaseFacet { const originEvent = ev.event; const { deltaX, deltaY, x, y } = ev; // The coordinates of mobile and pc are three times different + // TODO: 手指快速往上滚动时, deltaY 有时会为负数, 导致向下滚动时然后回弹, 看起来就像表格在抖动, 需要判断滚动方向, next 版本未复现 this.onWheel({ ...originEvent, deltaX, @@ -930,9 +931,14 @@ export abstract class BaseFacet { }; private stopScrollChaining = (event: WheelEvent) => { - event?.preventDefault?.(); + if (event?.cancelable) { + event?.preventDefault?.(); + } // 移动端的 prevent 存在于 originalEvent上 - (event as unknown as GraphEvent)?.originalEvent?.preventDefault?.(); + const mobileEvent = (event as unknown as GraphEvent)?.originalEvent; + if (mobileEvent?.cancelable) { + mobileEvent?.preventDefault?.(); + } }; onWheel = (event: WheelEvent) => { diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts index 7fff55540e..2381339e2d 100644 --- a/packages/s2-core/src/sheet-type/spread-sheet.ts +++ b/packages/s2-core/src/sheet-type/spread-sheet.ts @@ -6,7 +6,6 @@ import { get, includes, isEmpty, - isEqual, isFunction, isString, memoize, diff --git a/packages/s2-react/playground/index.html b/packages/s2-react/playground/index.html index 13576bda2a..901bfef23c 100644 --- a/packages/s2-react/playground/index.html +++ b/packages/s2-react/playground/index.html @@ -8,6 +8,5 @@
- - \ No newline at end of file +