From dcb1b5dbf17c53c3fdb538063c9893cbdaeb4458 Mon Sep 17 00:00:00 2001 From: chentianyu <18756170827@163.com> Date: Thu, 8 Jul 2021 18:47:11 +0800 Subject: [PATCH] =?UTF-8?q?Materialscrollbar=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../materialscrollbardemo/Hand.java | 2 +- .../materialscrollbardemo/MateriaScroller.java | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java b/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java index 4ca8572..a1e2373 100644 --- a/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java +++ b/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java @@ -68,7 +68,7 @@ public class Hand extends Component implements Component.DrawTask, Component.Est circlePaint.setAntiAlias(true); handleArc = new RectFloat(5, getTop(), getWidth(), getBottom()); arc = new Arc(90, 180, true); - handleHold = new RectFloat((float) (getWidth() / 2), (float)getTop(), (float)getWidth(), (float)getBottom()); + handleHold = new RectFloat((float)getWidth() / 2, (float)getTop(), (float)getWidth(), (float)getBottom()); } @Override diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/MateriaScroller.java b/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/MateriaScroller.java index 58c4af6..685f690 100644 --- a/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/MateriaScroller.java +++ b/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/MateriaScroller.java @@ -431,16 +431,14 @@ public class MateriaScroller extends DirectionalLayout { scrollListener.notifyListeners(relativePos); } - void setScrolledPosition(double relativePos) { - bubble.setTranslationY(ScrollingUtilities.getValueInRange( - 0, - getHeight() - bubble.getHeight(), - (float) (relativePos * (getHeight() - handle.getHeight()) + 6 * bubbleOffset / 2 + 70)) - bubble.getTop() + 20 - ); + void setScrolledPosition(float relativePos) { + float result = relativePos* ((float) getHeight() - (float) handle.getHeight()) + 6 * (float) bubbleOffset / 2 + 70; + bubble.setTranslationY(ScrollingUtilities.getValueInRange(0, + getHeight() - bubble.getHeight(), result) - bubble.getTop() + 20); handle.setTranslationY(ScrollingUtilities.getValueInRange( 0, getHeight() - handle.getHeight(), - (float)(relativePos * (getHeight() - handle.getHeight() + 30))) - handle.getTop() + (relativePos * (getHeight() - handle.getHeight() + 30))) - handle.getTop() ); setTextData(relativePos); } -- Gitee