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

How to know when the calendar stop scrolling? #126

Closed
IsmailHassanein opened this issue Oct 23, 2015 · 9 comments
Closed

How to know when the calendar stop scrolling? #126

IsmailHassanein opened this issue Oct 23, 2015 · 9 comments

Comments

@IsmailHassanein
Copy link

Hi @WenchaoIOS
I have a lot of events to load in the calendar for 10 years range. what I'm trying to do it loading more data with scrolling and when loading finishes I call calendar.relaodData(). The problem is when that happens while the calendar is still dragging or decelerating, the scrolling is interrubtted. What I want to do is get the data and check before I reload the calendar if it's scrolling or not. if not scrolling I update the calendar with the new data if still scrolling I set calendarNeedsUpdate = true, but I couldn't find a way to detect when the calendar stop scrolling to update it.
If there is a way to get notifiyed when it stop scrolling or anyother suggesstion is much appreciated.
Thanks,

@WenchaoD
Copy link
Owner

Why not loading on calendarCurrentPageDidChange:?

@IsmailHassanein
Copy link
Author

@WenchaoIOS Sorry for not explaining my problem accurately.
I use calendarCurrentPageDidChange() to call the API and get more data for the next 4 months. then update the data source and call reloadData().
My problem is when I call calendar.reloadData() at the time the calendar is scrolling, it makes the scroll jumpy and not smooth. So I thought of call the API in calendarCurrentPageDidChange() but make sure not to call calendar.reloadData() until it stop scrolling. So I need to know when it stops scrolling.
Thanks.

@IsmailHassanein
Copy link
Author

@WenchaoIOS Any Suggestions?

@WenchaoD
Copy link
Owner

What do you mean by 'jumpy'?

@IsmailHassanein
Copy link
Author

Not smooth. the loading interrupts the scrolling animation when I call calendar.relaodData() while the calendar is scrolling.

@WenchaoD
Copy link
Owner

Can you make a sample project? A repo or a droxbox link?

@IsmailHassanein
Copy link
Author

https://www.dropbox.com/s/fsm4dlugt5g6zmi/FSCalendar-1.6.2%202.zip?dl=0
it's not the same but something similar. the main idea is calling relaodData while scrolling.
please find my change and try the FullScreen example.

The best thing I'm looking for is to be able to do something like instead of reloadData directelly. call updateCalendarI()

var calendarNeedsUpdate  = false 
func  updateCalendarI(){
if   calendar.collectionView.dragging == false && calendar.collectionView.decelerating == false {
   calendar.reloadData()
} else {
calendarNeedsUpdate = true
}
}
func SomewhereIGetNotifiedWhenCalenarStopsScrolling () {
    if calendarNeedsUpdate {
      calendar.relaodData()
}
}

@WenchaoD
Copy link
Owner

WenchaoD commented Nov 1, 2015

I've pushed a few commits to make reloadData looks less 'jumpy'. Try this branch?

@IsmailHassanein
Copy link
Author

Hi @WenchaoIOS
I have tried the updated master branch today. there is a problem if you scroll fast you will find the cell day number changes. as it has not beed reset properly before reused or an async proccess updated the cell after it has been reused by another indexPath.I'm not sure, I didn't check the code. it's only what I observed.

To observe it, you need to set some borders, colours and title colors (make it needs more time to proccess) and load it on a slow machine (I use iPad 2)
I'll open an issue for this.

@WenchaoD WenchaoD closed this as completed Nov 5, 2015
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