Fixed long strip side padding being counted in zoom bounds (#4072)

This commit is contained in:
WizaHX
2026-10-11 17:11:51 +00:00
committed by GitHub
parent dd4e9f00f1
commit 35bd0a4b35
4 changed files with 19 additions and 6 deletions
+1
View File
@@ -152,6 +152,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- Fixed the chapter selection being cleared when new chapters were downloaded automatically after a refresh ([@AntsyLich](https://github.com/AntsyLich)) ([`a82d27c`](https://github.com/mihonapp/mihon/commit/a82d27c))
- Fixed actions started from a dialog sometimes not running when the dialog closed right away, Kitsu, Shikimori, MangaBaka, Bangumi and Hikka sometimes refreshing their login twice at once, adding an extension repo served over HTTP failing, and cancelling an extension install not stopping its download ([@AntsyLich](https://github.com/AntsyLich)) ([#4068](https://github.com/mihonapp/mihon/pull/4068))
- Fixed the next library update staying "Soon" after new chapters were found, and chapters that came out early, late or were dated earlier by the source pushing the next check back ([@AntsyLich](https://github.com/AntsyLich)) ([`ba44815`](https://github.com/mihonapp/mihon/commit/ba44815))
- Fixed long strip side padding being counted in zoom bounds ([@WizaHX](https://github.com/WizaHX)) ([#4072](https://github.com/mihonapp/mihon/pull/4072))
### Other
- Show "Nightly" instead of "Beta" for preview builds and "FOSS" for FOSS builds in About ([@AntsyLich](https://github.com/AntsyLich)) ([#3760](https://github.com/mihonapp/mihon/pull/3760))
@@ -1,6 +1,5 @@
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
import android.content.res.Resources
import android.view.LayoutInflater
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
@@ -103,9 +102,8 @@ class WebtoonPageHolder(
bottomMargin = 15.dpToPx
}
val margin = Resources.getSystem().displayMetrics.widthPixels * (viewer.config.sidePadding / 100f)
marginEnd = margin.toInt()
marginStart = margin.toInt()
marginEnd = viewer.recycler.sidePaddingPixels
marginStart = viewer.recycler.sidePaddingPixels
}
}
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
import android.animation.AnimatorSet
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.Resources
import android.util.AttributeSet
import android.view.HapticFeedbackConstants
import android.view.MotionEvent
@@ -47,6 +48,15 @@ class WebtoonRecyclerView @JvmOverloads constructor(
private val listener = GestureListener()
private val detector = Detector()
var sidePaddingPercent = 0
set(value) {
field = value
x = getPositionX(x)
}
val sidePaddingPixels: Int
get() = (Resources.getSystem().displayMetrics.widthPixels * (sidePaddingPercent / 100f)).toInt()
var doubleTapZoom = true
var tapListener: ((MotionEvent) -> Unit)? = null
@@ -63,6 +73,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
originalHeight = MeasureSpec.getSize(heightSpec)
}
super.onMeasure(widthSpec, heightSpec)
x = getPositionX(x)
}
override fun onTouchEvent(e: MotionEvent): Boolean {
@@ -99,7 +110,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
if (currentScale < 1) {
return 0f
}
val maxPositionX = halfWidth * (currentScale - 1)
val maxPositionX = ((halfWidth - sidePaddingPixels) * currentScale - halfWidth).coerceAtLeast(0f)
return positionX.coerceIn(-maxPositionX, maxPositionX)
}
@@ -122,7 +133,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
isZooming = true
val animatorSet = AnimatorSet()
val translationXAnimator = ValueAnimator.ofFloat(fromX, toX)
translationXAnimator.addUpdateListener { animation -> x = animation.animatedValue as Float }
translationXAnimator.addUpdateListener { animation -> x = getPositionX(animation.animatedValue as Float) }
val translationYAnimator = ValueAnimator.ofFloat(fromY, toY)
translationYAnimator.addUpdateListener { animation -> y = animation.animatedValue as Float }
@@ -182,6 +193,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
private fun setScaleRate(rate: Float) {
scaleX = rate
scaleY = rate
x = getPositionX(x)
}
fun onScale(scaleFactor: Float) {
@@ -73,6 +73,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
private val threshold: Int by lazy { readerPreferences.readerHideThreshold.get().threshold }
init {
recycler.sidePaddingPercent = config.sidePadding
recycler.setItemViewCacheSize(RECYCLER_VIEW_CACHE_SIZE)
recycler.isVisible = false // Don't let the recycler layout yet
recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
@@ -136,6 +137,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
}
config.imagePropertyChangedListener = {
recycler.sidePaddingPercent = config.sidePadding
refreshAdapter()
}