From d99f4697e892db70e765da9789f3ceba25aa7d46 Mon Sep 17 00:00:00 2001 From: LagradOst <46196380+Blatzar@users.noreply.github.com> Date: Sat, 1 Jul 2023 01:56:35 +0000 Subject: [PATCH] Fixed scrolling on the background using long strip (#9654) Update WebtoonFrame.kt --- .../ui/reader/viewer/webtoon/WebtoonFrame.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt index cedc45ab7..56b459701 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon import android.content.Context +import android.graphics.Rect import android.view.GestureDetector import android.view.MotionEvent import android.view.ScaleGestureDetector @@ -44,6 +45,18 @@ class WebtoonFrame(context: Context) : FrameLayout(context) { override fun dispatchTouchEvent(ev: MotionEvent): Boolean { scaleDetector.onTouchEvent(ev) flingDetector.onTouchEvent(ev) + + // Get the bounding box of the recyclerview and translate any motion events to be within it. + // Used to allow scrolling outside the recyclerview. + val recyclerRect = Rect() + recycler?.getHitRect(recyclerRect) ?: return super.dispatchTouchEvent(ev) + // Shrink the box to account for any rounding issues. + recyclerRect.inset(1, 1) + ev.setLocation( + ev.x.coerceIn(recyclerRect.left.toFloat(), recyclerRect.right.toFloat()), + ev.y.coerceIn(recyclerRect.top.toFloat(), recyclerRect.bottom.toFloat()), + ) + return super.dispatchTouchEvent(ev) }