subsampling-scale-image-view
subsampling-scale-image-view copied to clipboard
SCALE_TYPE_START issue with padding: image starts at not allowed position
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:
https://github.com/davemorrissey/subsampling-scale-image-view/blob/ebce8e07ef57b163b68e198655587c6107b2ae67/library/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java#L1476-L1478
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));
}
}