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

triggerScrollToDateDelegate does not trigger willScrollToDateSegmentWith #1262

Open
kushsolitary opened this issue May 7, 2020 · 4 comments

Comments

@kushsolitary
Copy link

Hi, I am on version 8.0.3.

While performing calendar.scrollToDate, I noticed that the delegate function willScrollToDateSegmentWith is not triggered but didScrollToDateSegmentWith is triggered perfectly.

I currently load my data in willScrollToDateSegmentWith for the visible dates so is there any way to force the delegate function to trigger before the calendar.scrollToDate is triggered?

I also noticed that the completion handler of calendar.scrollToDate triggers before the animation ends so if I try to select a date in the completion handler, it doesn't work.

Thank you!

@kushsolitary
Copy link
Author

I just checked the code which deals with scrolling and I can see that it only calls the didScrollToDateSegmentWith method.

    func scrollTo(point: CGPoint, triggerScrollToDateDelegate: Bool? = nil, isAnimationEnabled: Bool, extraAddedOffset: CGFloat, completionHandler: (() -> Void)?) {
        isScrollInProgress = true
        if let validCompletionHandler = completionHandler { scrollDelayedExecutionClosure.append(validCompletionHandler) }
        self.triggerScrollToDateDelegate = triggerScrollToDateDelegate
        var point = point
        if scrollDirection == .horizontal { point.x += extraAddedOffset } else { point.y += extraAddedOffset }
        DispatchQueue.main.async() {
            self.setContentOffset(point, animated: isAnimationEnabled)
            if (isAnimationEnabled && self.calendarOffsetIsAlreadyAtScrollPosition(forOffset: point)) ||
                !isAnimationEnabled {
                self.scrollViewDidEndScrollingAnimation(self)
            }
        }
    }

I would like to know why you decided to not include willScrollToDateSegmentWith here because I am very tempted to do so myself but I am worried it might break something else.

@patchthecode
Copy link
Owner

Do it.
Let me know how it goes.
I will take a look as well, its just that given this current time, I am a little tied up.

Help on this project is always welcomed.

@kushsolitary
Copy link
Author

kushsolitary commented May 8, 2020

Thanks, I fixed it in the PR #1264

@bystritskiy
Copy link

bystritskiy commented Dec 1, 2022

@patchthecode please, look this 2 PRs :)

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

No branches or pull requests

3 participants