diff --git a/library/src/main/java/ru/tinkoff/scrollingpagerindicator/ViewPagerAttacher.java b/library/src/main/java/ru/tinkoff/scrollingpagerindicator/ViewPagerAttacher.java index 3a6dc71..9c9d479 100644 --- a/library/src/main/java/ru/tinkoff/scrollingpagerindicator/ViewPagerAttacher.java +++ b/library/src/main/java/ru/tinkoff/scrollingpagerindicator/ViewPagerAttacher.java @@ -45,7 +45,16 @@ public void onInvalidated() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixel) { - indicator.onPageScrolled(position, positionOffset); + final float offset; + // ViewPager may emit negative positionOffset for very fast scrolling + if (positionOffset < 0) { + offset = 0; + } else if (positionOffset > 1) { + offset = 1; + } else { + offset = positionOffset; + } + indicator.onPageScrolled(position, offset); } @Override