Skip to content

Commit

Permalink
fix: Swipy (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawn-used-yeet authored Oct 29, 2024
1 parent 652ef21 commit f191502
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions app/src/main/java/ani/dantotsu/media/manga/mangareader/Swipy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,20 @@ class Swipy @JvmOverloads constructor(
}

private fun handleDrag(pos: Float) {
val overscroll = (pos - initialMotion) * DRAG_RATE
if (overscroll > 0) { // Keep this check
parent.requestDisallowInterceptTouchEvent(true)
if (vertical) {
val totalDragDistance = Resources.getSystem().displayMetrics.heightPixels / dragDivider
if (verticalPos == VerticalPosition.Top)
topBeingSwiped.invoke(overscroll * 2 / totalDragDistance)
else
bottomBeingSwiped.invoke(overscroll * 2 / totalDragDistance)
} else {
val totalDragDistance = Resources.getSystem().displayMetrics.widthPixels / dragDivider
if (horizontalPos == HorizontalPosition.Left)
leftBeingSwiped.invoke(overscroll / totalDragDistance)
else
rightBeingSwiped.invoke(overscroll / totalDragDistance)
}
val overscroll = abs((pos - initialMotion) * DRAG_RATE)
parent.requestDisallowInterceptTouchEvent(true)
if (vertical) {
val totalDragDistance = Resources.getSystem().displayMetrics.heightPixels / dragDivider
if (verticalPos == VerticalPosition.Top)
topBeingSwiped.invoke(overscroll * 2 / totalDragDistance)
else
bottomBeingSwiped.invoke(overscroll * 2 / totalDragDistance)
} else {
val totalDragDistance = Resources.getSystem().displayMetrics.widthPixels / dragDivider
if (horizontalPos == HorizontalPosition.Left)
leftBeingSwiped.invoke(overscroll / totalDragDistance)
else
rightBeingSwiped.invoke(overscroll / totalDragDistance)
}
}

Expand All @@ -183,7 +181,7 @@ class Swipy @JvmOverloads constructor(
topBeingSwiped.invoke(0f)
bottomBeingSwiped.invoke(0f)
} else {
rightBeingSwiped.invoke( 0f)
rightBeingSwiped.invoke(0f)
leftBeingSwiped.invoke(0f)
}
}
Expand Down

0 comments on commit f191502

Please sign in to comment.