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

month-1 does nothing sometimes #22

Closed
brizzly opened this issue Oct 25, 2017 · 6 comments
Closed

month-1 does nothing sometimes #22

brizzly opened this issue Oct 25, 2017 · 6 comments

Comments

@brizzly
Copy link

brizzly commented Oct 25, 2017

There is an issue when you call previous month method, sometimes it does not go to the desired month-1.

Here is an ugly fix based on previous code..

func setDisplayDate(_ date : Date, animated: Bool) {
	
	if let dispDate = self.displayDate {
		
		// skip is we are trying to set the same date
		if  date.compare(dispDate) == ComparisonResult.orderedSame {
			return
		}
		
		// check if the date is within range
		
		if startDateCache == date {
			return
		}
		if let startDateCache2 = self.calendar.date(byAdding: .month, value: -1, to: startDateCache) {
			if  date.compare(startDateCache2) == ComparisonResult.orderedAscending {
				return
			}
		}
		else
		{
			if  date.compare(startDateCache) == ComparisonResult.orderedAscending {
				return
			}
		}
		
		if  date.compare(endDateCache) == ComparisonResult.orderedDescending   {
			return
		}
		
		
		self.collectionView.setContentOffset(
			self.scrollViewOffset(in: self.collectionView, for: date),
			animated: animated
		)
		
	}
	
}

/*
func setDisplayDate(_ date : Date, animated: Bool) {
	
	// Julien
	if date == startDateCache {
		return
	}
	let newStartDateCache = self.calendar.date(byAdding: .month, value: -1, to: startDateCache)

		
	guard (date > newStartDateCache!) && (date < endDateCache) else { return }
	
	self.collectionView.setContentOffset(
		self.scrollViewOffset(in: self.collectionView, for: date),
		animated: animated
	)
	
	self.displayDateOnHeader(date)
	
}
*/
@mmick66
Copy link
Owner

mmick66 commented Oct 27, 2017

I checked and I cannot reproduce the problem. Please let me know exactly which dates are you setting in your data source and I will try to replicate it on my side. Remember that the calendar will not scroll past its start and end dates as set by the data source.

Check the latest code as I made some changes, and above all thank you for using my code.

@mmick66 mmick66 closed this as completed Nov 2, 2017
@brizzly
Copy link
Author

brizzly commented Nov 2, 2017

I'm sure there is a bug lol. I have fixed into my code. Swip back is working but not when you call previousMonth method, you stuck 1 month after.

@mmick66
Copy link
Owner

mmick66 commented Nov 2, 2017

Like I said above, can you let me know exactly which dates are you setting in your data source and I will try to replicate it on my side?

@mmick66 mmick66 reopened this Nov 2, 2017
@brizzly
Copy link
Author

brizzly commented Nov 2, 2017

any date.. let say : 25/10/17

@mmick66
Copy link
Owner

mmick66 commented Nov 2, 2017

Can you please copy and paste the code from your delegate that returns the start and end?

@mmick66
Copy link
Owner

mmick66 commented Nov 3, 2017

Can you please zip your project and drop it here so I can have a look?

@mmick66 mmick66 closed this as completed Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants