diff --git a/Sources/JTAppleCalendarView.swift b/Sources/JTAppleCalendarView.swift index 9f1d1733..8bb12145 100644 --- a/Sources/JTAppleCalendarView.swift +++ b/Sources/JTAppleCalendarView.swift @@ -221,7 +221,13 @@ open class JTAppleCalendarView: UIView { /// Cell inset padding for the x and y axis /// of every date-cell on the calendar view. - open var cellInset: CGPoint = CGPoint(x: 3, y: 3) + open var cellInset: CGPoint = CGPoint(x: 3, y: 3) { + didSet { + // to handle https://github.com/patchthecode/JTAppleCalendar/issues/26 + if cellInset.x == 0 { cellInset.x = -0.1 } + if cellInset.y == 0 { cellInset.y = -0.1 } + } + } var cellViewSource: JTAppleCalendarViewSource! var registeredHeaderViews: [JTAppleCalendarViewSource] = [] var thereAreHeaders: Bool { @@ -497,7 +503,6 @@ open class JTAppleCalendarView: UIView { animated: animation) if !animation { self.scrollViewDidEndScrollingAnimation(self.calendarView) - self.scrollInProgress = false } else { // If the scroll is set to animate, and the target // content offset is already on the screen, then the @@ -506,9 +511,9 @@ open class JTAppleCalendarView: UIView { // let's force a scroll so the delegate MUST get caalled if self.calendarOffsetIsAlreadyAtScrollPosition(forOffset: topOfHeader) { self.scrollViewDidEndScrollingAnimation(self.calendarView) - self.scrollInProgress = false } } + self.scrollInProgress = false } } } diff --git a/Sources/UserInteractionFunctions.swift b/Sources/UserInteractionFunctions.swift index 775e5bd4..d8eb2144 100644 --- a/Sources/UserInteractionFunctions.swift +++ b/Sources/UserInteractionFunctions.swift @@ -394,7 +394,7 @@ extension JTAppleCalendarView { /// - Paramater animateScroll: Bool indicating if animation should be enabled /// - Parameter triggerScrollToDateDelegate: trigger delegate if set to true /// - Parameter completionHandler: A completion handler that will be executed at the end of the scroll animation - public func scrollToSegment(_ destination: SegmentDestination, triggerScrollToDateDelegate: Bool = false, animateScroll: Bool = true, completionHandler: (() -> Void)? = nil) { + public func scrollToSegment(_ destination: SegmentDestination, triggerScrollToDateDelegate: Bool = true, animateScroll: Bool = true, completionHandler: (() -> Void)? = nil) { if !calendarIsAlreadyLoaded { delayedExecutionClosure.append { self.scrollToSegment(destination, triggerScrollToDateDelegate: triggerScrollToDateDelegate, animateScroll: animateScroll, completionHandler: completionHandler) @@ -575,7 +575,9 @@ extension JTAppleCalendarView { if let validCompletionHandler = completionHandler { self.delayedExecutionClosure.append(validCompletionHandler) } + self.triggerScrollToDateDelegate = triggerScrollToDateDelegate calendarView.scrollRectToVisible(rect, animated: isAnimationEnabled) + scrollInProgress = false } /// Scrolls the calendar view to the start of a section view header. @@ -583,8 +585,7 @@ extension JTAppleCalendarView { // nothing /// - Paramater date: The calendar view will scroll to the header of // a this provided date - public func scrollToHeaderForDate( - _ date: Date, triggerScrollToDateDelegate: Bool = false, + public func scrollToHeaderForDate(_ date: Date, triggerScrollToDateDelegate: Bool = false, withAnimation animation: Bool = false, completionHandler: (() -> Void)? = nil) { let path = pathsFromDates([date])