google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.34k stars 593 forks source link

[WebView] Unable to scroll the WebView when hosted inside an HorizontalPager #1687

Closed leinardi closed 11 months ago

leinardi commented 1 year ago

Description It is almost impossible to scroll vertically a page if the WebView is hosted inside an HorizontalPager. The reason is that, unless you go pixel perfect vertically with your scroll gesture, the WebView loses control of the scrolling and the pager one kicks in.

Steps to reproduce Run attached sample project and try to reach the bottom of the page.

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun WebViewPager() {
    val pagerState = rememberPagerState(0) { 5 }
    HorizontalPager(
        state = pagerState,
    ) { page ->
        val webViewState = rememberWebViewState("https://duckduckgo.com/?q=${page.inc()}")
        WebView(
            state = webViewState,
            modifier = Modifier.fillMaxSize(),
            onCreated = { it.settings.javaScriptEnabled = true },
        )
    }
}

Expected behavior When a vertical scroll gesture is initiated from the WebView, it should continue even if the Y coordinates change slightly.

Additional context accompanist = "0.31.6-rc" androidx-compose = "1.5.0-beta03" androidx-compose-compiler = "1.5.0"

bentrengrove commented 11 months ago

Unfortunately Accompanist WebView has been deprecated and won't be supported going forwards. I am closing this issue. We recommend you fork the implemenation here and customise it to your needs. For more information please see our update blog