natario1 / ZoomLayout

2D zoom and pan behavior for View hierarchies, images, video streams, and much more, written in Kotlin for Android.
https://natario1.github.io/ZoomLayout
Apache License 2.0
1.05k stars 147 forks source link

Unable to pan to coordinates #153

Closed jimmy510s closed 4 years ago

jimmy510s commented 4 years ago

Hi,

I want to pan to a specific point but the method pan to doesn't seem to work. The only thing that works is panBy method. Do i need to set setContainerSize? my container is about 5000 width and 2000 hegiht.

Thank you

markusressel commented 4 years ago

Can you provide a code snipped of what you are doing?

jimmy510s commented 4 years ago

Hi,

I have the zoom layout and inside i have a frame layout where i add images in order to create something like a floor plan dynamically. Everything works perfect. I can zoom, move etc but after all images have been placed (using code) i try to move to a specific point (using panTo()) but nothing happens. Only if i use panBy() the map moves but it's not what i want since i know the x,y of the item that i want o focus.

Hope this helps

<com.otaliastudios.zoom.ZoomLayout
    android:id="@+id/zoomLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical|horizontal"
    app:alignment="center"
    app:hasClickableChildren="true"
    app:maxZoom="3"
    app:maxZoomType="zoom"
    app:minZoom="1"
    app:minZoomType="zoom"
    app:oneFingerScrollEnabled="true"
    app:overPinchable="false"
    app:overScrollHorizontal="false"
    app:overScrollVertical="false"
    app:scrollEnabled="true"
    app:transformation="centerCrop"
    app:transformationGravity="center"
    app:zoomEnabled="true">

    <FrameLayout
        android:id="@+id/beach_map_asset_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</com.otaliastudios.zoom.ZoomLayout>
markusressel commented 4 years ago

Well, the actual java/kotlin code would be helpful.
I tried your XML on the demo app and I can not reproduce your issue. Make sure to use negative values when using panTo, otherwise you are trying to move the content beyond the limits of the ZoomLayout (the container) which is prevented by the overPinchable=false setting.

jimmy510s commented 4 years ago

Oh... i thought that i had to use positive values. Ok let me try with negative values.

jimmy510s commented 4 years ago

Yes it works!!! Thank you very much!! :D