diff --git a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java index 49487888..36f90033 100644 --- a/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java +++ b/materialviewpager/src/main/java/com/github/florent37/materialviewpager/MaterialViewPagerAnimator.java @@ -143,6 +143,8 @@ private void setScrollOffset(Object scroll, float yOffset) { } } + float initialDistance = -1; + /** * Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user * @@ -179,6 +181,13 @@ public void onMaterialScrolled(Object source, float yOffset) { float percent = yOffset / scrollMax; + if(initialDistance == -1) + initialDistance = mHeader.mPagerSlidingTabStrip.getTop() - mHeader.toolbar.getBottom(); + + float newDistance = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) - mHeader.toolbar.getBottom(); + + percent = 1 - newDistance/initialDistance; + percent = minMax(0, percent, 1); {