jayrambhia / CropperNoCropper

Instagram Style Image Cropper for Android (Library)
http://www.jayrambhia.com/project/nocropper-library
Apache License 2.0
475 stars 99 forks source link

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

Closed jitheeshsk closed 7 years ago

jitheeshsk commented 7 years ago

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 commented 7 years ago

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

jitheeshsk commented 7 years ago

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

jayrambhia commented 7 years ago

@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 commented 7 years ago

Attached is the gif showing the issue

image_crop

jayrambhia commented 7 years ago

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

jitheeshsk commented 7 years ago

It is 0.1.8

jayrambhia commented 7 years ago

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

crop_out

jitheeshsk commented 7 years ago

Hi the min zoom is not set, else the image cannot be the completely zoomed out. Check the min zoom value.

I set min zoom in cropperview.post(). As the minZoomValue is rewritten in onLayout of cropperImageView.

On Apr 20, 2017 3:16 PM, "Jay Rambhia" notifications@github.com wrote:

@jitheeshsk https://github.com/jitheeshsk I'm unable to reproduce it in 0.1.8 with min zoom 0.8f.

[image: crop_out] https://cloud.githubusercontent.com/assets/1256649/25224552/061b8fea-25bf-11e7-8e47-bc36f8ed5440.gif

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jayrambhia/CropperNoCropper/issues/21#issuecomment-295656332, or mute the thread https://github.com/notifications/unsubscribe-auth/AGMlV2VS9eaTcKyDZH8B5Ikl4L3XEVlrks5rxymHgaJpZM4NCswI .

jayrambhia commented 7 years ago

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

jitheeshsk commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

Fixed in 0.1.9.

@jitheeshsk