hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
408 stars 51 forks source link

Disabling "pull-to-refresh" when swiping in WebView with Swiper.js #277

Closed breadluvr closed 1 year ago

breadluvr commented 1 year ago

I have a WebView with Swiper.js to display sliders. However, I've faced an issue where sometimes swiping horizontally in the WebView triggers the "pull-to-refresh" feature provided by TurboSwipeRefreshLayout. I'd like to either disable the "pull-to-refresh" feature programmatically or prevent it from being triggered when swiping horizontally with Swiper.js.

I can't find any instructions or examples in the documentation on how to access or modify this behavior. Does anyone have any insight on how to properly access the TurboSwipeRefreshLayout to enable or disable the "pull-to-refresh" feature programmatically?

Thank you!

jayohms commented 1 year ago

You can easily disable the pull-to-refresh behavior on any particular screen using path configuration rules: https://github.com/hotwired/turbo-android/blob/main/docs/PATH-CONFIGURATION.md. See the pull_to_refresh_enabled flag.

Coordinating incoming js touch events with native control of pull-to-refresh dynamically would realistically lead to buggy behavior due to the async nature of WebView javascript <-> native communication.

breadluvr commented 1 year ago

I thought about coordinating JS touch events with the native pull-to-refresh, but as you pointed out, this could lead to buggy behavior. Your input confirms my concerns, and I appreciate the guidance. We'll try to adjust the swiper library to make swiping on the page smoother and see if it helps reduce unintended pull-to-refresh actions.