From 04cf102be93c3da25bf1664edb6be713a62ab5ce Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 18 Feb 2020 21:00:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../page/delegate/SimulationPageDelegate.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index 55a4a5209..aa55fec98 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -477,18 +477,18 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi * 计算拖拽点对应的拖拽脚 */ private fun calcCornerXY(x: Float, y: Float) { - mCornerX = if (x <= pageView.width / 2.0) { + mCornerX = if (x <= viewWidth / 2.0) { 0 } else { - pageView.width + viewWidth } - mCornerY = if (y <= pageView.height / 2.0) { + mCornerY = if (y <= viewHeight / 2.0) { 0 } else { - pageView.height + viewHeight } - mIsRT_LB = (mCornerX == 0 && mCornerY == pageView.height) - || (mCornerX == pageView.width && mCornerY == 0) + mIsRT_LB = (mCornerX == 0 && mCornerY == viewHeight) + || (mCornerX == viewWidth && mCornerY == 0) } private fun calcPoints() { @@ -509,11 +509,11 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi mBezierStart1.y = mCornerY.toFloat() // 当mBezierStart1.x < 0或者mBezierStart1.x > 480时 // 如果继续翻页,会出现BUG故在此限制 - if (touchX > 0 && touchX < pageView.width) { - if (mBezierStart1.x < 0 || mBezierStart1.x > pageView.width) { - if (mBezierStart1.x < 0) mBezierStart1.x = pageView.width - mBezierStart1.x + if (touchX > 0 && touchX < viewWidth) { + if (mBezierStart1.x < 0 || mBezierStart1.x > viewWidth) { + if (mBezierStart1.x < 0) mBezierStart1.x = viewWidth - mBezierStart1.x val f1: Float = abs(mCornerX - touchX) - val f2: Float = pageView.width * f1 / mBezierStart1.x + val f2: Float = viewWidth * f1 / mBezierStart1.x touchX = abs(mCornerX - f2) val f3: Float = abs(mCornerX - touchX) * abs(mCornerY - touchX) / f1 touchX = abs(mCornerY - f3) @@ -531,8 +531,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi mBezierControl2.y = mMiddleY - (mCornerX - mMiddleX) * (mCornerX - mMiddleX) / (mCornerY - mMiddleY) } - mBezierStart1.x = (mBezierControl1.x - - (mCornerX - mBezierControl1.x) / 2) + mBezierStart1.x = (mBezierControl1.x - (mCornerX - mBezierControl1.x) / 2) } } mBezierStart2.x = mCornerX.toFloat()