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

On zooming less than min zoom the image is panned to center #21

Closed
jitheeshsk opened this issue Apr 20, 2017 · 12 comments
Closed

On zooming less than min zoom the image is panned to center #21

jitheeshsk opened this issue Apr 20, 2017 · 12 comments

Comments

@jitheeshsk
Copy link

jitheeshsk commented Apr 20, 2017

Set min zoom to 0.8f.
Take an image which is really long in height, i'm using the below image.

Issue seems to be in on up
private boolean onUp(){
...
if (showAnimation()) {

            animateAdjustmentWithScale(tx, xx, ty, **ty,** scaleX, mMinZoom);

        } else {
            matrix.reset();
            matrix.setScale(mMinZoom, mMinZoom);
            matrix.postTranslate(xx, **ty**);
            setImageMatrix(matrix);
            invalidate();
            if (DEBUG) {
                Log.i(TAG, "scale after invalidate: " + getScale(matrix));
            }
        }
        return true;
    }

...

Should solve the issue,

screenshot_20170420-125705

@jayrambhia
Copy link
Owner

Yes, that is the desired behavior. It's a cropper so it tires to pan the image to center.

@jitheeshsk
Copy link
Author

Shouldn't the state of view be maintained, it should pan to center of screen not image right, just a suggestion

@jayrambhia
Copy link
Owner

@jitheeshsk I don't understand. How can image pan to center of itself? Can you add a gif/video? That would help me understand the problem.

@jitheeshsk
Copy link
Author

Attached is the gif showing the issue

image_crop

@jayrambhia
Copy link
Owner

@jitheeshsk Thanks for the gif. This is indeed a problem. Can you tell me which version of the lib are you using?

@jitheeshsk
Copy link
Author

It is 0.1.8

@jayrambhia
Copy link
Owner

@jitheeshsk I'm unable to reproduce it in 0.1.8 with min zoom 0.8f.

crop_out

@jitheeshsk
Copy link
Author

jitheeshsk commented Apr 20, 2017 via email

@jayrambhia
Copy link
Owner

@jitheeshsk oh yes, got the problem. I'll try to fix it. And also setMinZoom should work out of the box.

@jitheeshsk
Copy link
Author

@jayrambhia I will also see if there is a work around, will try to post if i am able to resolve the issue.

Thanks

@jitheeshsk
Copy link
Author

jitheeshsk commented Apr 20, 2017

in onUp()

f (scaleX < mMinZoom) {
            if (DEBUG) {
                Log.i(TAG, "set scale: " + mMinZoom);
            }
float yy = ty * mMinZoom/scaleX;
            if (showAnimation()) {
                if(yy > 0)
                    yy = 0;
                animateAdjustmentWithScale(tx, xx, ty, yy, scaleX, mMinZoom);

            }
}

Fixed the issue for me

jayrambhia added a commit that referenced this issue Apr 20, 2017
As mentioned in issue #21, the image pans and snpas back to its own center when zoomed out (> minzoom). This is fixed now. Now, the cropper decides where to snap and pan. If the image is zoomed out such that y translation is > 0, we snap top of the image to the view. If the image is zoomed out such that bottom of the image is inside the view, it snaps to bottom of the view. In other cases, we try to maintain the zoom focus point where it is. The same goes for x dimension.

Also fixed image panning issue when scale is min zoom. Issue #10.

Apart from these issues, user can set min zoom and it won't be overridden by onLayout method. But this has its own pitfall. If the user changes the image, it is required for the user to change min zoom manually.

Signed-off-by: Jay Rambhia <jayrambhia777@gmail.com>
@jayrambhia
Copy link
Owner

Fixed in 0.1.9.

@jitheeshsk

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

No branches or pull requests

2 participants