Skip to content

Commit

Permalink
Fix problem #113
Browse files Browse the repository at this point in the history
Fix problem #113
  • Loading branch information
WenchaoD committed May 29, 2016
1 parent 8733cf7 commit 80503c1
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ - (void)layoutSubviews
}];
hasDisabledOtherGesture = YES;
}

_supressEvent = YES;

if (_needsAdjustingViewFrame) {
Expand Down Expand Up @@ -696,23 +696,25 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi
break;
}
}
BOOL shouldTriggerPageChange = ((pannedOffset < 0 && targetOffset > currentOffset) ||
(pannedOffset > 0 && targetOffset < currentOffset)) && _minimumDate;

NSDate *targetPage = nil;
switch (_scope) {
case FSCalendarScopeMonth: {
NSDate *minimumPage = [self beginingOfMonthOfDate:_minimumDate];
targetPage = [self dateByAddingMonths:targetOffset/contentSize toDate:minimumPage];
break;
}
case FSCalendarScopeWeek: {
NSDate *minimumPage = [self beginingOfWeekOfDate:_minimumDate];
targetPage = [self dateByAddingWeeks:targetOffset/contentSize toDate:minimumPage];
break;
}
}
BOOL shouldTriggerPageChange = [self isDateInDifferentPage:targetPage];
if (shouldTriggerPageChange) {
NSDate *lastPage = _currentPage;
[self willChangeValueForKey:@"currentPage"];
switch (_scope) {
case FSCalendarScopeMonth: {
NSDate *minimumPage = [self beginingOfMonthOfDate:_minimumDate];
_currentPage = [self dateByAddingMonths:targetOffset/contentSize toDate:minimumPage];
break;
}
case FSCalendarScopeWeek: {
NSDate *minimumPage = [self beginingOfWeekOfDate:_minimumDate];
_currentPage = [self dateByAddingWeeks:targetOffset/contentSize toDate:minimumPage];
break;
}
}
_currentPage = targetPage;
[self currentPageDidChange];
if (!_showsPlaceholders && self.animator.state == FSCalendarTransitionStateIdle) {
[self.animator performBoudingRectTransitionFromMonth:lastPage toMonth:_currentPage duration:0.25];
Expand Down

0 comments on commit 80503c1

Please sign in to comment.