triggerScrollToDateDelegate does not trigger willScrollToDateSegmentWith
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!
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.
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.
Thanks, I fixed it in the PR #1264
@patchthecode please, look this 2 PRs :)