Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scroll): 修复移动端快速滚动时控制台报错 close #2266 #2302

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -201,6 +201,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 版本未复现
lijinke666 marked this conversation as resolved.
Show resolved Hide resolved
this.onWheel({
...originEvent,
deltaX,
Expand Down Expand Up @@ -927,9 +928,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
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>
Loading