Skip to content

Commit

Permalink
Fixed.
Browse files Browse the repository at this point in the history
Added Workaround -

1.
// to handle #26
if cellInset.x == 0 { cellInset.x = -0.1 }
if cellInset.y == 0 { cellInset.y = -0.1 }

2.
Fixed issue
#235
  • Loading branch information
patchthecode committed Dec 16, 2016
1 parent 8308165 commit c696a02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Sources/JTAppleCalendarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/UserInteractionFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -575,16 +575,17 @@ 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.
// If the calendar has no headers registered, then this function does
// 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])
Expand Down

0 comments on commit c696a02

Please sign in to comment.