-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix scroll issues #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix scroll issues #232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has the number 40 been tested with different number of days selected in the app? Because it seems like a magic value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is kind of a magic number, i just need a small threshold so there has to be a notable change in scroll direction before changing it. else there are some glitches if you put your hands off the screen and the scroll distance is suddenly 0.1 in other direction.
while writing this maybe the best would be if this threshold is calculated including density.
@caske33 do you have any idea how we can predict where the fling stops scrolling before we call mScroller.fling? we also can play around with goToNearestDay function e.g. to go to next day only if 25%-30% of next day are visible, else we snap back. |
On android usually the value to use is : http://developer.android.com/reference/android/view/ViewConfiguration.html#getScaledTouchSlop() as a minimal distance trigger. I'm currently testing another approach that works quite well. First for snap scrolling I use :
This makes the duration relative to the distance to scroll, making it more natural for all cases. (unlike fixed duration whatever distance to scroll) Second I start snapping a littler earlier than when fling is finished to avoid the pause effect. In
With mMinimalFlingVelocity set to Bouncing to back day when the fling stop in the start of next day feels more natural, than scrolling the whole day to go to next or previous one. |
@Tolriq Your code doesn't seem to snap anymore. |
I've played a little more but I can't get any good behaviour (yet) As @marunjar I've tried adding a The ViewPager class from AOSP seems to use Math.sin() for that. Maybe we should try to experiment with that too? |
@caske33 Well it does still snap here : please see Tolriq@b2e595e I can't really make PR for now as I've diverged a little from code base and had a too quick push with code formatting. Anyway whatever interpolator or not is used there will be a cut in animation since it will be after the fling that is decelerating. The only real proper way would be to not use the scroller fling but calculate the correct destination then do the scroll manually with an interpolator. But then it's no more snapping. Snapping effect is not a bad thing as it help users to understand the limits of the days and add interaction effect. |
make a difference wetween left and right scrolling when snapping to day use dynamic scroll duration (250ms) for gotoNearestOrigin allow changing direction while scrolling gotoNearestOrigin immediately after animation (>=API14 only)
thanks @Tolriq, i just played around with your suggestions and dynamic scroll speed and the properties from i also tried the early snapping but this only works on >= api 14 @caske33 we can also play with different scroll durations and custom interpolators, shouldn't be that hard. |
Sorry no, I'm not in production with my current code so can't really test right now. |
@marunjar I like this a lot better! Should we merge it like this? The only thing that could be enhanced is maybe that the fling gesture doesn't start this easily. |
i think it can be merged. I'm not sure if we can change the behavoour for the fling gesture. |
fix scroll issues
make a difference wetween left and right scrolling when snapping to day
use default scroll duration (250ms) instead of 50ms before
allow changing direction while scrolling