Skip to content

Commit

Permalink
Merge pull request #540 from TheBrokenRail/disable-super-zooming
Browse files Browse the repository at this point in the history
Allow Disabling Super Zooming
  • Loading branch information
hannesa2 committed Jul 16, 2023
2 parents 370f9c5 + a08a0d4 commit 22aac0c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt
Expand Up @@ -42,6 +42,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
private var touchMatrix: Matrix
private var prevMatrix: Matrix
var isZoomEnabled = false
var isSuperZoomEnabled = true
private var isRotateImageToFitScreen = false

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

override fun onScale(detector: ScaleGestureDetector): Boolean {
scaleImage(detector.scaleFactor.toDouble(), detector.focusX, detector.focusY, true)
scaleImage(detector.scaleFactor.toDouble(), detector.focusX, detector.focusY, isSuperZoomEnabled)

// OnTouchImageViewListener is set: TouchImageView pinch zoomed by user.
touchImageViewListener?.onMove()
Expand All @@ -917,7 +918,7 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
animateToZoomBoundary = true
}
if (animateToZoomBoundary) {
val doubleTap = DoubleTapZoom(targetZoom, (viewWidth / 2).toFloat(), (viewHeight / 2).toFloat(), true)
val doubleTap = DoubleTapZoom(targetZoom, (viewWidth / 2).toFloat(), (viewHeight / 2).toFloat(), isSuperZoomEnabled)
compatPostOnAnimation(doubleTap)
}
}
Expand Down

0 comments on commit 22aac0c

Please sign in to comment.