From 789421c7a001d2f0f3af28e198a24d1af1bf1b5d Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 22 Jun 2020 22:36:33 -0400 Subject: [PATCH] Scroll up/down when tapping top/bottom thirds in vertical reading modes (closes #3363) --- .../ui/reader/viewer/pager/PagerViewer.kt | 19 ++++++++++++++----- .../reader/viewer/pager/PagerViewerAdapter.kt | 1 + .../ui/reader/viewer/webtoon/WebtoonViewer.kt | 7 ++----- 3 files changed, 17 insertions(+), 10 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 81ea15a41..4bef6dd00 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 @@ -80,11 +80,20 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { } }) pager.tapListener = { event -> - val positionX = event.x - when { - positionX < pager.width * 0.33f && config.tappingEnabled -> moveLeft() - positionX > pager.width * 0.66f && config.tappingEnabled -> moveRight() - else -> activity.toggleMenu() + if (this is VerticalPagerViewer) { + val positionY = event.y + when { + positionY < pager.height * 0.33f && config.tappingEnabled -> moveLeft() + positionY > pager.height * 0.66f && config.tappingEnabled -> moveRight() + else -> activity.toggleMenu() + } + } else { + val positionX = event.x + when { + positionX < pager.width * 0.33f && config.tappingEnabled -> moveLeft() + positionX > pager.width * 0.66f && config.tappingEnabled -> moveRight() + else -> activity.toggleMenu() + } } } pager.longTapListener = f@{ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt index 30e568b97..720171e4e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewerAdapter.kt @@ -24,6 +24,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { private set var currentChapter: ReaderChapter? = null + /** * Updates this adapter with the given [chapters]. It handles setting a few pages of the * next/previous chapter to allow seamless transitions and inverting the pages if the viewer 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 55791f244..802f969e0 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 @@ -93,13 +93,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr } }) recycler.tapListener = { event -> - val positionX = event.rawX val positionY = event.rawY when { - positionY < recycler.height * 0.25 && config.tappingEnabled -> scrollUp() - positionY > recycler.height * 0.75 && config.tappingEnabled -> scrollDown() - positionX < recycler.width * 0.33 && config.tappingEnabled -> scrollUp() - positionX > recycler.width * 0.66 && config.tappingEnabled -> scrollDown() + positionY < recycler.height * 0.33f && config.tappingEnabled -> scrollUp() + positionY > recycler.height * 0.66f && config.tappingEnabled -> scrollDown() else -> activity.toggleMenu() } }