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

Find out if header stuck to top #9

Open
filipandrei87 opened this issue Mar 18, 2015 · 3 comments
Open

Find out if header stuck to top #9

filipandrei87 opened this issue Mar 18, 2015 · 3 comments
Labels

Comments

@filipandrei87
Copy link

Hi. Is there a way to find out when a header became sticky?
I would like to add a drop shadow to the header when it becomes sticky.

Thanks

@fillito
Copy link
Member

fillito commented Mar 18, 2015

I think you could simply implement scrollViewDidScroll: delegate method and check if the header's frame origin is in (0,0). That would be exactly when the header gets sticked.

@filipandrei87
Copy link
Author

In my case, the first section does not have a header. So no header will get to (0,0). However, i can check if scrollview.contentOffset is inside header.frame. Actually, I noticed this is not always exact either so I did something like:

if (CGRectContainsPoint(header.frame, CGPointMake(scrollView.contentOffset.x, scrollView.contentOffset.y + header.frame.size.height/2)))

I have more than 20 different section. Going through all the headers every time scrollViewDidScroll gets called and checking their frames seems overkill.

I was looking for a way to add a new delegate method to inform me when a header (ideally which header also) became sticky.

@fillito
Copy link
Member

fillito commented Mar 18, 2015

Seems like a nice feature to me. We would be happy to implement it, but we are very busy these weeks. If you don't mind to wait, we could add this at the end of the month/beginning of the next one...

But we are happy to receive pull requests. So if you want to add it yourself and send us a PR, it would be awesome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants