Skip to content

Commit

Permalink
fix: multitouch
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-deriv committed Aug 12, 2024
1 parent 7c4f81f commit f37f9ec
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/store/ChartAdapterStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export default class ChartAdapterStore {
touchValues: {
deltaXTotal?: number;
deltaYTotal?: number;
multiTouch?: boolean;
x?: number;
y?: number;
} = {
multiTouch: false,
deltaXTotal: 0,
deltaYTotal: 0,
x: 0,
Expand Down Expand Up @@ -245,12 +247,16 @@ export default class ChartAdapterStore {
onTouch(e: TouchEvent) {
// Prevent vertical scroll on the chart for touch devices by forcing scroll on a scrollable parent of the chart:
const chartNode = this.mainStore.chart.chartNode;
if (
chartNode &&
this.scrollableChartParent &&
!this.mainStore.state.isVerticalScrollEnabled &&
e.changedTouches.length === 1
) {
if (chartNode && this.scrollableChartParent && !this.mainStore.state.isVerticalScrollEnabled) {
if (this.touchValues.multiTouch) {
if (e.type === 'touchend') this.touchValues.multiTouch = false;
return;
}
if (e.touches.length > 1) {
this.touchValues.multiTouch = true;
return;
}

const { pageX, pageY } = e.changedTouches[0];

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

0 comments on commit f37f9ec

Please sign in to comment.