Skip to content
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

Prevent from scrolling "overflow". #1343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion FSCalendar/FSCalendarTransitionCoordinator.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,37 @@ - (void)scopeTransitionDidUpdate:(UIPanGestureRecognizer *)panGesture
{
if (self.state != FSCalendarTransitionStateChanging) return;

CGFloat translation = ABS([panGesture translationInView:panGesture.view].y);
CGFloat y = [panGesture translationInView:panGesture.view].y;

//
// Prevent from scrolling "overflow". This happens when we perform
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice explanation 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi WenchaoD,

Thank you for looking at this issues.

The submitted patch, is intent to resolve issue "during gesture", where it causes weird UI outcome.

However, I notice there is another issue "after releasing gesture".

Please note that, the issue "after releasing gesture" already occur, even before this patch.

If you look at the animation after fix (From week view, to month view, then to week view again)

3

Even though there is no weird UI outcome "during gesture", but the logic which determines the final state after "after releasing gesture" is incorrect.

For the above use case, the final state should be week view, "after releasing gesture". Somehow, the logic in scopeTransitionDidEnd incorrectly make the final state as month view.

I am currently studying and testing the logic of the following function

- (void)scopeTransitionDidEnd:(UIPanGestureRecognizer *)panGesture

If you agree, I would like to submit another code patch, to fix on scopeTransitionDidEnd.

Thank you very much for the your wonderful library. I just start learning on your library to integrate into my project, and hopefully can provide meaningful contribution soon.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the patch on scopeTransitionDidEnd 👍

//
// (1) Scroll down to switch from week view to month view.
// (2) Without releasing gesture, reverse scroll direction to up, to switch back week view.
// (3) Once we hit week view, and continue the scroll-up action, we can observe scrolling "overflow" behavior.
//
// or
//
// (1) Scroll up to switch from month view to week view.
// (2) Without releasing gesture, reverse scroll direction to down, to switch back month view.
// (3) Once we hit month view, and continue the scroll-down action, we can observe scrolling "overflow" behavior.
//
switch (self.calendar.scope) {
case FSCalendarScopeMonth: {
if (y > 0) {
y = 0;
}
break;
}
case FSCalendarScopeWeek: {
if (y < 0) {
y = 0;
}
break;
}
}

CGFloat translation = ABS(y);
CGFloat progress = ({
CGFloat maxTranslation = ABS(CGRectGetHeight(self.transitionAttributes.targetBounds) - CGRectGetHeight(self.transitionAttributes.sourceBounds));
translation = MIN(maxTranslation, translation);
Expand Down