Skip to content
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

Disable browser's refresh on swipe down in mobile phones #332

Open
Ashish50514561 opened this issue Aug 20, 2023 · 2 comments
Open

Disable browser's refresh on swipe down in mobile phones #332

Ashish50514561 opened this issue Aug 20, 2023 · 2 comments

Comments

@Ashish50514561
Copy link

I have used e.Event.preventDefault and stop propagation inside my swipe handler still when i swipe down it refreshes the app along with executing the handler.

@isaachinman
Copy link

This issue has been open for a year. Has anyone figured out a solution? It seems calling preventDefault and stopPropagation on the SwipeEventData does not behave as expected.

@jmorettonf
Copy link

The browser refresh can be avoided by using the touch-action attribute set to none in the container which is swipeable. There is an example in the docs here: https://commerce.nearform.com/open-source/react-swipeable/docs/examples/feature-test-console

If you open this on your phone and mark this checkbox here:
chrome_76ER85YaP9

You can see that the browser refresh no longer happens when swiping down in the swipeable area.

Here is a code example of how you can apply this to your project:
https://github.com/FormidableLabs/react-swipeable/blob/main/examples/app/FeatureTestConsole/index.tsx

Check the swipeableStyle const. This is passed a prop which is applied to the inner div in the hook. This should work for mobile browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants