---
title: "Handle touch scrolling in Compose DocumentView"
canonical_url: "https://www.nutrient.io/guides/android/knowledge-base/document-view-inside-pager-scroll-handling/"
md_url: "https://www.nutrient.io/guides/android/knowledge-base/document-view-inside-pager-scroll-handling.md"
last_updated: "2026-05-15T19:10:04.908Z"
description: "Learn how to enable vertical and horizontal scrolling in a Compose DocumentView within a scrollable container effectively."
---

# Managing touch scrolling in Compose containers

Say you have a [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/index.html#DocumentView(android.net.Uri,androidx.compose.ui.Modifier)) inside a [Compose `HorizontalPager`](https://developer.android.com/develop/ui/compose/layouts/pager) and you want to be able to scroll the document vertically and scroll the pager horizontally. To do this, you need to tell the pager that the document is being scrolled and block the scroll on the pager.

Nutrient has an `onDocumentScroll` listener as part of the [`DocumentManager`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-manager/index.html)’s [`UiListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-ui-listener/index.html), which can be used to check if the document is being scrolled.

The code below shows our PDF user interface (UI) composable, which contains our [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/index.html#DocumentView(android.net.Uri,androidx.compose.ui.Modifier)). This is where we pass the `DocumentView` our scrolling state lambda in which we can tell the parent pager whether or not we’re scrolling:

```kotlin

@Composable
fun PdfUI(pdf: File, scroll: (ScrollState) -> Unit = {}) {... // Various scaffolding code, etc. See other examples for details.

    DocumentView(
        documentState,
        modifier = Modifier.padding(it),
        documentManager = getDefaultDocumentManager(
            // Implement the `onDocumentScroll` listener and call the passed lambda.
            uiListener = DefaultListeners.uiListeners(
                onDocumentScroll = {
                    scroll.invoke(it)
                }
            )
        )
    )
}

```

And here’s `MainScreen`, which contains `HorizontalPager`:

```kotlin

@Composable
fun MainScreen(navigateTo: (String) -> Unit) {... // Various scaffolding code. etc. See other examples for details.

    Box() {
        val localPdfs = listOfLocalPdfFiles()
        val state = rememberPagerState(pageCount =  { 3 })
        if (state.isScrollInProgress) {
            pagerScroll = true
        }
        // Enable/disable pager scrolling using the `pagerScroll` flag.
        HorizontalPager(
            modifier = Modifier.fillMaxSize(),
            userScrollEnabled = pagerScroll,
            state = state
        ) { page ->
            when (page) {
                in 0 until 3 -> PdfUI(
                    pdf = File(localPdfs.first().path),
                ) { scroll ->
                    // Set the `pagerScroll` flag based on the scroll state of the `DocumentView`.
                    pagerScroll = scroll == ScrollState.IDLE
                }
            }
        )
        }
    }
}

```
---

## Related pages

- [Allow Clear Text Traffic](/guides/android/knowledge-base/allow-clear-text-traffic.md)
- [Compose Qna](/guides/android/knowledge-base/compose-qna.md)
- [Disabling Annotation Rotation](/guides/android/knowledge-base/disabling-annotation-rotation.md)
- [Custom Print Functionality](/guides/android/knowledge-base/custom-print-functionality.md)
- [Deleting Pages From A Pdf](/guides/android/knowledge-base/deleting-pages-from-a-pdf.md)
- [Easily disable share and print options in Android](/guides/android/knowledge-base/disable-share-documentinfo-print.md)
- [Getting All Digital Signatures](/guides/android/knowledge-base/getting-all-digital-signatures.md)
- [Change page layout dynamically based on orientation](/guides/android/knowledge-base/dynamic-page-layout-when-changing-orientation.md)
- [Getting Signature Location](/guides/android/knowledge-base/getting-signature-location.md)
- [Invoke Search Programmatically](/guides/android/knowledge-base/invoke-search-programmatically.md)
- [Install Failed Insufficient Storage](/guides/android/knowledge-base/install-failed-insufficient-storage.md)
- [Intercepting Touch Events](/guides/android/knowledge-base/intercepting-touch-events.md)
- [Creating invisible digital signatures in Android](/guides/android/knowledge-base/invisible-signature.md)
- [Invoking Share Action Programmatically](/guides/android/knowledge-base/invoking-share-action-programmatically.md)
- [Making Form Elements Read Only](/guides/android/knowledge-base/making-form-elements-read-only.md)
- [Override Hyperlink Behavior](/guides/android/knowledge-base/override-hyperlink-behavior.md)
- [Runtime Permissions Cordova](/guides/android/knowledge-base/runtime-permissions-cordova.md)
- [Remove Tool Variant From Toolbar](/guides/android/knowledge-base/remove-tool-variant-from-toolbar.md)
- [Customize the overflow button color in Android](/guides/android/knowledge-base/styling-overflow-button.md)
- [Save signed PDFs directly to a remote server on Android](/guides/android/knowledge-base/save-signed-pdfs-to-remote-server.md)
- [Using Pspdfkit With Dynamic Feature Modules](/guides/android/knowledge-base/using-pspdfkit-with-dynamic-feature-modules.md)

