Skip to content

Commit b87b1a6

Browse files
committed
fix: wrong pivot point used for feedback image scaling
1 parent 91b69b5 commit b87b1a6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gallery-viewer/src/main/java/com/liuzhenlin/galleryviewer/GestureImageView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ public boolean onDoubleTap(MotionEvent e) {
654654
else // else make it zoomed in
655655
toScaleX = toScaleY = mDoubleTapMagnifiedImageScale;
656656

657-
final float pivotX = e.getX();
658-
final float pivotY = e.getY();
657+
final float pivotX = e.getX() - getPaddingLeft();
658+
final float pivotY = e.getY() - getPaddingTop();
659659

660660
mTmpMatrix.set(mImageMatrix);
661661
mTmpMatrix.postScale(toScaleX / scaleX, toScaleY / scaleY, pivotX, pivotY);
@@ -709,7 +709,8 @@ public boolean onScale(ScaleGestureDetector detector) {
709709
else if (scale * scaleY < mImageMinScale) toScaleY = mImageMinScale / scaleY;
710710
else toScaleY = scale;
711711

712-
mImageMatrix.postScale(toScaleX, toScaleY, detector.getFocusX(), detector.getFocusY());
712+
mImageMatrix.postScale(toScaleX, toScaleY, detector.getFocusX() - getPaddingLeft(),
713+
detector.getFocusY() - getPaddingTop());
713714
setImageMatrix(mImageMatrix);
714715
return true;
715716
}

0 commit comments

Comments
 (0)