ToxicBakery / ViewPagerTransforms

Library containing common animations needed for transforming ViewPager scrolling for Android v13+.
https://toxicbakery.github.io/ViewPagerTransforms/
Apache License 2.0
2.57k stars 489 forks source link

Fixed issue on Android 4 where position was outside of the -1f..1f boundaries #74

Closed Sammekl closed 6 years ago

Sammekl commented 6 years ago

This issue is quite specific to our project. We use a continuous scrolling ViewPager with an infinite amount of pages.

Somehow the position retrieved in the 'transformPage' method exceed the boundaries on Android 4. This causes messed up animations where the wrong view animated which causes you to get stuck.

This fix makes sure that the position is always within it's boundaries and does not change any behaviour for working implementations.

ToxicBakery commented 6 years ago

Not an issue but in the future try to avoid the excessive formatting, you picked up a few unrelated lines.

Only thing I would like changed is the function name. Clamp is the appropriate naming for limiting a number between two bounds.

ref: https://en.wikipedia.org/wiki/Clamping_(graphics)

Sammekl commented 6 years ago

Hi,

Thanks for the reply. The formatting was a mistake caused by my pre-commit hook. Couldn't find the right word for clamping haha.

Will adjust my PR this sunday!