Skip to content

Commit

Permalink
fix: 修复移动端禁用外部容器滚动不生效 (#3097)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 authored Feb 10, 2025
1 parent 3278aef commit ba93684
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/s2-core/src/facet/base-facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
FederatedWheelEvent,
Group,
Rect,
type FederatedPointerEvent as GraphEvent,
type FederatedPointerEvent,
} from '@antv/g';
import { interpolateArray } from 'd3-interpolate';
import { timer, type Timer } from 'd3-timer';
Expand Down Expand Up @@ -1445,8 +1445,9 @@ export abstract class BaseFacet {
event?.preventDefault?.();
}

// 移动端的 prevent 存在于 originalEvent 上
const mobileEvent = (event as unknown as GraphEvent)?.originalEvent;
// 使用 G 对应的原生 TouchEvent,以达到移动端禁用外部容器滚动的效果
const mobileEvent =
(event as unknown as FederatedPointerEvent)?.nativeEvent || event;

if (mobileEvent?.cancelable) {
mobileEvent?.preventDefault?.();
Expand Down

0 comments on commit ba93684

Please sign in to comment.