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

fixed targetPage not current month #1261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion FSCalendar/FSCalendarTransitionCoordinator.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,22 @@ - (FSCalendarTransitionAttributes *)createTransitionAttributesTargetingScope:(FS
coordinate.row;
});
attributes.targetPage = ({
NSDate *targetPage = targetScope == FSCalendarScopeMonth ? [self.calendar.gregorian fs_firstDayOfMonth:attributes.focusedDate] : [self.calendar.gregorian fs_middleDayOfWeek:attributes.focusedDate];
__block NSDate *targetPage = nil;
if (targetScope == FSCalendarScopeMonth) {
targetPage = [self.calendar.gregorian fs_firstDayOfMonth:attributes.focusedDate];
}else{
NSDate *middleDay = [self.calendar.gregorian fs_middleDayOfWeek:attributes.focusedDate];
NSDate *firstDay = [self.calendar.gregorian fs_firstDayOfWeek:attributes.focusedDate];
NSDate *lastDay = [self.calendar.gregorian fs_lastDayOfWeek:attributes.focusedDate];
NSInteger focusedMonth = [self.calendar.gregorian component:NSCalendarUnitMonth fromDate:attributes.focusedDate];
[@[middleDay,firstDay,lastDay] enumerateObjectsUsingBlock:^(NSDate * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSInteger currentMonth = [self.calendar.gregorian component:NSCalendarUnitMonth fromDate:obj];
if (currentMonth == focusedMonth) {
targetPage = obj;
*stop = YES;
}
}];
}
targetPage;
});
attributes.targetBounds = [self boundingRectForScope:attributes.targetScope page:attributes.targetPage];
Expand Down