From 5f5915b25cc588561fdf34a416ed2c2538c387a0 Mon Sep 17 00:00:00 2001 From: Secozzi Date: Wed, 8 May 2024 16:38:52 +0200 Subject: [PATCH] Fixed tap controls not working when zoomed in (#10378) Co-authored-by: Paloys <40764414+Paloys@users.noreply.github.com> Co-authored-by: arkon <4098258+arkon@users.noreply.github.com> --- .../tachiyomi/ui/reader/viewer/pager/PagerViewer.kt | 9 ++++++++- .../tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index ef4b8b323..284da5966 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -102,7 +102,14 @@ abstract class PagerViewer(val activity: ReaderActivity) : Viewer { }, ) pager.tapListener = { event -> - val pos = PointF(event.x / pager.width, event.y / pager.height) + val viewPosition = IntArray(2) + pager.getLocationOnScreen(viewPosition) + val viewPositionRelativeToWindow = IntArray(2) + pager.getLocationInWindow(viewPositionRelativeToWindow) + val pos = PointF( + (event.rawX - viewPosition[0] + viewPositionRelativeToWindow[0]) / pager.width, + (event.rawY - viewPosition[1] + viewPositionRelativeToWindow[1]) / pager.height, + ) when (config.navigator.getAction(pos)) { NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.NEXT -> moveToNext() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 12dc201e8..9737f22df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -111,7 +111,14 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr }, ) recycler.tapListener = { event -> - val pos = PointF(event.y / recycler.width, event.y / recycler.height) + val viewPosition = IntArray(2) + recycler.getLocationOnScreen(viewPosition) + val viewPositionRelativeToWindow = IntArray(2) + recycler.getLocationInWindow(viewPositionRelativeToWindow) + val pos = PointF( + (event.rawX - viewPosition[0] + viewPositionRelativeToWindow[0]) / recycler.width, + (event.rawY - viewPosition[1] + viewPositionRelativeToWindow[1]) / recycler.height, + ) when (config.navigator.getAction(pos)) { NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()