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

trigger willScrollToDateSegmentWith when scrolling programmatically with scrollToSegment #1327

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

elliotcz97
Copy link

@elliotcz97 elliotcz97 commented May 30, 2021

This PR is a fix and a followup on #1262

My problem was that when I programmatically scrolled the calendar with the function scrollToSegment, then the willScrollToDateSegmentWith delegate did not get called.

I wanted this delegate to work because i wanted to deselect all dates before the scroll did end. I searched for an answer and found the PR #1264 which made the delegate work when the user scrolled with dragging the scrollview. But it did not fix my issue. So i forked his solution and added my fix.

So this PR fixes the willScrollToDateSegmentWith delegate. Now it will get called whenever you scroll via dragging the scrollview, or programmatically using scrollToSegment.

@bystritskiy
Copy link

You need to fix merge conflicts :)

@@ -356,7 +356,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = GBBYECNDQ9;

Choose a reason for hiding this comment

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

Doesn't need

@@ -384,7 +384,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = GBBYECNDQ9;

Choose a reason for hiding this comment

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

Doesn't need

// This was needed for when the user scrolls to next segment which will be the last,
// then the value is not exact the same as the height of the content,
// and then the didScrollToSegment delegate got called before the scroll happened, this fixed it.

Choose a reason for hiding this comment

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

Empty line


// If we added maybe too much days we check if we are in the range of the calendar
// if we gone too far we just use the endDate of the Calendar
if correctedNextDate < endDateCache

Choose a reason for hiding this comment

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

You can change to:

date = correctedNextDate < endDateCache ? correctedNextDate : endDateCache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants