Adjust vertical reading mode tap zones (closes #3551)
Basically L shapes, where top/left goes back, bottom/right goes forward, and middle opens the menu.
This commit is contained in:
parent
af2ef0621a
commit
493c8b0943
@ -80,29 +80,38 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
|||||||
isIdle = state == ViewPager.SCROLL_STATE_IDLE
|
isIdle = state == ViewPager.SCROLL_STATE_IDLE
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
pager.tapListener = { event ->
|
pager.tapListener = f@{ event ->
|
||||||
|
if (!config.tappingEnabled) {
|
||||||
|
activity.toggleMenu()
|
||||||
|
return@f
|
||||||
|
}
|
||||||
|
|
||||||
|
val positionX = event.x
|
||||||
|
val positionY = event.y
|
||||||
|
val topSideTap = positionY < pager.height * 0.25f
|
||||||
|
val bottomSideTap = positionY > pager.height * 0.75f
|
||||||
|
val leftSideTap = positionX < pager.width * 0.33f
|
||||||
|
val rightSideTap = positionX > pager.width * 0.66f
|
||||||
|
|
||||||
val invertMode = config.tappingInverted
|
val invertMode = config.tappingInverted
|
||||||
|
val invertVertical = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
||||||
|
val invertHorizontal = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH
|
||||||
|
|
||||||
if (this is VerticalPagerViewer) {
|
if (this is VerticalPagerViewer) {
|
||||||
val positionY = event.y
|
|
||||||
val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
|
||||||
val topSideTap = positionY < pager.height * 0.33f && config.tappingEnabled
|
|
||||||
val bottomSideTap = positionY > pager.height * 0.66f && config.tappingEnabled
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> moveLeft()
|
topSideTap && !invertVertical || bottomSideTap && invertVertical -> moveLeft()
|
||||||
bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> moveRight()
|
bottomSideTap && !invertVertical || topSideTap && invertVertical -> moveRight()
|
||||||
|
|
||||||
|
leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> moveLeft()
|
||||||
|
rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> moveRight()
|
||||||
|
|
||||||
else -> activity.toggleMenu()
|
else -> activity.toggleMenu()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val positionX = event.x
|
|
||||||
val tappingInverted = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH
|
|
||||||
val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled
|
|
||||||
val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
leftSideTap && !tappingInverted || rightSideTap && tappingInverted -> moveLeft()
|
leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> moveLeft()
|
||||||
rightSideTap && !tappingInverted || leftSideTap && tappingInverted -> moveRight()
|
rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> moveRight()
|
||||||
|
|
||||||
else -> activity.toggleMenu()
|
else -> activity.toggleMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,17 +93,30 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
recycler.tapListener = { event ->
|
recycler.tapListener = f@{ event ->
|
||||||
val positionY = event.rawY
|
if (!config.tappingEnabled) {
|
||||||
val invertMode = config.tappingInverted
|
activity.toggleMenu()
|
||||||
val topSideTap = positionY < recycler.height * 0.33f && config.tappingEnabled
|
return@f
|
||||||
val bottomSideTap = positionY > recycler.height * 0.66f && config.tappingEnabled
|
}
|
||||||
|
|
||||||
val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
val positionX = event.rawX
|
||||||
|
val positionY = event.rawY
|
||||||
|
val topSideTap = positionY < recycler.height * 0.25f
|
||||||
|
val bottomSideTap = positionY > recycler.height * 0.75f
|
||||||
|
val leftSideTap = positionX < recycler.width * 0.33f
|
||||||
|
val rightSideTap = positionX > recycler.width * 0.66f
|
||||||
|
|
||||||
|
val invertMode = config.tappingInverted
|
||||||
|
val invertVertical = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
||||||
|
val invertHorizontal = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH
|
||||||
|
|
||||||
when {
|
when {
|
||||||
topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> scrollUp()
|
topSideTap && !invertVertical || bottomSideTap && invertVertical -> scrollUp()
|
||||||
bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> scrollDown()
|
bottomSideTap && !invertVertical || topSideTap && invertVertical -> scrollDown()
|
||||||
|
|
||||||
|
leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> scrollUp()
|
||||||
|
rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> scrollDown()
|
||||||
|
|
||||||
else -> activity.toggleMenu()
|
else -> activity.toggleMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user