Skip to content

Commit

Permalink
fix(scroll): 修复移动端滚动时控制台报错 close #2266
Browse files Browse the repository at this point in the history
  • Loading branch information
卿珂 committed Jul 31, 2023
1 parent 2845c11 commit fd4db44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 8 additions & 2 deletions packages/s2-core/src/facet/base-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand Down
1 change: 0 additions & 1 deletion packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
get,
includes,
isEmpty,
isEqual,
isFunction,
isString,
memoize,
Expand Down
3 changes: 1 addition & 2 deletions packages/s2-react/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>

</body>
</html>
</html>

0 comments on commit fd4db44

Please sign in to comment.