Fixed long strip side padding being counted in zoom bounds (#4072)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user