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

SCALE_TYPE_START issue with padding: image starts at not allowed position #533

Open
lorenzos opened this issue Oct 28, 2020 · 0 comments
Open

Comments

@lorenzos
Copy link

lorenzos commented Oct 28, 2020

If I use setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_START) on a SubsamplingScaleImageView with padding, the image is placed at the very view border, and as soon as it's grabbed it "snaps in place" (moving away from the border) in order to respect the padding area. Then, that grab gesture doesn't work as intended, and you have to let it go and grab it again to resume normal behavior.

If instead of using SCALE_TYPE_START I use SCALE_TYPE_CENTER_CROP and pass new ImageViewState(0, new PointF(0, 0), 0) when loading the image (as suggested in #166), everything works perfectly and padding is observed, just like I would expect when using SCALE_TYPE_START.

PS: I think the issue is somewhere here in fitToBounds:

if (init && minimumScaleType != SCALE_TYPE_START) {
vTranslate.set(vTranslateForSCenter(sWidth()/2, sHeight()/2, scale));
}

I'd try changing it to:

if (init) {
    if (minimumScaleType != SCALE_TYPE_START) {
        vTranslate.set(vTranslateForSCenter(sWidth()/2, sHeight()/2, scale));
    } else {
        vTranslate.set(vTranslateForSCenter(0, 0, scale));
    }
}
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

1 participant