Skip to content

Commit

Permalink
Fix issue #432
Browse files Browse the repository at this point in the history
Decrease alpha improvement
  • Loading branch information
WenchaoD committed Oct 1, 2016
1 parent 0ecc475 commit fe527bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 4 additions & 5 deletions FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtInde
if (_placeholderType == FSCalendarPlaceholderTypeNone) return NO;
if ([self isDateInRange:cell.date]) {
[self selectDate:cell.date scrollToDate:YES forPlaceholder:YES];
} else if (![self.gregorian isDate:cell.date equalToDate:_currentPage toUnitGranularity:NSCalendarUnitMonth]){
[self scrollToPageForDate:cell.date animated:YES];
}
return NO;
}
Expand Down Expand Up @@ -847,7 +845,6 @@ - (void)setCurrentPage:(NSDate *)currentPage
- (void)setCurrentPage:(NSDate *)currentPage animated:(BOOL)animated
{
[self requestBoundingDatesIfNecessary];
FSCalendarAssertDateInBounds(currentPage,self.gregorian,self.minimumDate,self.maximumDate);
if (self.floatingMode || [self isDateInDifferentPage:currentPage]) {
currentPage = [self.gregorian dateBySettingHour:0 minute:0 second:0 ofDate:currentPage options:0];
[self scrollToPageForDate:currentPage animated:animated];
Expand Down Expand Up @@ -1250,15 +1247,15 @@ - (void)scrollToDate:(NSDate *)date animated:(BOOL)animated
animated &= _scrollEnabled; // No animation if _scrollEnabled == NO;
_supressEvent = !animated;

FSCalendarAssertDateInBounds(date,self.gregorian,self.minimumDate,self.maximumDate);

NSInteger scrollOffset = 0;
switch (_scope) {
case FSCalendarScopeMonth: {
FSCalendarAssertDateInBounds(date,self.gregorian,[self beginingOfMonth:self.minimumDate],[self endOfMonth:self.maximumDate]);
scrollOffset = [self.gregorian components:NSCalendarUnitMonth fromDate:[self beginingOfMonth:self.minimumDate] toDate:date options:0].month;
break;
}
case FSCalendarScopeWeek: {
FSCalendarAssertDateInBounds(date,self.gregorian,[self beginingOfWeek:self.minimumDate],[self endOfWeek:self.maximumDate]);
scrollOffset = [self.gregorian components:NSCalendarUnitWeekOfYear fromDate:[self beginingOfWeek:self.minimumDate] toDate:date options:0].weekOfYear;
break;
}
Expand Down Expand Up @@ -1307,10 +1304,12 @@ - (void)scrollToPageForDate:(NSDate *)date animated:(BOOL)animated
NSDate *lastPage = _currentPage;
switch (_scope) {
case FSCalendarScopeMonth: {
FSCalendarAssertDateInBounds(date, self.gregorian, [self beginingOfMonth:self.minimumDate], [self endOfMonth:self.maximumDate]);
_currentPage = [self beginingOfMonth:date];
break;
}
case FSCalendarScopeWeek: {
FSCalendarAssertDateInBounds(date, self.gregorian, [self beginingOfWeek:self.minimumDate], [self endOfWeek:self.maximumDate]);
_currentPage = [self beginingOfWeek:date];
break;
}
Expand Down
8 changes: 3 additions & 5 deletions FSCalendar/FSCalendarAnimator.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ - (void)performScopeTransitionFromScope:(FSCalendarScope)fromScope toScope:(FSCa
self.transition = FSCalendarTransitionWeekToMonth;
}

// animated &= !FSCalendarInAppExtension;

// Start transition
self.state = FSCalendarTransitionStateInProgress;
FSCalendarTransitionAttributes *attr = self.transitionAttributes;
Expand Down Expand Up @@ -571,7 +569,7 @@ - (void)performForwardTransition:(FSCalendarTransition)transition fromProgress:(

self.calendar.contentView.clipsToBounds = YES;

CGFloat currentAlpha = MAX(1-progress*1.2,0);
CGFloat currentAlpha = MAX(1-progress*1.1,0);
CGFloat duration = 0.3;
[self performAlphaAnimationFrom:currentAlpha to:0 duration:0.22 exception:attr.focusedRowNumber completion:^{
[self performTransitionCompletionAnimated:YES];
Expand Down Expand Up @@ -621,7 +619,7 @@ - (void)performBackwardTransition:(FSCalendarTransition)transition fromProgress:
{
switch (transition) {
case FSCalendarTransitionMonthToWeek: {
[self performAlphaAnimationFrom:MAX(1-progress*1.2,0) to:1 duration:0.3 exception:self.pendingAttributes.focusedRowNumber completion:^{
[self performAlphaAnimationFrom:MAX(1-progress*1.1,0) to:1 duration:0.3 exception:self.pendingAttributes.focusedRowNumber completion:^{
[self.calendar.collectionView.visibleCells enumerateObjectsUsingBlock:^(__kindof UICollectionViewCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.contentView.layer.opacity = 1;
[obj.contentView.layer removeAnimationForKey:@"opacity"];
Expand Down Expand Up @@ -702,7 +700,7 @@ - (void)performAlphaAnimationFrom:(CGFloat)fromAlpha to:(CGFloat)toAlpha duratio

- (void)performAlphaAnimationWithProgress:(CGFloat)progress
{
CGFloat opacity = self.transition == FSCalendarTransitionMonthToWeek ? MAX((1-progress*1.2),0) : progress;
CGFloat opacity = self.transition == FSCalendarTransitionMonthToWeek ? MAX((1-progress*1.1),0) : progress;
[self.collectionView.visibleCells enumerateObjectsUsingBlock:^(FSCalendarCell *cell, NSUInteger idx, BOOL *stop) {
if (CGRectContainsPoint(self.collectionView.bounds, cell.center)) {
BOOL shouldPerformAlpha = NO;
Expand Down

0 comments on commit fe527bc

Please sign in to comment.