Restore both-edge swipe: left edge = prev page, right edge = next page

Swipe direction is determined by which edge the finger started on AND
the drag direction matching (right edge + swipe left = next, left edge
+ swipe right = prev). Both no-op at their respective boundaries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 18:42:44 -07:00
parent 2cc445a30d
commit a74e0dce04

View File

@@ -794,9 +794,9 @@ class PadCanvasView(context: Context) : View(context) {
lastTouchY = event.y
fingerDownX = event.x
fingerDownY = event.y
// Detect if finger started at screen edge
// Detect if finger started at either screen edge
val edgeZone = width * EDGE_ZONE_FRACTION
isEdgeSwipe = event.x > width - edgeZone // Only right edge for next page
isEdgeSwipe = event.x < edgeZone || event.x > width - edgeZone
}
MotionEvent.ACTION_MOVE -> {
if (!scaleGestureDetector.isInProgress && event.pointerCount == 1) {
@@ -821,9 +821,15 @@ class PadCanvasView(context: Context) : View(context) {
val dy = event.y - fingerDownY
val absDx = Math.abs(dx)
val absDy = Math.abs(dy)
if (absDx > EDGE_SWIPE_MIN_PX && absDx > absDy * 2 && dx < 0) {
val edgeZone = width * EDGE_ZONE_FRACTION
if (absDx > EDGE_SWIPE_MIN_PX && absDx > absDy * 2) {
if (fingerDownX > width - edgeZone && dx < 0) {
// Swipe left from right edge = next page
onEdgeSwipe?.invoke(SwipeDirection.NEXT)
} else if (fingerDownX < edgeZone && dx > 0) {
// Swipe right from left edge = prev page
onEdgeSwipe?.invoke(SwipeDirection.PREV)
}
}
}
isEdgeSwipe = false