Skip to content

Commit 109e9e6

Browse files
Merge pull request #14112 from guardian/rejig-article-swipe-in-dcar-interactives
2 parents 1fd3594 + bd01f1c commit 109e9e6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ import { useEffect } from 'react';
33
import { getInteractionClient } from '../lib/bridgetApi';
44

55
export const InteractivesDisableArticleSwipe = () => {
6-
useEffect(() => {
7-
void getInteractionClient()
6+
const onTouchStart = () => {
7+
getInteractionClient()
88
.disableArticleSwipe(true)
99
.catch((error) => {
10-
log('dotcom', 'disableArticleSwipe failed:', error);
10+
log('dotcom', 'disableArticleSwipe failed', error);
1111
});
12+
};
13+
useEffect(() => {
14+
document.addEventListener('touchstart', onTouchStart, {
15+
passive: true,
16+
});
17+
18+
return () => {
19+
document.removeEventListener('touchstart', onTouchStart);
20+
};
1221
}, []);
1322
return null;
1423
};

0 commit comments

Comments
 (0)