usuiat / Zoomable

Jetpack Compose library that enables contents zooming with pinch gesture.
https://usuiat.github.io/Zoomable/
Apache License 2.0
342 stars 16 forks source link

onTouchEvent is not broadcasted to the view when the view is zoomed #172

Open ludovicroland opened 5 months ago

ludovicroland commented 5 months ago

Hello,

I have integrated the library in my project and I apply it to an AndroidView :

AndroidView(
    modifier = modifier
      .zoomable(
        zoomState = zoomState,
        enableOneFingerZoom = false,
      ),
    factory = {
      MyCustomRelativeLayout(it).apply {
        layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
      }
    },
    update = {
     //...
    }
  )

The MyCustomRelativeLayout is a ViewGroup that extends RelativeLayout in which on the onTouchEvent(MotionEvent event) method is overrided.

When my custom view is not zoomed, the touch event is correctly triggered. But when the view is zoomed, the onTouchEvent of my custom view is not called anymore.

How can I update the library to trigger the onTouchEvent regardless of the view zoom level?

Thank you for your help.

usuiat commented 5 months ago

@ludovicroland In conclusion, I could not find a solution.

I have reproduced this Issue. And I have confirmed that when the AndroidView is zoomed, onTouchEvent is called only in the same size area as the original View, based on the top left corner.

image

Zoomable uses graphicsLayer to achieve zooming, but the area where AndroidView touch events are detected does not seem to change.

I am not familiar with the internals of AndroidView, so it is difficult to investigate further.

ludovicroland commented 5 months ago

Hello,

Thank you for your feedback and the investigation!

Regards