Skip to content

Commit f37f9ec

Browse files
committed
fix: multitouch
1 parent 7c4f81f commit f37f9ec

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/store/ChartAdapterStore.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ export default class ChartAdapterStore {
4343
touchValues: {
4444
deltaXTotal?: number;
4545
deltaYTotal?: number;
46+
multiTouch?: boolean;
4647
x?: number;
4748
y?: number;
4849
} = {
50+
multiTouch: false,
4951
deltaXTotal: 0,
5052
deltaYTotal: 0,
5153
x: 0,
@@ -245,12 +247,16 @@ export default class ChartAdapterStore {
245247
onTouch(e: TouchEvent) {
246248
// Prevent vertical scroll on the chart for touch devices by forcing scroll on a scrollable parent of the chart:
247249
const chartNode = this.mainStore.chart.chartNode;
248-
if (
249-
chartNode &&
250-
this.scrollableChartParent &&
251-
!this.mainStore.state.isVerticalScrollEnabled &&
252-
e.changedTouches.length === 1
253-
) {
250+
if (chartNode && this.scrollableChartParent && !this.mainStore.state.isVerticalScrollEnabled) {
251+
if (this.touchValues.multiTouch) {
252+
if (e.type === 'touchend') this.touchValues.multiTouch = false;
253+
return;
254+
}
255+
if (e.touches.length > 1) {
256+
this.touchValues.multiTouch = true;
257+
return;
258+
}
259+
254260
const { pageX, pageY } = e.changedTouches[0];
255261

256262
if (['touchmove', 'touchend'].includes(e.type)) {

0 commit comments

Comments
 (0)