Skip to content

Commit 22aac0c

Browse files
authored
Merge pull request #540 from TheBrokenRail/disable-super-zooming
Allow Disabling Super Zooming
2 parents 370f9c5 + a08a0d4 commit 22aac0c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
4242
private var touchMatrix: Matrix
4343
private var prevMatrix: Matrix
4444
var isZoomEnabled = false
45+
var isSuperZoomEnabled = true
4546
private var isRotateImageToFitScreen = false
4647

4748
var orientationChangeFixedPixel: FixedPixel? = FixedPixel.CENTER
@@ -392,7 +393,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
392393
setScaleType(scaleType!!)
393394
}
394395
resetZoom()
395-
scaleImage(scale.toDouble(), viewWidth / 2.toFloat(), viewHeight / 2.toFloat(), true)
396+
scaleImage(scale.toDouble(), viewWidth / 2.toFloat(), viewHeight / 2.toFloat(), isSuperZoomEnabled)
396397
touchMatrix.getValues(floatMatrix)
397398
floatMatrix[Matrix.MTRANS_X] = -(focusX * imageWidth - viewWidth * 0.5f)
398399
floatMatrix[Matrix.MTRANS_Y] = -(focusY * imageHeight - viewHeight * 0.5f)
@@ -897,7 +898,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
897898
}
898899

899900
override fun onScale(detector: ScaleGestureDetector): Boolean {
900-
scaleImage(detector.scaleFactor.toDouble(), detector.focusX, detector.focusY, true)
901+
scaleImage(detector.scaleFactor.toDouble(), detector.focusX, detector.focusY, isSuperZoomEnabled)
901902

902903
// OnTouchImageViewListener is set: TouchImageView pinch zoomed by user.
903904
touchImageViewListener?.onMove()
@@ -917,7 +918,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
917918
animateToZoomBoundary = true
918919
}
919920
if (animateToZoomBoundary) {
920-
val doubleTap = DoubleTapZoom(targetZoom, (viewWidth / 2).toFloat(), (viewHeight / 2).toFloat(), true)
921+
val doubleTap = DoubleTapZoom(targetZoom, (viewWidth / 2).toFloat(), (viewHeight / 2).toFloat(), isSuperZoomEnabled)
921922
compatPostOnAnimation(doubleTap)
922923
}
923924
}

0 commit comments

Comments
 (0)