Skip to content

Commit

Permalink
Fix a possible crash with auto-zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
jobobby04 committed Nov 8, 2024
1 parent e5a6d1b commit 26cfb48
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,22 @@ open class ReaderPageImageView @JvmOverloads constructor(
}

private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean) {
val config = config
if (config != null &&
config!!.landscapeZoom &&
config!!.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
config.landscapeZoom &&
config.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
sWidth > sHeight &&
scale == minScale
) {
handler?.postDelayed(500) {
val point = when (config!!.zoomStartPosition) {
val point = when (config.zoomStartPosition) {
ZoomStartPosition.LEFT -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
ZoomStartPosition.RIGHT -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
ZoomStartPosition.CENTER -> center
}

val targetScale = height.toFloat() / sHeight.toFloat()
animateScaleAndCenter(targetScale, point)!!
(animateScaleAndCenter(targetScale, point) ?: return@postDelayed)
.withDuration(500)
.withEasing(EASE_IN_OUT_QUAD)
.withInterruptible(true)
Expand Down

0 comments on commit 26cfb48

Please sign in to comment.