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

ZoomLayout.zoomTo() ignored when loading images of different resolutions #209

Open
littledot opened this issue Aug 8, 2021 · 1 comment
Labels

Comments

@littledot
Copy link

littledot commented Aug 8, 2021

Describe the bug

Please add a clear description of what the bug is, and fill the list below.

  • Library version: 1.8.0
  • Reproducible in official demo app: no, but repro app included
  • Device / Android version: Nexus 5, API 21

I'm implementing a feature that allows users to select the resolution of the image being displayed. I reset the zoom to 1 with zoomTo(1f, false) when the user selects a resolution, like so:

    fun loadImg(res: Int) {
        zoom.zoomTo(1f, false)
        img.setImageResource(res)
        zoom.zoomTo(1f, false)
        zoomInfo()
    }

but ZoomLayout sometimes ignores the call and sets the zoom to 2.

If you run my repro app, then tap the 3 resolution buttons, you'll see the unwanted jumps in zoom levels. Pan the image around with 1 finger to get updated zoom and realZoom values.

To Reproduce

Steps to reproduce the behavior, possibly in the demo app:

  1. Run my repro app https://github.com/littledot/android-bug-report
  2. Click on 160p, 320p, etc.
  3. Pan the image with 1 finger to get updated ZoomLayout info

Expected behavior

.zoomTo() should not be ignored.

XML layout

Declaration of your XML component, so we can read its attributes.

    <com.otaliastudios.zoom.ZoomLayout
        android:id="@+id/zoom"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:maxZoom="1000.00"
        app:minZoom="1.0"
        app:overPinchable="false"
        app:overScrollHorizontal="false"
        app:overScrollVertical="false">

        <ImageView
            android:id="@+id/img"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.otaliastudios.zoom.ZoomLayout>

Screenshots

If applicable, add screenshots to help explain your problem.

Logs

If applicable, please add logs to help diagnose the problem.
Use ZoomLogger.setLogLevel(LEVEL_INFO) to stream all logs into LogCat.

APK

Link to a Github repo where the bug is reproducible.

@markusressel
Copy link
Collaborator

Thx for the detailed bug report ❤️
Not sure when I have time, but I will try to investigate this.
If you find any hints as to why this might be happening, feel free to open a PR.

@stale stale bot added the status:stale label Sep 3, 2021
Repository owner deleted a comment from stale bot Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants