diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt index b83e4bc88..9ce140145 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt @@ -94,7 +94,7 @@ abstract class PageDelegate(protected val pageView: PageView) { startY, dx, dy, - getDuration((if (dx != 0) dx else dy).toFloat()) + if (dx != 0) getDuration(dx, viewWidth) else getDuration(dy, viewHeight) ) isRunning = true isStarted = true @@ -109,9 +109,8 @@ abstract class PageDelegate(protected val pageView: PageView) { invalidate() } - protected fun getDuration(distance: Float): Int { - val duration = 300 * abs(distance) / viewWidth - return duration.toInt() + private fun getDuration(distance: Int, len: Int): Int { + return (300f * abs(distance) / len).toInt() } fun setViewSize(width: Int, height: Int) {