diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java b/lib/src/main/java/com/turingtechnologies/materialscrollbardemo/Hand.java index 4ca8572d65c759dc4c5f8dbaee119725138d7497..a1e2373e0937effb251ae620bc0ae4c45d7ce37e 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 58c4af69c3dd1790004deecfb5b21fc09eee0edc..685f69006fb1af928dd97dc5c4f22a46f2c39046 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); }