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

Cancel gesture handling when PointerEvent is consumed by the parent. #180

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

usuiat
Copy link
Owner

@usuiat usuiat commented Mar 6, 2024

Related Issue

Overview

In some cases, the Zoomable Modifier would continue gesture processing even after PointerEvents were consumed by the parent component.
As a result, scrolling of the HorizontalPager and onTap of the Zoomable were occurring simultaneously.

In this PR, Zoomable Modifier cancels the gesture processing when the parent component consumes PointerEvents.

@usuiat usuiat marked this pull request as ready for review March 7, 2024 03:51
@usuiat usuiat merged commit 4adbdac into develop_v1.6.1 Mar 7, 2024
1 check passed
@usuiat usuiat deleted the issue177_fix_ontap branch March 7, 2024 03:54
@Kartex7260
Copy link

Hello, this is not a very clear change. Normally, in Compose, the child element overrides the parent input events by using input events. This change does not correspond to this concept. The change is nice, but I would consider using NestedScrollConnection.

We used your library and encountered a problem when updating it. When tapping, we hide and show the UI, but due to this change, DoubleTap stopped working for us, since the parent element uses clickable.

@usuiat
Copy link
Owner Author

usuiat commented Jul 18, 2024

@Kartex7260
Hi, Thank you for your comment.

I experimented with the following code.

Box(modifier = Modifier.clickable { println("Tap parent") }) {
    Image(
        ...
        modifier = Modifier
            .zoomable(
                ...
                onDoubleTap = { println("DoubleTap Zoomable") }
            )
    )
}

When I double-tap the Image, Zoomable v1.6.0 prints “DoubleTap Zoomable”.
But Zoomable v1.6.1 does not print it and "Tap parent" is printed twice.
Is this what you are trying to point out?

@Kartex7260
Copy link

@usuiat
Thank you for your reply.
That's right, in version 1.6.0, there is a tap on both the parent view and the zoomable view. However, in version 1.6.1, the zoomable tap no longer works, as the parent clickable element disables it.

I believe it would be more intuitive if, when tapping on the zoomable area, the parent view was not tapped. Additionally, conflicts between the zoomable gesture and Pager or Scrollable components can be resolved using NestedScrollView.

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

Successfully merging this pull request may close these issues.

2 participants