-
Notifications
You must be signed in to change notification settings - Fork 34
Rejig interactives disableArticleSwipe implementation
#14112
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,21 @@ import { useEffect } from 'react'; | |
| import { getInteractionClient } from '../lib/bridgetApi'; | ||
|
|
||
| export const InteractivesDisableArticleSwipe = () => { | ||
| useEffect(() => { | ||
| void getInteractionClient() | ||
| const onTouchStart = () => { | ||
| getInteractionClient() | ||
| .disableArticleSwipe(true) | ||
| .catch((error) => { | ||
| log('dotcom', 'disableArticleSwipe failed:', error); | ||
| log('dotcom', 'disableArticleSwipe failed', error); | ||
| }); | ||
| }; | ||
| useEffect(() => { | ||
| document.addEventListener('touchstart', onTouchStart, { | ||
| passive: true, | ||
| }); | ||
|
|
||
| return () => { | ||
| document.removeEventListener('touchstart', onTouchStart); | ||
| }; | ||
| }, []); | ||
| return null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also wondering if you tested the number of events that are being fired. I think this might cause too many events being fired and might have performance side effect. I'm not sure though, it needs testing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't, it's tricky to get things in the emulators pre-beta, though it shouldn't fire any more than carousels or key events on live blogs should it? A blanket on/off switch would be ideal but my understanding is that's not how the Android implementation works
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will setup my android simulator now and will test this. Will let you know 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! |
||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if you want the article to always have the article swipe disabled? If that's the case, it might be better to not ever set this to
true, what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's a great shout! Yes, we always want interactives to have the article swipe disabled, have removed
touchendevents with bd01f1c